This one's for @thatcosmonaut and @TheSpydog - this should at least get the offsets for when attribs are declared and loaded:
attrib_type_offsets is the word offset for the type id when the input is declared - when passing the vertex element bindings to MojoShader this is where we change it from vec3 to ivec4/uvec4 depending on the vertex format.
attrib_type_load_offsets is the full list of offsets where the attrib is loaded via SpvOpLoad, and then either copied via SpvOpCopyObject or converted via either SpvOpConvertSToF or SpvOpConvertUToF.
So, for example, for a ubyte4 element, the shader runtime needs to change the value at attrib_type_offsets[usage][index] to tid_uvec4_p, and then for all loads in attrib_type_load_offsets[usage][index] the types will be changed to tid_uvec4 and the opcodes will be changed to SpvOpConvertUToF.
Testing/Reviewing this will require modifying mojoshader_sdlgpu to export a vertex shader compilation stage, and then modifying FNA3D to make use of it. I think the offsets are right, but base_offset may need to be updated depending on which chunk of the SPIR-V module certain offsets reside in (i.e. "do we need to add mainline_intro to the base_offset before doing the word arithmetic to finalize the load offsets").
This one's for @thatcosmonaut and @TheSpydog - this should at least get the offsets for when attribs are declared and loaded:
attrib_type_offsets
is the word offset for the type id when the input is declared - when passing the vertex element bindings to MojoShader this is where we change it from vec3 to ivec4/uvec4 depending on the vertex format.attrib_type_load_offsets
is the full list of offsets where the attrib is loaded viaSpvOpLoad
, and then either copied viaSpvOpCopyObject
or converted via eitherSpvOpConvertSToF
orSpvOpConvertUToF
.So, for example, for a ubyte4 element, the shader runtime needs to change the value at
attrib_type_offsets[usage][index]
totid_uvec4_p
, and then for all loads inattrib_type_load_offsets[usage][index]
the types will be changed totid_uvec4
and the opcodes will be changed toSpvOpConvertUToF
.Testing/Reviewing this will require modifying mojoshader_sdlgpu to export a vertex shader compilation stage, and then modifying FNA3D to make use of it. I think the offsets are right, but
base_offset
may need to be updated depending on which chunk of the SPIR-V module certain offsets reside in (i.e. "do we need to add mainline_intro to the base_offset before doing the word arithmetic to finalize the load offsets").Fixes #68