summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <[email protected]>2025-06-10 12:01:13 +0200
committerLaszlo Agocs <[email protected]>2025-06-11 15:15:42 +0200
commitfdbc8079c96aabcd8350d1f4e18e450c9a9e456c (patch)
tree95ec655319cead241bcb608722d852c10c7ecaee
parent7dd952667c690fc2c97385c899ca372f2583c781 (diff)
rhi: Update the docs and manual test for geometry shaders
Task-number: QTBUG-137521 Change-Id: Ic9256eaaa55aef20c622429058fda9235c1f73c1 Reviewed-by: Andy Nichols <[email protected]>
-rw-r--r--src/gui/rhi/qrhi.cpp21
-rwxr-xr-xtests/manual/rhi/geometryshader/buildshaders.bat3
-rw-r--r--tests/manual/rhi/geometryshader/test.frag.qsbbin456 -> 450 bytes
-rw-r--r--tests/manual/rhi/geometryshader/test.geom3
-rw-r--r--tests/manual/rhi/geometryshader/test.geom.qsbbin1222 -> 1364 bytes
-rw-r--r--tests/manual/rhi/geometryshader/test.vert4
-rw-r--r--tests/manual/rhi/geometryshader/test.vert.qsbbin591 -> 665 bytes
-rw-r--r--tests/manual/rhi/geometryshader/test_geom.hlsl26
8 files changed, 17 insertions, 40 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index 0628d07ce73..c47828120d8 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -936,16 +936,17 @@ Q_LOGGING_CATEGORY(QRHI_LOG_RUB, "qt.rhi.rub")
avoided as it will not be supported by all backends. The maximum patch
control point count portable between backends is 32.
- \value GeometryShader Indicates that the geometry shader stage is
- supported. When supported, a geometry shader can be specified in the
- QRhiShaderStage list. Geometry Shaders are considered an experimental
- feature in QRhi and can only be expected to be supported with Vulkan,
- Direct 3D, OpenGL (3.2+) and OpenGL ES (3.2+), assuming the implementation
- reports it as supported at run time. Geometry shaders have portability
- issues between APIs, and therefore no guarantees can be given for a
- universal solution. They will never be supported with Metal. Whereas with
- Direct 3D a handwritten HLSL geometry shader must be injected into each
- QShader for the geometry stage since qsb cannot generate this from SPIR-V.
+ \value GeometryShader Indicates that the geometry shader stage is supported.
+ When supported, a geometry shader can be specified in the QRhiShaderStage
+ list. Geometry Shaders are considered an experimental feature in QRhi and
+ can only be expected to be supported with Vulkan, Direct 3D 11 and 12,
+ OpenGL (3.2+) and OpenGL ES (3.2+), assuming the implementation reports it
+ as supported at run time. Starting with Qt 6.11 geometry shaders are
+ automatically translated to HLSL, and therefore no injection of handwritten
+ HLSL geometry shaders is necessary anymore (but note that gl_in and
+ expressions such as gl_in[0].gl_Position are not supported; rather, pass the
+ position as an output variable from the vertex shader). Geometry shaders are
+ not supported with Metal.
\value TextureArrayRange Indicates that for
\l{QRhi::newTextureArray()}{texture arrays} it is possible to specify a
diff --git a/tests/manual/rhi/geometryshader/buildshaders.bat b/tests/manual/rhi/geometryshader/buildshaders.bat
index a3b7296e168..c4ce5266429 100755
--- a/tests/manual/rhi/geometryshader/buildshaders.bat
+++ b/tests/manual/rhi/geometryshader/buildshaders.bat
@@ -1,6 +1,5 @@
:: Copyright (C) 2024 The Qt Company Ltd.
:: SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
qsb --glsl 320es,410 --hlsl 50 test.vert -o test.vert.qsb
-qsb --glsl 320es,410 test.geom -o test.geom.qsb
-qsb -r hlsl,50,test_geom.hlsl test.geom.qsb
+qsb --glsl 320es,410 --hlsl 50 test.geom -o test.geom.qsb
qsb --glsl 320es,410 --hlsl 50 test.frag -o test.frag.qsb
diff --git a/tests/manual/rhi/geometryshader/test.frag.qsb b/tests/manual/rhi/geometryshader/test.frag.qsb
index b6a5877b951..b857f362982 100644
--- a/tests/manual/rhi/geometryshader/test.frag.qsb
+++ b/tests/manual/rhi/geometryshader/test.frag.qsb
Binary files differ
diff --git a/tests/manual/rhi/geometryshader/test.geom b/tests/manual/rhi/geometryshader/test.geom
index 750a3085bd4..46f381f33a8 100644
--- a/tests/manual/rhi/geometryshader/test.geom
+++ b/tests/manual/rhi/geometryshader/test.geom
@@ -4,6 +4,7 @@
layout(points) in;
layout(line_strip, max_vertices = 7) out;
+layout(location = 0) in vec4 v_position[];
layout(std140, binding = 0) uniform buf {
float radius;
@@ -16,7 +17,7 @@ void main(void)
{
float theta = float(i) / 6.0f * 2.0 * M_PI;
- gl_Position = gl_in[0].gl_Position;
+ gl_Position = v_position[0];
gl_Position.xy += radius * vec2(cos(theta), sin(theta));
EmitVertex();
diff --git a/tests/manual/rhi/geometryshader/test.geom.qsb b/tests/manual/rhi/geometryshader/test.geom.qsb
index 9aa4a0cf98e..93a059b502f 100644
--- a/tests/manual/rhi/geometryshader/test.geom.qsb
+++ b/tests/manual/rhi/geometryshader/test.geom.qsb
Binary files differ
diff --git a/tests/manual/rhi/geometryshader/test.vert b/tests/manual/rhi/geometryshader/test.vert
index af06581f6a4..33c52df4e64 100644
--- a/tests/manual/rhi/geometryshader/test.vert
+++ b/tests/manual/rhi/geometryshader/test.vert
@@ -1,8 +1,10 @@
#version 440
layout(location = 0) in vec3 position;
+layout(location = 0) out vec4 v_position;
void main()
{
- gl_Position = vec4(position, 1.0);
+ v_position = vec4(position, 1.0);
+ gl_Position = v_position;
}
diff --git a/tests/manual/rhi/geometryshader/test.vert.qsb b/tests/manual/rhi/geometryshader/test.vert.qsb
index 7238d8037b6..4b12cd37d0c 100644
--- a/tests/manual/rhi/geometryshader/test.vert.qsb
+++ b/tests/manual/rhi/geometryshader/test.vert.qsb
Binary files differ
diff --git a/tests/manual/rhi/geometryshader/test_geom.hlsl b/tests/manual/rhi/geometryshader/test_geom.hlsl
deleted file mode 100644
index e58659252b1..00000000000
--- a/tests/manual/rhi/geometryshader/test_geom.hlsl
+++ /dev/null
@@ -1,26 +0,0 @@
-struct VertexOutput
-{
- float4 position : SV_Position;
-};
-
-struct PixelInput
-{
- float4 position : SV_POSITION;
-};
-
-cbuffer buf : register(b0)
-{
- float radius : packoffset(c0);
-};
-
-[maxvertexcount(7)]
-void main(point VertexOutput input[1], inout LineStream<PixelInput> OutputStream)
-{
- PixelInput output;
- for (int i = 0; i < 7; ++i) {
- float theta = float(i) / 6.0f * 2.0 * 3.14159265;
- output.position = input[0].position;
- output.position.xy += radius * float2(cos(theta), sin(theta));
- OutputStream.Append(output);
- }
-}