summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese
diff options
context:
space:
mode:
authorBen Fletcher <ben.fletcher@me.com>2022-12-13 15:47:19 -0800
committerLaszlo Agocs <laszlo.agocs@qt.io>2023-02-14 17:48:09 +0100
commitdc0b2466f8dda3a0858e01c9d63098c1d9b638f2 (patch)
treed47317b1669f4ba7c36f57074a3b8b1b81a373e9 /tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese
parentd21e9a432661b161d94cd4ee90804a4a9b122fe0 (diff)
RHI: Metal SPIRV-Cross buffer size buffers
When SPIRV-Cross encounters a GLSL storage buffer runtime sized array, it generates MSL code which expects a "buffer size buffer" containing a list of storage buffer sizes to be bound. This patch adds RHI backend support for Metal "buffer size buffers" on compute and graphics (including tessellation) pipelines. Includes unit tests. An accompanying patch to qtshadertools is required. Change-Id: I9392bfb21803e1a868d7de420fedc097a8452429 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese')
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese
new file mode 100644
index 0000000000..a8bec13561
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese
@@ -0,0 +1,39 @@
+#version 450
+
+layout(triangles, fractional_odd_spacing, ccw) in;
+
+layout (std140, binding = 6) uniform unused0
+{
+ int unused;
+}u0;
+
+layout (binding = 0) uniform u
+{
+ mat4 matrix;
+};
+
+layout (std430, binding = 5) readonly buffer ssbo5
+{
+ float _float[];
+};
+
+layout (std430, binding = 8) readonly buffer ssbo8
+{
+ float float8[];
+};
+
+layout (std430, binding = 1) readonly buffer unused1
+{
+ int unused[];
+}u1;
+
+
+void main()
+{
+ // some OpenGL implementations will optimize out the buffer variables if we don't use them
+ // resulting in a .length() of 0
+ float a = _float[0] == 0 && float8[0] == 1 ? 1 : 1;
+
+ if(_float.length() == 64)
+ gl_Position = a * matrix * ((gl_TessCoord.x * gl_in[0].gl_Position) + (gl_TessCoord.y * gl_in[1].gl_Position) + (gl_TessCoord.z * gl_in[2].gl_Position)) * (float8.length()==2?1:0);
+}