Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[DX] Shader parameter semantics are ignored #6282
Shader parameters are bound by position rather than by semantics for WindowsDX projects. For DesktopGL parameters are bound correctly.
I set up a minimal project that shows the issue: https://github.com/Jjagg/MgSemanticsBug
and the pixel shader:
For DesktopGL this correctly outputs the color that's passed in (green), but for WindowsDX this outputs red. So
What version of MonoGame does the bug occur on:
What operating system are you using:
What MonoGame platform are you using:
That's a DX runtime thing with user-semantics needing to be in sequence between stages when passed argument style. You'd have to parse and automatically restructure the HLSL to fix, since when a shader for a stage is compiled it's clueless about the other stages.
Shows its head all the time when you're plugging in some GS/HS+DS into some existing shaders that use that awful function style.
I think this is what the effect-compiler tool (fxc) does. Though I can't seem to find documentation on it.
This is a bit tricky to do for us right now since our effects parser is very limited. Once we switch to a more complete parsing approach, rewriting the parameter order should become pretty doable with some syntax tree manipulations.
It would require adding SharpDX.Direct3D11 as a dependency but as far as I'm aware the signature checking functions don't require an actual device context to be active, so could maybe at least provide an error ahead of time. Granted I've never bothered with using them since turning on the debug layer has it screaming at you about signature compliance.
O/T: Is there anything more detailed on the 2MGFX pipeline and where it's going? It's seemingly stagnated so long that I just said screw it and added GS/HS/DS a few days ago despite some minor confusion with d3dx_state's operation field and some seemingly nonsensical parser constructs for parameters (commits, runtime untested - compiling checks out so far). It felt like everything in there was being pulled all sorts of ways.