Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spirv: Add patch table for vertex attribute types #70

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

flibitijibibo
Copy link
Collaborator

@flibitijibibo flibitijibibo commented Aug 22, 2024

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

Fixes #68

@flibitijibibo flibitijibibo merged commit fd72f3c into main Aug 22, 2024
6 checks passed
@flibitijibibo flibitijibibo deleted the attrib_types branch August 22, 2024 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add patching stage to SPIR-V for vertex attrib types
1 participant