none
D3DCompiler bug with a simple shader (error X8000: D3D11 Internal Compiler Error...) RRS feed

  • Question

  • Hi!

    I'm not sure if I'm reporting the problem at the appropriate place.

    I have a generated HLSL source for a pixel shader that doesn't compile with d3dcompiler_47 (using the one from Win10 1809) if code optimization is enabled.

    I managed to simplify the shader code enough and it still causes error

    error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: source register relative index temp register component 0 in r0 uninitialized. Opcode #12 (count is 1-based)

    when I try to compile it for target ps_4_0 (or other targets like ps_4_1, ps_5_0).
    The code contains a simple if/else block and that seems to cause a problem for the compiler code optimizer. When I replace that with its ternal condition expression equivalent then no problem arises.

    The shader in question is the following (I cannot workaround it, because as I said, it's a generated one):

    buffer cb : register (b4) {
     uint4  vMap[10];
     int4 b[16];
     float4 c[224];
    };
    
    struct INPUT {
     float4 v0:   COLOR0;
     float4 v1:   COLOR1;
     float4 v2:   COLOR2;
    };
    
    static struct OUTPUT {
     float4 color:  SV_TARGET0;
    } o;
    
    static float4 r0;
    static float4 xv[3];
    
    OUTPUT main (in INPUT i) {
    
     xv[0] = i.v0; xv[1] = i.v1; xv[2] = i.v2;
     r0 = 0;
     //r0.r = b[0].x ? (c[4].r + (-xv[vMap[1].x].r)).r : (c[4].a + xv[vMap[1].x].r).r;
     if (b[0].x != 0) {
    
      r0.r = (c[4].r + (-xv[vMap[1].x].r)).r;
     
     } else {
      
      r0.r = (c[4].a + xv[vMap[1].x].r).r;
     }
     
     o.color = r0;
     return o;
    }





    • Edited by Diosg Thursday, January 31, 2019 4:11 PM
    Thursday, January 31, 2019 4:10 PM