I’m following along the Third Edition of Metal by Tutorials and have run into an issue when Shader Validation is enabled. This happens when we are constructing the vertex shader using a buffer of bytes.
Even after making the change to use a
packed_float3 to have the shader’s data type use the same amount of bytes for a vertex as our Swift
Float array would, the following is shown:
**Invalid device load executing vertex function "vertex_main" encoder: "0", draw: 0, at offset 72** buffer: <unnamed>, length:72, resident:Read Write
This happens on the latest version of macOS Monterrey on an M1 MacBook Pro, but only for the
Vertex (macOS) scheme that was included with the starter project.
The same code, running on the iOS Simulator, does not result in the same shader validation message.
I tried changing the vertex shader to use just a pointer to an array of
float, and then traversing through things one pixel at a time to construct a
float4 for the vertex, but without any successful results.
I also tried using a
simd_float1 in Swift, for the vertices array, and then a
simd_float3 in the vertex shader alas with the same results.
Note that the quad renders ok, but that validation error is throwing me off
Would you be kind enough to provide some insight into why this is happening? I tend to be very curious and like to understand why and how things work (or don’t, as in this case).
Many thanks in advance!