summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-11-13 14:17:09 -0800
committerGitHub <noreply@github.com>2017-11-13 14:17:09 -0800
commitc9d94248dc73fe41c344b0a23230e597f7b94a2c (patch)
tree07330bef7fc8685f5615212de33250bb32adc918 /tests
parentc9368fe3ec8f8d8bc58947ddb1b5fd2caa4bd70a (diff)
Parameter block work (#276)
* Don't auto-enable IR use for compute tests The `COMPARE_COMPUTE` and `COMPARE_RENDER_COMPUTE` test fixtures were set up to always enable the `-use-ir` flag on Slang, which precludes having any tests that confirm functionality on the old non-IR path (which is still required by our main customer). This change adds the `-xslang -use-ir` flags explicitly to any compute test cases that left them out, and makes the fixture no longer add it by default. * Continue building out parameter block support The initial front-end logic for parameter blocks was already added, but they are still missing a bunch of functionality. This change addresses some of the known issues: - Bug fix: don't try to emit HLSL `register` bindings for variables that consume whole register spaces/sets - Overhaul type layout logic so that it can make decisions based on a given code generation target (currently passed in as a `TargetRequest`), which allows us to decide whether or not a parameter block should get its own register set on a per-target basis. - Always use a register space/set for Vulkan - Never use a register space/set for HLSL SM 5.0 and lower - By default, don't use register spaces/sets for HLSL output - Add a command-line flag and some "target flags" to enable register-space usage for D3D targets - Hackily add initial support for parameter blocks in the AST-to-AST path - This just blindly lowers `ParameterBlock<T>` to `T`, which shouldn't quite work - A more complete overhaul will probably need to wait until the AST-to-AST legalization is changed to use the `LegalType`s from the IR legalization pass. - Add a compute-based test case to actually run code using parameter blocks - This file runs test cases both with and without the IR
Diffstat (limited to 'tests')
-rw-r--r--tests/bindings/multiple-parameter-blocks.slang2
-rw-r--r--tests/bindings/parameter-blocks.slang2
-rw-r--r--tests/compute/break-stmt.slang2
-rw-r--r--tests/compute/continue-stmt.slang2
-rw-r--r--tests/compute/discard-stmt.slang2
-rw-r--r--tests/compute/parameter-block.slang28
-rw-r--r--tests/compute/parameter-block.slang.1.expected.txt4
-rw-r--r--tests/compute/parameter-block.slang.expected.txt4
-rw-r--r--tests/compute/select-expr.slang2
-rw-r--r--tests/compute/simple.slang2
-rw-r--r--tests/compute/textureSamplingTest.slang2
11 files changed, 44 insertions, 8 deletions
diff --git a/tests/bindings/multiple-parameter-blocks.slang b/tests/bindings/multiple-parameter-blocks.slang
index 0fdf7d429..093d2ea43 100644
--- a/tests/bindings/multiple-parameter-blocks.slang
+++ b/tests/bindings/multiple-parameter-blocks.slang
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -use-ir -target dxbc-assembly -profile ps_5_1 -entry main
+//TEST:COMPARE_HLSL:-no-mangle -use-ir -target dxbc-assembly -profile ps_5_1 -entry main -parameter-blocks-use-register-spaces
// Confirm that Slang `ParameterBlock<T>` generates
// parameter bindings like we expect.
diff --git a/tests/bindings/parameter-blocks.slang b/tests/bindings/parameter-blocks.slang
index cd916f144..38f99d105 100644
--- a/tests/bindings/parameter-blocks.slang
+++ b/tests/bindings/parameter-blocks.slang
@@ -1,4 +1,4 @@
-//TEST:COMPARE_HLSL:-no-mangle -use-ir -target dxbc-assembly -profile ps_5_1 -entry main
+//TEST:COMPARE_HLSL:-no-mangle -use-ir -target dxbc-assembly -profile ps_5_1 -entry main -parameter-blocks-use-register-spaces
// Confirm that Slang `ParameterBlock<T>` generates
// parameter bindings like we expect.
diff --git a/tests/compute/break-stmt.slang b/tests/compute/break-stmt.slang
index 02f5f9fa9..3f438da54 100644
--- a/tests/compute/break-stmt.slang
+++ b/tests/compute/break-stmt.slang
@@ -1,4 +1,4 @@
-//TEST(compute):COMPARE_COMPUTE:
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):dxbinding(0),glbinding(0),out
// Test that `break` from a loop works.
diff --git a/tests/compute/continue-stmt.slang b/tests/compute/continue-stmt.slang
index 9adb5a4a6..800511290 100644
--- a/tests/compute/continue-stmt.slang
+++ b/tests/compute/continue-stmt.slang
@@ -1,4 +1,4 @@
-//TEST(compute):COMPARE_COMPUTE:
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):dxbinding(0),glbinding(0),out
// Test that `break` from a loop works.
diff --git a/tests/compute/discard-stmt.slang b/tests/compute/discard-stmt.slang
index 18ffc39e2..5f861ed96 100644
--- a/tests/compute/discard-stmt.slang
+++ b/tests/compute/discard-stmt.slang
@@ -1,4 +1,4 @@
-//TEST(compute):COMPARE_RENDER_COMPUTE:
+//TEST(compute):COMPARE_RENDER_COMPUTE:-xslang -use-ir
//TEST_INPUT: Texture2D(size=4, content = one) : dxbinding(0),glbinding(0)
//TEST_INPUT: Sampler : dxbinding(0),glbinding(0)
//TEST_INPUT: ubuffer(data=[0 0], stride=4):dxbinding(1),glbinding(0),out
diff --git a/tests/compute/parameter-block.slang b/tests/compute/parameter-block.slang
new file mode 100644
index 000000000..d10a1e9c2
--- /dev/null
+++ b/tests/compute/parameter-block.slang
@@ -0,0 +1,28 @@
+//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST(compute):COMPARE_COMPUTE:
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):dxbinding(1),glbinding(1)
+
+// Ensure that Slang `ParameterBlock` type is lowered
+// to HLSL in the fashion that we expect.
+
+struct P
+{
+ RWStructuredBuffer<int> buffer;
+};
+
+ParameterBlock<P> block0;
+ParameterBlock<P> block1;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ int inVal = block1.buffer[tid];
+
+ int outVal = inVal;
+
+ block0.buffer[tid] = outVal;
+} \ No newline at end of file
diff --git a/tests/compute/parameter-block.slang.1.expected.txt b/tests/compute/parameter-block.slang.1.expected.txt
new file mode 100644
index 000000000..bc856dafa
--- /dev/null
+++ b/tests/compute/parameter-block.slang.1.expected.txt
@@ -0,0 +1,4 @@
+0
+1
+2
+3
diff --git a/tests/compute/parameter-block.slang.expected.txt b/tests/compute/parameter-block.slang.expected.txt
new file mode 100644
index 000000000..bc856dafa
--- /dev/null
+++ b/tests/compute/parameter-block.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+1
+2
+3
diff --git a/tests/compute/select-expr.slang b/tests/compute/select-expr.slang
index d90708ab9..4d9abfd35 100644
--- a/tests/compute/select-expr.slang
+++ b/tests/compute/select-expr.slang
@@ -1,4 +1,4 @@
-//TEST(smoke,compute):COMPARE_COMPUTE:
+//TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
diff --git a/tests/compute/simple.slang b/tests/compute/simple.slang
index 8f53a79b2..b2f1417cf 100644
--- a/tests/compute/simple.slang
+++ b/tests/compute/simple.slang
@@ -1,4 +1,4 @@
-//TEST(smoke,compute):COMPARE_COMPUTE:
+//TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
// This is a basic test for Slang compute shader.
diff --git a/tests/compute/textureSamplingTest.slang b/tests/compute/textureSamplingTest.slang
index 1aa267b89..b1255f6c5 100644
--- a/tests/compute/textureSamplingTest.slang
+++ b/tests/compute/textureSamplingTest.slang
@@ -1,4 +1,4 @@
-//TEST(compute):COMPARE_RENDER_COMPUTE:
+//TEST(compute):COMPARE_RENDER_COMPUTE:-xslang -use-ir
//TEST_INPUT: Texture1D(size=4, content = one) : dxbinding(0),glbinding(0)
//TEST_INPUT: Texture2D(size=4, content = one) : dxbinding(1),glbinding(1)
//TEST_INPUT: Texture3D(size=4, content = one) : dxbinding(2),glbinding(2)