summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-08-18 13:42:46 -0400
committerGitHub <noreply@github.com>2020-08-18 13:42:46 -0400
commit9abcb6ea24dbc7184c3a2ad9f4458f63f8901928 (patch)
tree155ae80bbd15efae88b5852b7bb24804a70af405 /tests
parent697e7fbbbb5dcb448c03a9887e6ef09e328505ef (diff)
Support for float atomics on RWByteAddressBuffer (#1502)
* Fix premake5.lua so it uses the new path needed for OpenCLDebugInfo100.h * Keep including the includes directory. * Added the spirv-tools-generated files. * We don't need to include the spirv/unified1 path because the files needed are actually in the spirv-tools-generated folder. * Put the build_info.h glslang generated files in external/glslang-generated. Alter premake5.lua to pick up that header. * First pass at documenting how to build glslang and spirv-tools. * Improved glsl/spir-v tools README.md * Added revision.h * Change how gResources is calculated. Update about revision.h * Update docs a little. * Split out spirv-tools into a separate project for building glslang. This was not necessary on linux, but *is* necessary on windows, because there is a file disassemble.cpp in spirv-tools and in glslang, and this leads to VS choosing only one. With the separate library, the problem is resolved. * Fix direct-spirv-emit output. * Update to latest version of spirv headers and spirv-tools. * Upgrade submodule version of glslang in external. * Add fPIC to build options of slang-spirv-tools * WIP adding support for InterlockedAddFp32 * Upgrade slang-binaries to have new glslang. * Fix issues with Windows slang-glslang binaries, via update of slang-binaries used. * WIP - atomicAdd. This solution can't work as we can't do (float*) in glsl. * WIP on atomic float ops. * Added checking for multiple decls that takes into account __target_intrinsic and __specialized_for_target. First pass impl of atomic add on float for glsl. * Split __atomicAdd so extensions are applied appropriately. * Made Dxc/Fxc support includes. Use HLSL prelude to pass the path to nvapi Added -nv-api-path * Refactor around IncludeHandler and impl of IncludeSystem * slang-include-handler -> slang-include-system Have IncludeHandler/Impl defined in slang-preprocessor * Small comment improvements. * Document atomic float add addition in target-compatibility.md. * CUDA float atomic support on RWByteAddressBuffer. * Add atomic-float-byte-address-buffer-cross.slang * Removed inappropriate-once.slang - the test is no longer valid when a file is loaded and has a unique identity by default. A test could be made, but would require an API call to create the file (so no unique id). Improved handling of loadFile - uses uniqueId if has one. * Work around for testing target overlaps - to avoid exceptions on adding targets. Simplify PathInfo setup. Modify single-target-intrinsic.slang - it no longer failed because there were no longer multiple definitions for the same target. Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/byte-address-buffer.slang2
-rw-r--r--tests/diagnostics/single-target-intrinsic.slang3
-rw-r--r--tests/diagnostics/single-target-intrinsic.slang.expected4
-rw-r--r--tests/preprocessor/inappropriate-once.slang6
-rw-r--r--tests/preprocessor/inappropriate-once.slang.expected6
-rw-r--r--tests/slang-extension/atomic-float-byte-address-buffer-cross.slang27
-rw-r--r--tests/slang-extension/atomic-float-byte-address-buffer-cross.slang.glsl51
-rw-r--r--tests/slang-extension/atomic-float-byte-address-buffer.slang34
-rw-r--r--tests/slang-extension/atomic-float-byte-address-buffer.slang.expected.txt4
9 files changed, 122 insertions, 15 deletions
diff --git a/tests/compute/byte-address-buffer.slang b/tests/compute/byte-address-buffer.slang
index f2078b52d..96e100ae8 100644
--- a/tests/compute/byte-address-buffer.slang
+++ b/tests/compute/byte-address-buffer.slang
@@ -3,7 +3,7 @@
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
-//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-d3d12 -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute
// Confirm cross-compilation of `(RW)ByteAddressBuffer`
//
diff --git a/tests/diagnostics/single-target-intrinsic.slang b/tests/diagnostics/single-target-intrinsic.slang
index e8ff0ed1a..94e1a2bae 100644
--- a/tests/diagnostics/single-target-intrinsic.slang
+++ b/tests/diagnostics/single-target-intrinsic.slang
@@ -9,6 +9,9 @@ T doThing<T>(T in)
__target_intrinsic(hlsl, "doSomethingIntrinsically($0)")
T doThing<T>(T in);
+__target_intrinsic(hlsl, "letsRedefineIt($0)")
+T doThing<T>(T in);
+
void test()
{
int a = 5;
diff --git a/tests/diagnostics/single-target-intrinsic.slang.expected b/tests/diagnostics/single-target-intrinsic.slang.expected
index 82068f17d..544cd2d3b 100644
--- a/tests/diagnostics/single-target-intrinsic.slang.expected
+++ b/tests/diagnostics/single-target-intrinsic.slang.expected
@@ -1,7 +1,7 @@
result code = -1
standard error = {
-tests/diagnostics/single-target-intrinsic.slang(10): error 30201: function 'doThing' already has a body
-tests/diagnostics/single-target-intrinsic.slang(4): note: see previous definition of 'doThing'
+tests/diagnostics/single-target-intrinsic.slang(13): error 30201: function 'doThing' already has a body
+tests/diagnostics/single-target-intrinsic.slang(10): note: see previous definition of 'doThing'
}
standard output = {
}
diff --git a/tests/preprocessor/inappropriate-once.slang b/tests/preprocessor/inappropriate-once.slang
deleted file mode 100644
index 6b750ec77..000000000
--- a/tests/preprocessor/inappropriate-once.slang
+++ /dev/null
@@ -1,6 +0,0 @@
-//TEST:SIMPLE:
-// #include support
-
-#pragma once
-
-int foo() { return 0; } \ No newline at end of file
diff --git a/tests/preprocessor/inappropriate-once.slang.expected b/tests/preprocessor/inappropriate-once.slang.expected
deleted file mode 100644
index 04d7f7834..000000000
--- a/tests/preprocessor/inappropriate-once.slang.expected
+++ /dev/null
@@ -1,6 +0,0 @@
-result code = 0
-standard error = {
-tests/preprocessor/inappropriate-once.slang(4): warning 15602: pragma once was ignored - this is typically because is not placed in an include
-}
-standard output = {
-}
diff --git a/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang
new file mode 100644
index 000000000..e99494d5f
--- /dev/null
+++ b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang
@@ -0,0 +1,27 @@
+// atomic-float-byte-address-buffer-cross.slang
+
+//TEST:CROSS_COMPILE: -profile cs_6_5 -entry computeMain -target spirv-assembly
+// We can't do this test, because it relies on nvAPI
+//DISABLE_TEST:CROSS_COMPILE: -profile cs_6_5 -entry computeMain -target dxil
+
+//TEST_INPUT:ubuffer(data=[0.1 0.2 0.3 0.4]):out,name=outputBuffer
+RWByteAddressBuffer outputBuffer;
+
+//TEST_INPUT:ubuffer(data=[0.7 0.5 0.2 0.6]):name=anotherBuffer
+RWStructuredBuffer<float> anotherBuffer;
+
+[numthreads(16, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int idx = (tid & 3) ^ (tid >> 2);
+
+ const float delta = anotherBuffer[idx & 3];
+
+ float previousValue = 0;
+ outputBuffer.InterlockedAddFp32((idx << 2), 1.0f, previousValue);
+
+ // The sum of values in anotherBuffer should also be added
+ int anotherIdx = tid >> 2;
+ outputBuffer.InterlockedAddFp32(anotherIdx << 2, delta);
+} \ No newline at end of file
diff --git a/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang.glsl b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang.glsl
new file mode 100644
index 000000000..9fd2f18f9
--- /dev/null
+++ b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang.glsl
@@ -0,0 +1,51 @@
+#version 450
+#extension GL_EXT_shader_atomic_float : require
+layout(row_major) uniform;
+layout(row_major) buffer;
+
+#line 10 "tests/slang-extension/atomic-float-byte-address-buffer-cross.slang"
+layout(std430, binding = 1) buffer _S1 {
+ float _data[];
+} anotherBuffer_0;
+
+#line 60 "hlsl"
+layout(std430, binding = 0) buffer _S2 {
+ float _data[];
+} _S3;
+
+#line 18 "tests/slang-extension/atomic-float-byte-address-buffer-cross.slang"
+void RWByteAddressBuffer_InterlockedAddFp32_0(uint _S4, float _S5, out float _S6)
+{
+ uint _S7 = _S4 / uint(4);
+ float _S8 = (atomicAdd((((_S3)._data[(_S7)])), (_S5)));
+ _S6 = _S8;
+ return;
+}
+
+void RWByteAddressBuffer_InterlockedAddFp32_1(uint _S9, float _S10)
+{
+ uint _S11 = _S9 / uint(4);
+ float _S12 = (atomicAdd((((_S3)._data[(_S11)])), (_S10)));
+ return;
+}
+
+
+#line 13
+layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in;void main()
+{
+ uint tid_0 = gl_GlobalInvocationID.x;
+ int idx_0 = int(tid_0 & uint(3) ^ tid_0 >> 2);
+
+ float delta_0 = ((anotherBuffer_0)._data[(uint(idx_0 & 3))]);
+
+
+ uint _S13 = uint(idx_0 << 2);
+
+#line 21
+ float _S14;
+ RWByteAddressBuffer_InterlockedAddFp32_0(_S13, 1.00000000000000000000, _S14);
+ RWByteAddressBuffer_InterlockedAddFp32_1(uint(int(tid_0 >> 2) << 2), delta_0);
+
+#line 13
+ return;
+} \ No newline at end of file
diff --git a/tests/slang-extension/atomic-float-byte-address-buffer.slang b/tests/slang-extension/atomic-float-byte-address-buffer.slang
new file mode 100644
index 000000000..e6e2268ff
--- /dev/null
+++ b/tests/slang-extension/atomic-float-byte-address-buffer.slang
@@ -0,0 +1,34 @@
+// byte-address-buffer.slang
+
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+// Disabled because crashes currently on vulkan
+//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
+// Disabled because requires nvapi to work
+// Note for this feature we require dxc and we can force that with -use-dxil
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -use-dxil
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -use-dxil
+
+//TEST_INPUT:ubuffer(data=[0.1 0.2 0.3 0.4]):out,name=outputBuffer
+RWByteAddressBuffer outputBuffer;
+
+//TEST_INPUT:ubuffer(data=[0.7 0.5 0.2 0.6]):name=anotherBuffer
+RWStructuredBuffer<float> anotherBuffer;
+
+[numthreads(16, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int idx = (tid & 3) ^ (tid >> 2);
+
+ //const float delta = anotherBuffer[idx & 3];
+ const float delta = 0.0f;
+
+ float previousValue = 0;
+ outputBuffer.InterlockedAddFp32((idx << 2), 1.0f, previousValue);
+ //outputBuffer.InterlockedAddFp32((idx ^ 2) << 2, 2.0f + delta);
+
+ // The sum of values in anotherBuffer should also be added
+ //int anotherIdx = tid >> 2;
+ //outputBuffer.InterlockedAddFp32(anotherIdx << 2, delta);
+} \ No newline at end of file
diff --git a/tests/slang-extension/atomic-float-byte-address-buffer.slang.expected.txt b/tests/slang-extension/atomic-float-byte-address-buffer.slang.expected.txt
new file mode 100644
index 000000000..4affc7d87
--- /dev/null
+++ b/tests/slang-extension/atomic-float-byte-address-buffer.slang.expected.txt
@@ -0,0 +1,4 @@
+40833333
+40866666
+4089999A
+408CCCCD