summaryrefslogtreecommitdiffstats
path: root/tests/bindings
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-12-14 11:51:29 -0800
committerGitHub <noreply@github.com>2017-12-14 11:51:29 -0800
commit4137f9d4a58462ed94ed658ac0d722c830c3eb89 (patch)
tree74e89ad6deb13e23a4a2a72020e87219c9a1879e /tests/bindings
parent6d6142122b15461d6c8cabdb31292b0de688ba35 (diff)
More fixups for Vulkan parameter block bindings (#309)
I'm adding a small cross-compilation test to try to make sure that we are testing the binding generation for GLSL output. We probably still need a more complex test that uses multiple blocks, plus variables not in a block. The big changes here are: - Change the `containerTypeLayout` field to a `containerVarLayout` in the `ParameterGroupTypeLayout`, so that we can store the base offsets for the fields in a uniform fashion (even though these will all be zero). - Switch the emit logic to carefully use either the container or element var layout depending on what they are emitting bindings for. This involved adding something akin to the "reflection path" notion that Falcor has to use, but only for the emit step.
Diffstat (limited to 'tests/bindings')
-rw-r--r--tests/bindings/glsl-parameter-blocks.slang16
-rw-r--r--tests/bindings/glsl-parameter-blocks.slang.glsl37
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/bindings/glsl-parameter-blocks.slang b/tests/bindings/glsl-parameter-blocks.slang
new file mode 100644
index 000000000..d356df775
--- /dev/null
+++ b/tests/bindings/glsl-parameter-blocks.slang
@@ -0,0 +1,16 @@
+#version 450 core
+//TEST:CROSS_COMPILE: -profile ps_5_0 -entry main -target spirv-assembly
+
+struct Test
+{
+ float4 a;
+ Texture2D t;
+ SamplerState s;
+};
+
+ParameterBlock<Test> gTest;
+
+float4 main(float2 uv : UV)
+{
+ return gTest.a + gTest.t.Sample(gTest.s, uv);
+}
diff --git a/tests/bindings/glsl-parameter-blocks.slang.glsl b/tests/bindings/glsl-parameter-blocks.slang.glsl
new file mode 100644
index 000000000..5094debb1
--- /dev/null
+++ b/tests/bindings/glsl-parameter-blocks.slang.glsl
@@ -0,0 +1,37 @@
+//TEST_IGNORE_FILE:
+#version 450 core
+
+struct Test
+{
+ vec4 a;
+};
+
+layout(binding = 0)
+uniform gTest_S1
+{
+ Test gTest;
+};
+
+layout(binding = 1)
+uniform texture2D gTest_t;
+
+layout(binding = 2)
+uniform sampler gTest_s;
+
+vec4 main_(vec2 uv)
+{
+ return gTest.a + texture(sampler2D(gTest_t, gTest_s), uv);
+}
+
+layout(location = 0)
+in vec2 SLANG_in_uv;
+
+layout(location = 0)
+out vec4 SLANG_out_main_result;
+
+void main()
+{
+ vec2 uv = SLANG_in_uv;
+ vec4 main_result = main_(uv);
+ SLANG_out_main_result = main_result;
+}