summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-05-15 10:52:55 -0400
committerGitHub <noreply@github.com>2021-05-15 10:52:55 -0400
commit1027225ac7ec8da0e471b633f358333c8a95b010 (patch)
tree39575cd03fed47dffb56d7ca0ec7eff3385d1407 /tests
parent1856b8ad85266ed66985b42bd2321a35f8573a00 (diff)
Support for HW format conversions for RWTexture on CUDA (#1840)
* #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.
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/half-rw-texture-convert.slang42
-rw-r--r--tests/compute/half-rw-texture-convert.slang.expected.txt5
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/compute/half-rw-texture-convert.slang b/tests/compute/half-rw-texture-convert.slang
new file mode 100644
index 000000000..cf6eea4ea
--- /dev/null
+++ b/tests/compute/half-rw-texture-convert.slang
@@ -0,0 +1,42 @@
+
+
+// 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
+
+// Note that this test is a little silly. The output does not confirm that the write actually worked.
+// This is because it's not trivial on CUDA to do so. If there is a write conversion, the RWTexture
+// is backed by a surface. There is a texture converting write (in sust.p) but not in reading.
+//
+// In practice if if you wanted a texture read, you'd either only be able to read *without* format
+// conversion, or via a separate binding of the same surface as a Texture.
+// There's no simple way to describe either, so this test just confirms it outputs PTX that can
+// be executed, and unfortunately doesn't test if the write conversion actually *worked*
+
+//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: 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 = idx;
+
+ // Do a format converting write!
+ rwt2D[uint2(idx, idx)] = val;
+
+ outputBuffer[idx] = val;
+}
diff --git a/tests/compute/half-rw-texture-convert.slang.expected.txt b/tests/compute/half-rw-texture-convert.slang.expected.txt
new file mode 100644
index 000000000..8867afc5a
--- /dev/null
+++ b/tests/compute/half-rw-texture-convert.slang.expected.txt
@@ -0,0 +1,5 @@
+type: float
+0.000000
+1.000000
+2.000000
+3.000000