spirv: Add patch table for vertex attribute types #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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