James-Jones / HLSLCrossCompiler

Other
468 stars 81 forks source link

Another implicit cast issue #21

Closed nosferalatu closed 10 years ago

nosferalatu commented 10 years ago

I'm seeing a separate issue that is causing implicit cast errors. Given this HLSL:

void TestVS(float4 vPos : POSITION, out float4 oPosition : POSITION)
{
    float4 value;
    if (vPos.x == 1 && vPos.y == 1)
        value = 0;
    else
        value = 1;
    oPosition = value;
}

The D3D bytecode is this:

vs_4_0
dcl_input v0.xy
dcl_output o0.xyzw
dcl_temps 1
eq r0.xy, v0.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000)
and r0.x, r0.y, r0.x
movc o0.xyzw, r0.xxxx, l(0,0,0,0), l(1.000000,1.000000,1.000000,1.000000)
ret 

Which gets cross-compiled to:

void main()
{
    //--- Start Early Main ---
    Input0 = dcl_Input0;
    //--- End Early Main ---
    //Instruction 0
    //EQ
    Temp_uint[0].xy = uvec2(equal(vec4(Input0.xyxx).xy, vec4(vec4(1.000000, 1.000000, 0.000000, 0.000000)).xy)) * 0xFFFFFFFFu;
    //Instruction 1
    //AND
    Temp_uint[0].x = ivec4(Temp_uint[0]).y & ivec4(Temp_uint[0]).x;
    //Instruction 2
    //MOVC
    if(vec4(Temp_uint[0].xxxx).x != 0) {
        Output0 = vec4(0.000000, 0.000000, 0.000000, 0.000000);
    } else {
        Output0 = vec4(1.000000, 1.000000, 1.000000, 1.000000);
    }
    //Instruction 3
    //RET
    return;
}

But GLSL complains that on line 11 (after the // AND comment) there is an implicit cast from int to uint.

James-Jones commented 10 years ago

Fixed