Shader
// dxc.exe /Emain /Tps_5_0 /Zi /Zpr /O3 shader.hlsl
cbuffer cb
{
int cb_a;
int cb_b;
bool cb_c[1];
}
static const struct
{
int a;
int b;
bool c[1];
} cbstruct = { cb_a, cb_b, cb_c };
bool IsPos( float3 pos )
{
float maxpos = max(pos.x, max(pos.y, pos.z) );
float minpos = min(pos.x, min(pos.y, pos.z) );
return ( maxpos < 32 && minpos > 0 );
}
float3 GetPos()
{
[branch]
if(cbstruct.c[cbstruct.b])
{
return float3(0,0,0);
}
else
{
return float3(1,1,1);
}
}
int GetIdx( )
{
for( int i=0; i< 4 ; i++ )
{
if( i == cbstruct.b )
{
return -1;
}
float3 pos = GetPos();
if( IsPos(pos) )
{
return i;
}
}
return -1;
}
float GetColor()
{
int idx = GetIdx();
if( idx == cbstruct.a )
{
return 1.0;
}
return 0.0;
}
void main(out float4 OutColor : SV_Target0)
{
float x = GetColor();
[branch]
if ( x < 0.0001f )
{
OutColor = 0.0f;
}
}
Issue: Generated dxil has phi on struct type. PHI on struct type is not a valid dxil. Apart from fixing this bug, we would also likely need to update the validator to fail the validation in case such as these.
%.lcssa = phi %dx.types.CBufRet.i32 [ %0, %"\01?GetPos@@YA?AV?$vector@M$02@@XZ.exit.i.i" ], [ %0, %for.body.i.i ], [ %6, %for.inc.i.i ], [ %6, %"\01?GetPos@@YA?AV?$vector@M$02@@XZ.exit.i.i.1" ], [ %13, %for.inc.i.i.1 ], [ %13, %"\01?GetPos@@YA?AV?$vector@M$02@@XZ.exit.i.i.2" ], [ %19, %for.inc.i.i.2 ], [ %19, %"\01?GetPos@@YA?AV?$vector@M$02@@XZ.exit.i.i.3" ], [ %19, %for.inc.i.i.3 ]
Shader
Issue: Generated dxil has phi on struct type. PHI on struct type is not a valid dxil. Apart from fixing this bug, we would also likely need to update the validator to fail the validation in case such as these.
%.lcssa = phi %dx.types.CBufRet.i32 [ %0, %"\01?GetPos@@YA?AV?$vector@M$02@@XZ.exit.i.i" ], [ %0, %for.body.i.i ], [ %6, %for.inc.i.i ], [ %6, %"\01?GetPos@@YA?AV?$vector@M$02@@XZ.exit.i.i.1" ], [ %13, %for.inc.i.i.1 ], [ %13, %"\01?GetPos@@YA?AV?$vector@M$02@@XZ.exit.i.i.2" ], [ %19, %for.inc.i.i.2 ], [ %19, %"\01?GetPos@@YA?AV?$vector@M$02@@XZ.exit.i.i.3" ], [ %19, %for.inc.i.i.3 ]