summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-05-15 11:45:58 -0400
committerGitHub <noreply@github.com>2021-05-15 11:45:58 -0400
commitd5e8044d0a9723bb0bbd7ae1738d1157265da783 (patch)
treed330e87e67646fd6e978e4debad17b4f7fbe2c40 /tests
parentbfe75618be81566882be8570b8db82ad5a2f8fe4 (diff)
Read half->float RWTexture conversion (#1842)
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix for writing to RWTexture with half types on CUDA. * CUDA half functionality doc updates. * First pass support for sust.p RWTexture format conversion on write. * Tidy up implementation of $C. Made clamping mode #define able. * A simple test for RWTexture CUDA format conversion. * Add support for float2 and float4. * WIP conversion testing. * Use $E to fix byte addressing in X in CUDA. * Do not scale when accessing via _convert versions of surface functions. * Revert to previous test. * Test with half/float convert write/read. * More broad half->float read conversion testing. * Improve documentation around half and RWTexture conversion.
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/half-rw-texture-convert.slang14
-rw-r--r--tests/compute/half-rw-texture-convert2.slang53
-rw-r--r--tests/compute/half-rw-texture-convert2.slang.expected.txt5
3 files changed, 71 insertions, 1 deletions
diff --git a/tests/compute/half-rw-texture-convert.slang b/tests/compute/half-rw-texture-convert.slang
index cf6eea4ea..338f44454 100644
--- a/tests/compute/half-rw-texture-convert.slang
+++ b/tests/compute/half-rw-texture-convert.slang
@@ -25,6 +25,14 @@
[format("r16f")]
RWTexture2D<float> rwt2D;
+//TEST_INPUT: RWTexture2D(format=RG_Float16, size=4, content = one, mipMaps = 1):name rwt2D_2
+[format("rg16f")]
+RWTexture2D<float2> rwt2D_2;
+
+//TEST_INPUT: RWTexture2D(format=RGBA_Float16, size=4, content = one, mipMaps = 1):name rwt2D_4
+[format("rgba16f")]
+RWTexture2D<float4> rwt2D_4;
+
//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<float> outputBuffer;
@@ -38,5 +46,9 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
// Do a format converting write!
rwt2D[uint2(idx, idx)] = val;
+ rwt2D_2[uint2(idx, idx)] = float2(val * 2, val * 3);
+
+ rwt2D_4[uint2(idx, idx)] = float4(val + 1, val - 1, val * 4, val * -4);
+
outputBuffer[idx] = val;
-}
+} \ No newline at end of file
diff --git a/tests/compute/half-rw-texture-convert2.slang b/tests/compute/half-rw-texture-convert2.slang
new file mode 100644
index 000000000..e9b7200c4
--- /dev/null
+++ b/tests/compute/half-rw-texture-convert2.slang
@@ -0,0 +1,53 @@
+// Native half not supported on CPU currently
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj
+// Doesn't work on DX11 currently - locks up on binding
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -shaderobj
+// Produces a different result on DX12 with DXBC than expected(!). So disabled for now
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type -shaderobj
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -use-dxil -output-using-type -shaderobj
+// TODO(JS): Doesn't work on vk currently, because createTextureView not implemented on vk renderer
+//DIABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj
+
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj -render-features half
+
+//TEST_INPUT: RWTexture2D(format=R_Float16, size=4, content = one, mipMaps = 1):name rwt2D
+[format("r16f")]
+RWTexture2D<float> rwt2D;
+
+//TEST_INPUT: RWTexture2D(format=RG_Float16, size=4, content = one, mipMaps = 1):name rwt2D_2
+[format("rg16f")]
+RWTexture2D<float2> rwt2D_2;
+
+//TEST_INPUT: RWTexture2D(format=RGBA_Float16, size=4, content = one, mipMaps = 1):name rwt2D_4
+[format("rgba16f")]
+RWTexture2D<float4> rwt2D_4;
+
+//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = dispatchThreadID.x;
+
+ float val = 0;
+
+ // Do a format converting write2!
+ rwt2D[uint2(idx, idx)] = idx - 1;
+ rwt2D_2[uint2(idx, idx)] = float2(idx + idx, idx * idx);
+ rwt2D_4[uint2(idx, idx)] = float4(idx + 97, idx + 8, idx + 16, idx + 24);
+
+ // May not be strictly necessary
+ AllMemoryBarrierWithGroupSync();
+
+ // Do read converting
+ // There is *only* CUDA support for half/float *converting* reads for 1d, 2d, 3d shapes for RWTexture/surface
+
+ float4 v4 = rwt2D_4[uint2(idx, idx)];
+ float2 v2 = rwt2D_2[uint2(idx, idx)];
+ float v = rwt2D[uint2(idx, idx)];
+
+ val += v4.x + v2.x + v;
+
+ outputBuffer[idx] = val;
+}
diff --git a/tests/compute/half-rw-texture-convert2.slang.expected.txt b/tests/compute/half-rw-texture-convert2.slang.expected.txt
new file mode 100644
index 000000000..462941fda
--- /dev/null
+++ b/tests/compute/half-rw-texture-convert2.slang.expected.txt
@@ -0,0 +1,5 @@
+type: float
+96.000000
+100.000000
+104.000000
+108.000000