Report bugs on the Integers on HLSL of Direct3D 11

# Report bugs on the Integers on HLSL of Direct3D 11

• Thursday, May 17, 2012 1:13 PM

On HLSL of Direct3D 11, there are Bugs on conversion to 'uint', and on comparisons between 'uint'.

To avoid the problems on our program, test our code detail by detail.

Example 1:

void PSMain(in VS_OUTPUT Input, out PS_OUTPUT Output)
{
Output.Color.rgba = float4(1,1,1,1);
uint x = uint(Input.AbsolutePosition.x);

if(x > 0)
Output.Color.rgb = float3(1,0,0);

// Normally, the left and right areas should be red because x is unsigned,
// but it's not the case due to the Bugs.
}

Example 2:

void PSMain(in VS_OUTPUT Input, out PS_OUTPUT Output)
{
Output.Color.rgba = float4(1,1,1,1);

uint x = uint(Input.AbsolutePosition.x);
uint y = uint(Input.AbsolutePosition.y);

uint k = x ^ y;
if(k == 0)

Output.Color.rgb = float3(1,0,0);

// On ((signed int)x > 0 && (signed int)y > 0), there is no problem.

// But on the negative left-bottom area, all are red that is to say there are Bugs.

}

Example 3:

uint x = uint(Input.AbsolutePosition.x);
uint y = uint(Input.AbsolutePosition.y);

uint k = x ^ y;
if(k == 0)        [...]

and

uint x = uint(Input.AbsolutePosition.x);
uint y = uint(Input.AbsolutePosition.y);

if(x ^ y == 0)        [...]

do not have the same result; the second is worst.

Please report those issues to Microsoft in order to improve our future Direct3D. That’s essentially.

If you are interested, answer me to approve me and to confirm me that the report is sent before outing of the next version of Direct3D.

Manda.

### All Replies

• Thursday, May 17, 2012 2:18 PM
Owner

Hi manda_water

Sorry, this is not an HLSL forum.

Please post to the DirectX forum to reach that team with your question:
http://www.bing.com/search?q=directx+forum

Cheers
Daniel

http://www.danielmoth.com/Blog/

• Wednesday, May 23, 2012 1:08 AM

I don't think there is a bug here in HLSL.  You have two problems in your code or understanding of HLSL.

1. In Examples 1 and 2: It doesn't appear that you understand what uint() does.  This triggers an ftou (float to uint) conversion, where negative numbers will be clamped to zero.  I think you might be thinking of asuint(), which is the reinterpret cast for uint, but it is a little hard to tell exactly what you're expecting from your code and comments.

2. In Example 3: Operator precedence is tripping you up.  The XOR operator "^" has a lower precedence than "==", therefore it will be performed as if you wrote:
if( x ^ (y == 0) )

That's why the behavior is different between the two cases.

-Tex

Tex Riddell, DirectX Graphics

• Proposed As Answer by Wednesday, May 23, 2012 1:10 AM
•