Skip to content

HLSL: better support for geometry shaders builtins#2603

Merged
HansKristian-Work merged 4 commits intoKhronosGroup:mainfrom
xen2:hlsl_geo_shader
Feb 26, 2026
Merged

HLSL: better support for geometry shaders builtins#2603
HansKristian-Work merged 4 commits intoKhronosGroup:mainfrom
xen2:hlsl_geo_shader

Conversation

@xen2
Copy link
Copy Markdown
Contributor

@xen2 xen2 commented Feb 22, 2026

SV_Position in geometry shaders (1ca6a7a)

Geometry shaders have both an input and output gl_Position, which requires two separate global variables.

A has_separate_input_output loop was introduced in emit_builtin_variables() to emit both gl_PositionIn (input, array-sized by vertex count) and gl_Position (output).
Note: this also applies to BuiltInSampleMask (which had different type as input and output) and is now handled automatically with the same system.

SV_PrimitiveID / SV_GSInstanceID in geometry shaders (3b374ae)

In HLSL, SV_PrimitiveID is passed as a direct function parameter to the geometry shader entry point rather than via the input struct. The input struct emission is suppressed for GS, the parameter is added to the entry point argument list, and the copy-in assigns gl_PrimitiveIDIn = gl_PrimitiveID. SV_GSInstanceID (mapping to BuiltInInvocationId) is handled similarly for instanced geometry shaders.

Fix per-vertex array dimension stripping (707bc66)

SPIR-V stores array dimensions in reverse order (outermost dimension last in the array vector). The previous code removed the innermost dimension, which was wrong.

Comment thread spirv_hlsl.cpp Outdated
Comment thread spirv_hlsl.cpp Outdated
@HansKristian-Work HansKristian-Work merged commit 7bfcf72 into KhronosGroup:main Feb 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants