Reputation: 3669
When compiling this simple pixel shader:
Texture2D tex0 : register(t0);
Texture2D tex1 : register(t1);
SamplerState s : register(s0);
float4 main(float2 tc : TEXCOORD0) : SV_TARGET
{
Texture2D tex = tex0;
if (tc.x > 0.5)
{
tex = tex1;
}
return tex.SampleLevel(s, tc, 0);
}
Using the command line fxc.exe /T ps_4_0 hello.hlsl
I get:
Microsoft (R) Direct3D Shader Compiler 10.1 (using C:\Windows Kits\10\bin\10.0.17763.0\x86\D3DCOMPILER_47.dll)
Copyright (C) 2013 Microsoft. All rights reserved.
error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Invalid operand type for operand #3 of opcode #8 (counts are 1-based).
error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Can't continue validation - aborting.
What am I doing wrong?
Upvotes: 0
Views: 2679
Reputation: 41067
The internal compiler error is not a helpful error here, but the pattern you used above is just not something most people write. The same shader works if you write it as:
Texture2D tex0 : register(t0);
Texture2D tex1 : register(t1);
SamplerState s : register(s0);
float4 main(float2 tc : TEXCOORD0) : SV_TARGET
{
if (tc.x > 0.5)
{
return tex1.SampleLevel(s, tc, 0);
}
else
{
return tex0.SampleLevel(s, tc, 0);
}
}
Note that the DXIL compiler for Shader Model 6 returns a more sensible error in this case:
error: local resource not guaranteed to map to unique global resource. Use /Zi for source location.
Upvotes: 2