HLSL compiler bug

Posted By: Hummel

HLSL compiler bug - 02/27/11 00:03

Hi,

found a strange bug which doesnt occur when I precompile my shader using the fxc.exe from the DX SDK. The following expression should never become true but it actually does:
(x>=1) != (x>1 || x==1)

Just make simple pp effect using COL as output with these lines:
Code:
float bla2=frac(Tex.x*32);
COL=floor(bla2*32)/31.f;

COL=((COL.r>=1) != (COL.r>1 || COL.r==1));



YouŽll get white vertical stripes over the screen.
Compiled with fxc the screen stays black as expected.

V8.10.1

Regards

PS: Besides, when compiling complex shaders with big loops the fxc compiler is much faster. Why?
Posted By: jcl

Re: HLSL compiler bug - 02/28/11 08:42

Better never compare nonzero floating point variables with "==". As you see, some compilers just don't like this. And we're not going to fix the compiler.

But it's interesting. Which DirectX SDK version were you using for the external compiler?
Posted By: Hummel

Re: HLSL compiler bug - 03/02/11 20:55

Must have been a quite old one but actually I dont know the exact SDK version the exe is coming from. The fxc.exe file version is 9.26.952.2844.
Posted By: jcl

Re: HLSL compiler bug - 03/03/11 11:06

This could explain the different behavior. The engine uses the August 2009 SDK. I don't know if shader compiling with a different version causes a problem, but better use the August 2009 fxc.exe to get consistent behavior. Or compile fxo files with the engine - fxc.exe won't work for library shaders anyway.
© 2024 lite-C Forums