rhi: Update the docs and manual test for geometry shaders

Task-number: QTBUG-137521
Change-Id: Ic9256eaaa55aef20c622429058fda9235c1f73c1
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2025-06-10 12:01:13 +02:00
parent 7dd952667c
commit fdbc8079c9
8 changed files with 17 additions and 40 deletions

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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;
}

View File

@ -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);
}
}