icculus / mojoshader

Use Direct3D shaders with other 3D rendering APIs.
https://icculus.org/mojoshader/
zlib License
150 stars 37 forks source link

spirv: Add patch table for vertex attribute types #70

Closed flibitijibibo closed 2 months ago

flibitijibibo commented 2 months ago

This one's for @thatcosmonaut and @TheSpydog - this should at least get the offsets for when attribs are declared and loaded:

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").

Fixes #68