icculus / mojoshader

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

Examine behavior for obscure D3D attributes #1

Closed flibitijibibo closed 5 years ago

flibitijibibo commented 6 years ago

This is a follow-up issue for https://github.com/FNA-XNA/FNA/issues/69.

For whatever reason TEXCOORD has inconsistent (and more importantly, undocumented) behavior even in D3D, leading to the use of high attrib index values like 5-9. Internally we use gl_TexCoord for GLSL 1.20 and varyings in all other scenarios (including the new SPIR-V stuff, I think).

We need to find out if D3D is being rather dastardly with higher values and secretly treating those as standard vec4s rather than built-ins, and adjust MojoShader accordingly.

CC @jsmars

flibitijibibo commented 5 years ago

Finally got my own test case for this. From what I can tell, the gl_TexCoord array has a cap of either 4 or 8, either way it's entirely avoidable so we play it safe and use a generic variable for index values >= 4:

https://github.com/FNA-XNA/MojoShader/commit/df8a5c1674e99f6cf0d4d9cb28c138fd217ec543