summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-12-18 15:14:59 -0800
committerGitHub <noreply@github.com>2017-12-18 15:14:59 -0800
commit393e25fd2e2b8c5ff82ff4c6b14a9d7152d37a5e (patch)
treea3b0617e7ce5a5bfcf43454893f6c2962b7ec382 /tests
parent46b68ed41daecfaf1761e299cf040156e0f65ac0 (diff)
Work on getting rewriter + IR playing nice together. (#314)
* Work on getting rewriter + IR playing nice together. There are a few different changes here, with the goal of improving the interaction between the "rewriter" code generation approach and the new IR and type legalization code. The main changes are: - Add a new pass that occurs before the AST legalization pass, which walks the (used) AST declarations and tries to discover (1) which declarations need to be specialized/lowered via the IR, and (2) which declarations need to be included in the resulting AST module. - AST-based legalization now uses the generated list when in "rewriter" mode, so that we should be working around issues that users were seeing with types not getting emitted. - TODO: we still need an equivalent fixup in the case of non-"rewriter" emit, so this may still be a problem for `.slang` files. - IR type legalization now precedes AST legalization, so that we can record information on how any IR global values got legalized (e.g., if they got split). Then AST legalization includes logic to reconstruct suitable tuple expressions to reference a split global. - When emitting using IR + AST, we walk all of the declarations that we decided belonged to the IR, but which were subsequently referenced in the AST, to make sure they get output (this would include `struct` types that are declared in a file compiled via IR, but never used in IR-based code). The rewriter+IR use case still doesn't *quite* work, but the logic for walking the AST in a pre-pass ends up being needed/useful to fix some pure rewriter bugs, so I'm getting this checked in sooner rather than later. * Fixup: walk arguments to generic declaration reference The gotcha here is that the code for walking the AST would walk a line of code like: SomeType a; and know to traverse the declaration of `SomeType`, but if it saw a line of code like: ParameterBlock<SomeType> b; it would traverse the declaration of `ParameterBlock`, but fail to visit that of `SomeType`.
Diffstat (limited to 'tests')
-rw-r--r--tests/bindings/multiple-parameter-blocks.slang20
-rw-r--r--tests/bugs/split-nested-types.hlsl30
-rw-r--r--tests/bugs/split-nested-types.slang14
-rw-r--r--tests/compute/rewriter-parameter-block-complex.hlsl2
-rw-r--r--tests/compute/rewriter-parameter-block.hlsl2
-rw-r--r--tests/compute/rewriter-use-ir-type.hlsl24
-rw-r--r--tests/compute/rewriter-use-ir-type.hlsl.expected.txt4
-rw-r--r--tests/compute/rewriter-use-ir-type.slang6
8 files changed, 88 insertions, 14 deletions
diff --git a/tests/bindings/multiple-parameter-blocks.slang b/tests/bindings/multiple-parameter-blocks.slang
index 0a73fdcbd..5fcb9c6d5 100644
--- a/tests/bindings/multiple-parameter-blocks.slang
+++ b/tests/bindings/multiple-parameter-blocks.slang
@@ -29,20 +29,20 @@ float4 main(float v : V) : SV_Target
#else
-Texture2D _S1 : register(t0, space0);
-Texture2D _S2[4] : register(t1, space0);
-SamplerState _S3 : register(s0, space0);
+Texture2D _SV01pL0 : register(t0, space0);
+Texture2D _SV01pL1[4] : register(t1, space0);
+SamplerState _SV01pL2 : register(s0, space0);
-Texture2D _S12 : register(t0, space1);
-Texture2D _S13[4] : register(t1, space1);
-SamplerState _S14 : register(s0, space1);
+Texture2D _SV02p1L0 : register(t0, space1);
+Texture2D _SV02p1L1[4] : register(t1, space1);
+SamplerState _SV02p1L2 : register(s0, space1);
float4 main(float v : V) : SV_Target
{
- return use(_S1, _S3)
- + use(_S2[int(v)], _S3)
- + use(_S12, _S14)
- + use(_S13[int(v)], _S14);
+ return use(_SV01pL0, _SV01pL2)
+ + use(_SV01pL1[int(v)], _SV01pL2)
+ + use(_SV02p1L0, _SV02p1L2)
+ + use(_SV02p1L1[int(v)], _SV02p1L2);
}
#endif
diff --git a/tests/bugs/split-nested-types.hlsl b/tests/bugs/split-nested-types.hlsl
new file mode 100644
index 000000000..210c119df
--- /dev/null
+++ b/tests/bugs/split-nested-types.hlsl
@@ -0,0 +1,30 @@
+// array-size-static-const.hlsl
+//TEST:COMPARE_HLSL: -profile ps_5_0 -target dxbc-assembly
+
+#ifdef __SLANG__
+import split_nested_types;
+#else
+
+struct A { int x; };
+
+struct B { float y; };
+
+struct C { Texture2D t; SamplerState s; };
+
+struct M
+{
+ A a;
+ B b;
+};
+
+#endif
+
+cbuffer C
+{
+ M m;
+}
+
+float4 main() : SV_target
+{
+ return m.b.y;
+}
diff --git a/tests/bugs/split-nested-types.slang b/tests/bugs/split-nested-types.slang
new file mode 100644
index 000000000..ccf95d906
--- /dev/null
+++ b/tests/bugs/split-nested-types.slang
@@ -0,0 +1,14 @@
+//TEST_IGNORE_FILE:
+
+struct A { int x; };
+
+struct B { float y; };
+
+struct C { Texture2D t; SamplerState s; };
+
+struct M
+{
+ A a;
+ B b;
+ C c;
+};
diff --git a/tests/compute/rewriter-parameter-block-complex.hlsl b/tests/compute/rewriter-parameter-block-complex.hlsl
index 4dc312f95..fe7aae4a6 100644
--- a/tests/compute/rewriter-parameter-block-complex.hlsl
+++ b/tests/compute/rewriter-parameter-block-complex.hlsl
@@ -1,7 +1,5 @@
//TEST(compute):HLSL_COMPUTE:-xslang -no-checking
//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
-
-// Doesn't work with IR yet.
//DISABLED_TEST(compute):HLSL_COMPUTE:-xslang -no-checking -xslang -use-ir
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
diff --git a/tests/compute/rewriter-parameter-block.hlsl b/tests/compute/rewriter-parameter-block.hlsl
index 0cc06cc10..9d3140475 100644
--- a/tests/compute/rewriter-parameter-block.hlsl
+++ b/tests/compute/rewriter-parameter-block.hlsl
@@ -1,7 +1,5 @@
//TEST(compute):HLSL_COMPUTE:-xslang -no-checking
//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
-
-// Doesn't work with rewriter + IR yet.
//DISABLED_TEST(compute):HLSL_COMPUTE:-xslang -no-checking -xslang -use-ir
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
diff --git a/tests/compute/rewriter-use-ir-type.hlsl b/tests/compute/rewriter-use-ir-type.hlsl
new file mode 100644
index 000000000..8d388addf
--- /dev/null
+++ b/tests/compute/rewriter-use-ir-type.hlsl
@@ -0,0 +1,24 @@
+//TEST(compute):HLSL_COMPUTE:-xslang -no-checking -xslang -use-ir
+
+//TEST_INPUT:cbuffer(data=[1 2 3 4 16 32 48 64]):dxbinding(0),glbinding(0)
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+
+import rewriter_use_ir_type;
+
+RWStructuredBuffer<int> outputBuffer : register(u0);
+
+cbuffer C : register(b0)
+{
+ Helper helper;
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int inVal = tid;
+
+ int outVal = helper.a[inVal];
+
+ outputBuffer[tid] = outVal;
+} \ No newline at end of file
diff --git a/tests/compute/rewriter-use-ir-type.hlsl.expected.txt b/tests/compute/rewriter-use-ir-type.hlsl.expected.txt
new file mode 100644
index 000000000..94ebaf900
--- /dev/null
+++ b/tests/compute/rewriter-use-ir-type.hlsl.expected.txt
@@ -0,0 +1,4 @@
+1
+2
+3
+4
diff --git a/tests/compute/rewriter-use-ir-type.slang b/tests/compute/rewriter-use-ir-type.slang
new file mode 100644
index 000000000..8870f000f
--- /dev/null
+++ b/tests/compute/rewriter-use-ir-type.slang
@@ -0,0 +1,6 @@
+//TEST_IGNORE_FILE:
+
+struct Helper
+{
+ int4 a;
+}; \ No newline at end of file