diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-06-09 11:34:21 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-06-09 13:44:59 -0700 |
| commit | fcf83dbf9effab3bd98bad2b83b2468b7eb05cfd (patch) | |
| tree | 41047c94883b86ec085a81597391ce3ef557cd43 /tests/hlsl/dxsdk/BasicCompute11/BasicCompute11.hlsl | |
| parent | 52e8d4b9a27ab0060f874c3a63ab531847be35c0 (diff) | |
Initial import of code.
Diffstat (limited to 'tests/hlsl/dxsdk/BasicCompute11/BasicCompute11.hlsl')
| -rw-r--r-- | tests/hlsl/dxsdk/BasicCompute11/BasicCompute11.hlsl | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/hlsl/dxsdk/BasicCompute11/BasicCompute11.hlsl b/tests/hlsl/dxsdk/BasicCompute11/BasicCompute11.hlsl new file mode 100644 index 000000000..798eea2ff --- /dev/null +++ b/tests/hlsl/dxsdk/BasicCompute11/BasicCompute11.hlsl @@ -0,0 +1,72 @@ +//TEST_IGNORE_FILE: Currently failing due to Spire compiler issues. +//TEST:COMPARE_HLSL: -target dxbc-assembly -profile cs_4_0 -entry CSMain +//-------------------------------------------------------------------------------------- +// File: BasicCompute11.hlsl +// +// This file contains the Compute Shader to perform array A + array B +// +// Copyright (c) Microsoft Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- + +#ifdef USE_STRUCTURED_BUFFERS + +struct BufType +{ + int i; + float f; +#ifdef TEST_DOUBLE + double d; +#endif +}; + +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 ) +{ + BufferOut[DTid.x].i = Buffer0[DTid.x].i + Buffer1[DTid.x].i; + BufferOut[DTid.x].f = Buffer0[DTid.x].f + Buffer1[DTid.x].f; +#ifdef TEST_DOUBLE + BufferOut[DTid.x].d = Buffer0[DTid.x].d + Buffer1[DTid.x].d; +#endif +} + +#else // The following code is for raw buffers + +ByteAddressBuffer Buffer0 : register(t0); +ByteAddressBuffer Buffer1 : register(t1); +RWByteAddressBuffer BufferOut : register(u0); + +[numthreads(1, 1, 1)] +void CSMain( uint3 DTid : SV_DispatchThreadID ) +{ +#ifdef TEST_DOUBLE + int i0 = asint( Buffer0.Load( DTid.x*16 ) ); + float f0 = asfloat( Buffer0.Load( DTid.x*16+4 ) ); + double d0 = asdouble( Buffer0.Load( DTid.x*16+8 ), Buffer0.Load( DTid.x*16+12 ) ); + int i1 = asint( Buffer1.Load( DTid.x*16 ) ); + float f1 = asfloat( Buffer1.Load( DTid.x*16+4 ) ); + double d1 = asdouble( Buffer1.Load( DTid.x*16+8 ), Buffer1.Load( DTid.x*16+12 ) ); + + BufferOut.Store( DTid.x*16, asuint(i0 + i1) ); + BufferOut.Store( DTid.x*16+4, asuint(f0 + f1) ); + + uint dl, dh; + asuint( d0 + d1, dl, dh ); + + BufferOut.Store( DTid.x*16+8, dl ); + BufferOut.Store( DTid.x*16+12, dh ); +#else + int i0 = asint( Buffer0.Load( DTid.x*8 ) ); + float f0 = asfloat( Buffer0.Load( DTid.x*8+4 ) ); + int i1 = asint( Buffer1.Load( DTid.x*8 ) ); + float f1 = asfloat( Buffer1.Load( DTid.x*8+4 ) ); + + BufferOut.Store( DTid.x*8, asuint(i0 + i1) ); + BufferOut.Store( DTid.x*8+4, asuint(f0 + f1) ); +#endif // TEST_DOUBLE +} + +#endif // USE_STRUCTURED_BUFFERS |
