Skip to content

Instantly share code, notes, and snippets.

@iondune
Created May 16, 2019 14:10
Show Gist options
  • Save iondune/d49287c2973c596d0f9b996bc38f09f3 to your computer and use it in GitHub Desktop.
Save iondune/d49287c2973c596d0f9b996bc38f09f3 to your computer and use it in GitHub Desktop.
Short HLSL shader that causes an internal compiler error
int solve(float x)
{
if (x < 0)
{
return 0;
}
// 1>MinRepo.hlsl(7,2): warning X4000: use of potentially uninitialized variable (solve)
// 1>error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Negate modifier not allowed for operand #4 of opcode #6 (counts are 1-based).
return 1;
}
int problem(float a)
{
int num = 0;
float b = (a < 0.0 ? -a : a);
num += solve(b);
b = (a < 0.0 ? a : -a);
num += solve(b);
return num;
}
float3 pixel(float value : TEXCOORD0) : SV_Target0
{
float3 output = float3(0.0, 0.0, 0.0);
int count = problem(value);
if (count > 0)
{
output = float3(1, 0, 1);
}
else
{
output = float3(0, 0, 0);
}
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment