summaryrefslogtreecommitdiff
path: root/tests/cross-compile
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cross-compile')
-rw-r--r--tests/cross-compile/array-of-buffers.slang32
-rw-r--r--tests/cross-compile/array-of-buffers.slang.glsl57
-rw-r--r--tests/cross-compile/array-of-buffers.slang.hlsl35
3 files changed, 124 insertions, 0 deletions
diff --git a/tests/cross-compile/array-of-buffers.slang b/tests/cross-compile/array-of-buffers.slang
new file mode 100644
index 000000000..de87e6d9d
--- /dev/null
+++ b/tests/cross-compile/array-of-buffers.slang
@@ -0,0 +1,32 @@
+// array-of-buffers.slang
+
+//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage fragment
+//TEST:CROSS_COMPILE:-target dxil-assembly -entry main -stage fragment -profile sm_6_0
+
+// This test ensures that we cross-compile arrays of structured/constant
+// buffers into appropriate GLSL, where these are not first-class types.
+//
+// Note that this test does *not* currently test the case of passing
+// a structured or constant buffer into a subroutine, which requires
+// further work.
+
+struct S { float4 f; };
+
+cbuffer C
+{
+ uint index;
+}
+
+ConstantBuffer<S> cb [3];
+StructuredBuffer<S> sb1[4];
+RWStructuredBuffer<float4> sb2[5];
+ByteAddressBuffer bb [6];
+
+float4 main() : SV_Target
+{
+ return cb [index] .f
+ + sb1[index][index].f
+ + sb2[index][index]
+ + float4(bb[index].Load(index*4));
+}
+
diff --git a/tests/cross-compile/array-of-buffers.slang.glsl b/tests/cross-compile/array-of-buffers.slang.glsl
new file mode 100644
index 000000000..d3aa5082f
--- /dev/null
+++ b/tests/cross-compile/array-of-buffers.slang.glsl
@@ -0,0 +1,57 @@
+//TEST_IGNORE_FILE:
+#version 450
+
+struct SLANG_ParameterGroup_C_0
+{
+ uint index_0;
+};
+
+layout(binding = 0)
+layout(std140) uniform _S1
+{
+ SLANG_ParameterGroup_C_0 _data;
+} C_0;
+
+struct S_0
+{
+ vec4 f_0;
+};
+
+layout(binding = 1)
+layout(std140) uniform _S2
+{
+ S_0 _data;
+} cb_0[3];
+
+
+layout(std430, binding = 2)
+buffer _S3 {
+ S_0 _data[];
+} sb1_0[4];
+
+layout(std430, binding = 3)
+buffer _S4 {
+ vec4 _data[];
+} sb2_0[5];
+
+layout(std430, binding = 4)
+buffer _S5
+{
+ uint _data[];
+} bb_0[6];
+
+layout(location = 0)
+out vec4 _S6;
+
+void main()
+{
+ vec4 _S7 = cb_0[C_0._data.index_0]._data.f_0;
+
+ S_0 _S8 = sb1_0[C_0._data.index_0]._data[C_0._data.index_0];
+
+ vec4 _S9 = _S7 + _S8.f_0;
+ vec4 _S10 = _S9 + sb2_0[C_0._data.index_0]._data[C_0._data.index_0];
+ uint _S11 = bb_0[C_0._data.index_0]._data[int(C_0._data.index_0 * uint(4))];
+ _S6 = _S10 + vec4(_S11);
+ return;
+}
diff --git a/tests/cross-compile/array-of-buffers.slang.hlsl b/tests/cross-compile/array-of-buffers.slang.hlsl
new file mode 100644
index 000000000..129993edc
--- /dev/null
+++ b/tests/cross-compile/array-of-buffers.slang.hlsl
@@ -0,0 +1,35 @@
+//TEST_IGNORE_FILE:
+
+struct SLANG_ParameterGroup_C_0
+{
+ uint index_0;
+};
+
+cbuffer C_0 : register(b0)
+{
+ SLANG_ParameterGroup_C_0 C_0;
+}
+
+struct S_0
+{
+ float4 f_0;
+};
+
+ConstantBuffer<S_0> cb_0 [3] : register(b1);
+StructuredBuffer<S_0> sb1_0[4] : register(t0);
+RWStructuredBuffer<float4> sb2_0[5] : register(u1);
+ByteAddressBuffer bb_0[6] : register(t4);
+
+float4 main() : SV_TARGET
+{
+ float4 _S1 = cb_0[C_0.index_0].f_0;
+
+ S_0 _S2 = sb1_0[C_0.index_0][C_0.index_0];
+
+ float4 _S3 = _S1 + _S2.f_0;
+ float4 _S4 = _S3 + sb2_0[C_0.index_0][C_0.index_0];
+ uint _S5 = bb_0[C_0.index_0].Load(
+ (int) (C_0.index_0 * (uint) 4));
+
+ return _S4 + (float4) _S5;
+}