summaryrefslogtreecommitdiffstats
path: root/tests/compute
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-03-21 06:38:47 -0400
committerGitHub <noreply@github.com>2020-03-21 10:38:47 +0000
commit05c9a5c9dc23a716c7cbeae91f581bbc13f10ed2 (patch)
tree02d1f2a5ad0e59904efa2751e30ada81fda86ea0 /tests/compute
parent884a9bcafc5fb9ae47245fa3ea9a6e64cb65a482 (diff)
CPU Texture GetDimensions support (#1283)
* Added CPU support for GetDimensions on C++/CPU target. Added texture-get-dimension.slang test * Fix some typos. * Update CUDA docs. * Fix output of GetDimensions on glsl when has an array. Disabled VK - because VK renderer doesn't support createTextureView * Fix typo. * Fix typo. * Fix bad-operator-call diagnostics output.
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/texture-get-dimensions.slang106
-rw-r--r--tests/compute/texture-get-dimensions.slang.expected.txt8
2 files changed, 114 insertions, 0 deletions
diff --git a/tests/compute/texture-get-dimensions.slang b/tests/compute/texture-get-dimensions.slang
new file mode 100644
index 000000000..67c1fddc8
--- /dev/null
+++ b/tests/compute/texture-get-dimensions.slang
@@ -0,0 +1,106 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -use-dxil
+// TODO(JS): Doesn't work on vk currently, because createTextureView not implemented on vk renderer
+//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
+// TODO(JS): Doesn't work on CUDA as there aren't any CUDA functions to get dimensions.
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute
+
+//TEST_INPUT: Texture1D(size=4, content = one):name t1D
+Texture1D<float> t1D;
+//TEST_INPUT: Texture2D(size=8, content = one):name t2D
+Texture2D<float> t2D;
+//TEST_INPUT: Texture3D(size=2, content = one):name t3D
+Texture3D<float> t3D;
+//TEST_INPUT: TextureCube(size=16, content = one):name tCube
+TextureCube<float> tCube;
+
+//TEST_INPUT: Texture1D(size=2, content = one, arrayLength=2):name t1DArray
+Texture1DArray<float> t1DArray;
+//TEST_INPUT: Texture2D(size=4, content = one, arrayLength=3):name t2DArray
+Texture2DArray<float> t2DArray;
+//TEST_INPUT: TextureCube(size=16, content = one, arrayLength=1):name tCubeArray
+TextureCubeArray<float> tCubeArray;
+
+//TEST_INPUT: Sampler:name samplerState
+SamplerState samplerState;
+
+//TEST_INPUT: ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(8, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = dispatchThreadID.x;
+
+ uint mipWidth = 0;
+ uint mipHeight = 0;
+ uint mipDepth = 0;
+ uint mipCount = 1;
+ uint elementCount = 0;
+
+ uint width = 0;
+ uint height = 0;
+ uint depth = 0;
+
+ switch (idx)
+ {
+ case 0:
+ {
+ t1D.GetDimensions(width);
+ t1D.GetDimensions(0, mipWidth, mipCount);
+ break;
+ }
+ case 1:
+ {
+ t2D.GetDimensions(width, height);
+ t2D.GetDimensions(0, mipWidth, mipHeight, mipCount);
+ break;
+ }
+ case 2:
+ {
+ t3D.GetDimensions(width, height, depth);
+ t3D.GetDimensions(0, mipWidth, mipHeight, mipDepth, mipCount);
+ break;
+ }
+ case 3:
+ {
+ tCube.GetDimensions(width, height);
+ tCube.GetDimensions(0, mipWidth, mipHeight, mipCount);
+ break;
+ }
+ case 4:
+ {
+ t1DArray.GetDimensions(width, elementCount);
+ t1DArray.GetDimensions(0, mipWidth, elementCount, mipCount);
+ break;
+ }
+ case 5:
+ {
+ t2DArray.GetDimensions(width, height, elementCount);
+ t2DArray.GetDimensions(0, mipWidth, mipHeight, elementCount, mipCount);
+ break;
+ }
+ case 6:
+ {
+ tCubeArray.GetDimensions(width, height, elementCount);
+ tCubeArray.GetDimensions(0, mipWidth, mipHeight, elementCount, mipCount);
+ break;
+ }
+ }
+
+ width = (mipWidth != width) ? ~0 : width;
+ height = (mipHeight != height) ? ~0 : height;
+ depth = (mipDepth != depth) ? ~0 : depth;
+
+ // Only depth or element count can be set
+ if (depth == 0 && elementCount > 0)
+ {
+ depth = elementCount;
+ }
+
+ uint val = ((0xff & width) << 24) | ((0xff & height) << 16) | ((0xff & depth) << 8) | (mipCount);
+
+ outputBuffer[idx] = val;
+}
diff --git a/tests/compute/texture-get-dimensions.slang.expected.txt b/tests/compute/texture-get-dimensions.slang.expected.txt
new file mode 100644
index 000000000..3b060b4ae
--- /dev/null
+++ b/tests/compute/texture-get-dimensions.slang.expected.txt
@@ -0,0 +1,8 @@
+4C800000
+4D008000
+4C008080
+4D808000
+4C000080
+4C808060
+4D808008
+3F800000