icculus / mojoshader

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

Add patching stage to SPIR-V for vertex attrib types #68

Closed flibitijibibo closed 2 weeks ago

flibitijibibo commented 3 weeks ago

Previously we were exploiting Vulkan's SCALED types, but this doesn't hold up when SPIRV-Cross gets involved and it won't hold up for SDL_gpu since it can't provide scaled types. I don't think it will be as involved as HLSL/D3D11 but I also don't know if we have to patch in type conversion helpers.

CC @thatcosmonaut @TheSpydog

flibitijibibo commented 3 weeks ago

This is where the attrib is emitted, it doesn't have a type declaration so it may get determined when the attrib is loaded, rather than declared?

https://github.com/icculus/mojoshader/blob/main/profiles/mojoshader_profile_spirv.c#L288

flibitijibibo commented 3 weeks ago

Here's where vertex inputs are emitted:

https://github.com/icculus/mojoshader/blob/main/profiles/mojoshader_profile_spirv.c#L2218

We can likely pad the top with OpNop instructions to make room for OpConvertUToF as needed.