summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-08-17 10:58:11 -0700
committerGitHub <noreply@github.com>2017-08-17 10:58:11 -0700
commit5230ad2edb28e176d0d7d2a9873ffb8f65285269 (patch)
treed1b85e1553b0a81d2322f043d3e4022bd9d780c1 /tests
parent3dd88c2eb5cd2e405cd5aa184a2cd45db6fb027a (diff)
parentd13bd05164c6a3d0b7ba95bb415f6bfac4cfcb70 (diff)
Merge pull request #168 from tfoleyNV/resources-in-structs-control
Add a flag to control type splitting
Diffstat (limited to 'tests')
-rw-r--r--tests/rewriter/type-splitting.hlsl59
-rw-r--r--tests/rewriter/type-splitting.slang3
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/rewriter/type-splitting.hlsl b/tests/rewriter/type-splitting.hlsl
new file mode 100644
index 000000000..c8d69f5fd
--- /dev/null
+++ b/tests/rewriter/type-splitting.hlsl
@@ -0,0 +1,59 @@
+//TEST:COMPARE_HLSL: -split-mixed-types -no-checking -target dxbc-assembly -profile ps_4_0 -entry main
+
+// Confirm that the `-split-mixed-types` flag works.
+
+#ifdef __SLANG__
+
+// HLSL input:
+//
+// - Uses at least one `import` of Slang code
+// - Uses an aggregate type that mixes resource and non-resource types
+//
+
+__import type_splitting;
+
+struct Foo
+{
+ Texture2D t;
+ SamplerState s;
+ float2 u;
+};
+
+cbuffer C
+{
+ Foo foo;
+}
+
+float4 main() : SV_Target
+{
+ return foo.t.Sample(foo.s, foo.u);
+}
+
+#else
+
+// Equivalent raw HLSL:
+//
+// - Fields of resource type have been stripped from original type definition
+// - Fields of resource type get hoisted out of variable declarations
+//
+
+struct Foo
+{
+ float2 u;
+};
+
+cbuffer C
+{
+ Foo foo;
+}
+
+Texture2D SLANG_parameterBlock_C_foo_t;
+SamplerState SLANG_parameterBlock_C_foo_s;
+
+float4 main() : SV_Target
+{
+ return SLANG_parameterBlock_C_foo_t.Sample(SLANG_parameterBlock_C_foo_s, foo.u);
+}
+
+#endif
+
diff --git a/tests/rewriter/type-splitting.slang b/tests/rewriter/type-splitting.slang
new file mode 100644
index 000000000..548836fbb
--- /dev/null
+++ b/tests/rewriter/type-splitting.slang
@@ -0,0 +1,3 @@
+//TEST_IGNORE_FILE:
+
+// This file only exists so that `type-splitting.hlsl` officially appears to be using some Slang code.