HLSL: better support for geometry shaders builtins#2603
Merged
HansKristian-Work merged 4 commits intoKhronosGroup:mainfrom Feb 26, 2026
Merged
HLSL: better support for geometry shaders builtins#2603HansKristian-Work merged 4 commits intoKhronosGroup:mainfrom
HansKristian-Work merged 4 commits intoKhronosGroup:mainfrom
Conversation
HansKristian-Work
approved these changes
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_outputloop 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.