cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

RSMI
Journeyman III

Help with D3D11 cs_5_0 AsDouble & AsUint Functions?

Having just bought a new HD5850 DX11 card I've been trying some basic D3D11 programming with double precision examples.

I've hit a couple of problems when attempting to use the HLSL functions "asdouble" and "asuint" with double precision.  Would appreciate any help anyone can offer?

The code below correctly returns two unsigned 32 bit ints for hx & lx.

double x;

x = 1.43567;

asuint(x,hx,lx);

The code below incorrectly returns zeros for hx & lx.

double x;

x = 2.231143554;

asuint(x,hx,lx);

 



 



 



 



 



 



 



 



Is this a bug with the compiler?





I read cs5 is supposed to support double precision but whether asuint works correctly or not depends on the precision of the double passed into asuint.

Also ......

The code below also calls the asdouble function and results in zeros being returned in output buffer elements f & i.

    a = 10;
    b = 20;
    c = asdouble(a,b);
    BufferOut[DTid.x].f = c;
    BufferOut[DTid.x].i = 25;

The code below however works fine returning a double of 500.0 and  integer value 25 in output buffer elements f & i.

    a = 10;
    b = 20;
    c = 500.0;
    BufferOut[DTid.x].f = c;
    BufferOut[DTid.x].i = 25;

Can anyone help with a fix or alternative for creating a 64 bit double from two unsigned 32 bit ints?

 

struct BufType { int i; double f; }; StructuredBuffer<BufType> Buffer0 : register(t0); StructuredBuffer<BufType> Buffer1 : register(t1); RWStructuredBuffer<BufType> BufferOut : register(u0); [numthreads(1, 1, 1)] void CSMain( uint3 DTid : SV_DispatchThreadID ) { uint a; uint b; double c; a = 10; b = 20; c = asdouble(a,b); BufferOut[DTid.x].i = 25; BufferOut[DTid.x].f = c; }

0 Likes
0 Replies