In the Chapter 8 code, there is the following code in Model.swift:
encoder.setVertexBytes(
&uniforms,
length: MemoryLayout<Uniforms>.stride,
index: UniformsBuffer.index)
encoder.setFragmentBytes(
¶ms,
length: MemoryLayout<Uniforms>.stride,
index: ParamsBuffer.index)
That length
parameter in the second call should be MemoryLayout<Params>.stride
, not MemoryLayout<Uniforms>.stride
. I also think a similar error exists in Chapter 7 code as well, where the actual text says:
In
draw(in:)
, before calling the methods to render the model or quad, send the parameters to the fragment function:renderEncoder.setFragmentBytes( ¶ms, length: MemoryLayout<Uniforms>.stride, index: 12)