icculus / mojoshader

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

SPIR-V: Remove color relocation logic for non-glspirv profiles #66

Closed TheSpydog closed 3 months ago

TheSpydog commented 3 months ago

MOJOSHADER_spirv_link_attributes performs some postprocessing operations on the SPIR-V content to rearrange and match up vertex output and pixel input. This is necessary for cross-stage linkage, and it works for Vulkan and OpenGL. However, when using SPIRV-Cross to transpile the emitted SPIR-V into HLSL, there are certain relocations that produce invalid HLSL. Specifically, the dedicated logic for COLOR attributes results in vertex outputs/pixel inputs with "holes" in them, which will cause link errors when compiling the HLSL.

This PR disables the COLOR attribute relocation logic on non-glspirv profiles. The logic was added specifically for OpenGL 4.6 SPIR-V support in the first place, so it's unnecessary on other profiles anyway. (In fact, it may be unnecessary even with glspirv -- all my tests seemed to run as expected with all of the color relocation disabled! But just for safety, we'll keep it for now.)