Closed nosferalatu closed 10 years ago
Here's a small repro I've been able to make:
bool g_bBoolParam;
int g_IntParam;
void TestVS(int4 vPos : POSITION, out float4 oPosition : POSITION)
{
int4 value;
if (g_bBoolParam)
value = vPos;
else
value = 0;
value += g_IntParam;
oPosition = value;
}
I save the above as shader.hlsl and compile with:
fxc.exe /Tvs_4_0 /ETestVS /Foshader.bin shader.hlsl
hlslcc.exe -in=shader.bin -out=shader.glsl -lang=150
Also, I uncommented the ASSERT on line 2167 of toGLSLInstruction.c. That assertion is failing; the operand[2] is SVT_UINT and operand[3] is SVT_FLOAT.
The BitwiseOnFloat branch was created to sort out this and other problems. I'll see if I can finish it and move to master this\next week.
Thanks, James. Is there anything I could do to help out? Is that branch in a working state that I could checkout and test with my shaders? Otherwise, I'll be looking forward to when that's merged with master.
We're integrating HLSLCrossCompiler into the shader pipeline at my employer, Double Fine. Our shader source code is ~15K lines of HLSL, although that's before shader permutation generation. Everything's been successfully converted by HLSLCC, but at runtime, GLSL reports many implicit casting errors. Some good news, though, is that those seem to be the only errors reported.
Its a proof-of-concept branch which has gotten out of date, difficult to merge and only fixes a subset of opcodes. If need be I can lay the foundations and then describe what is left to do for you to look at so you don't wait on me.
I just checked out the BitwiseOnFloat branch. It passes the first test (this issue) but fails the second test (issue 21 https://github.com/James-Jones/HLSLCrossCompiler/issues/21 ). However, I uncommented the block of code in toGLSLInstruction.c line 1775, and both tests now work.
"If need be I can lay the foundations and then describe what is left to do for you to look at so you don't wait on me."
That sounds great to me. I'd be happy to help out when it's ready; HLSLCrossCompiler will be very useful to our studio. |I was hoping we'd be able to use hlslcc immediately (production deadlines are looming :) but with a bit more work I think we'll be able to use it.
The reported shader now compiles.
When calling glCompileShader() with GLSL generated by HLSLCrossCompiler, GL says 'error C7011: implicit cast from "float" to "uint"'. I'm using an NVIDIA GPU. I tracked down the issue to this line of D3D microcode:
This cross compiles into:
The issue seems to be that the HLSL literal 'l(0)' is cross compiled into '0.000000' and not '0'.
I'm about to start digging through the HLSLCrossCompiler code, but I'm not sure where to start. I assume that since it knows the left-hand side is a uint that it will be able to work out that the right-hand side should be a uint?