-
Notifications
You must be signed in to change notification settings - Fork 680
Geometry shader support for HLSL #2483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
HansKristian-Work
merged 20 commits into
KhronosGroup:main
from
ashleyharris-maptek-com-au:GeometryShadersHlsl
May 27, 2025
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2de391c
Disable a warning when #ifdef'ing off all the code within a switch, b…
ashleyharris-maptek-com-au b807712
Add a very basic reference hlsl geometry shader.
ashleyharris-maptek-com-au fc46e64
Implement HLSL export of geometry shaders.
ashleyharris-maptek-com-au b919a16
Add a test for hlsl geometry shaders that call emit from functions, i…
ashleyharris-maptek-com-au 6db3f85
For each function, store a bool whether it, or any function called by…
ashleyharris-maptek-com-au 429a9e0
When calling a function in HLSL, if that function emits geometry, app…
ashleyharris-maptek-com-au 5113120
Tweaks to hlsl geoemtry shader function argument signitures, we add t…
ashleyharris-maptek-com-au 98f4d55
When running the tests, don't pollute the repo with compiled .spv files.
ashleyharris-maptek-com-au e9f780f
Shrink clang-format execution scope from 'touched function' to 'hunk'
ashleyharris-maptek-com-au facca17
Re-apply input struct handling code.
ashleyharris-maptek-com-au 16503b2
Refactor "execution mode to vertex count" into it's own function, as …
ashleyharris-maptek-com-au 7b0bee4
Don't return the output struct from main in geometry shaders. (Re-add…
ashleyharris-maptek-com-au 860d63c
Test update - all geometry streams are just called geometry_stream now.
ashleyharris-maptek-com-au 05d0f33
Add discover_geometry_emitters() and it's helper GeometryEmitDisocver…
ashleyharris-maptek-com-au 43ab16c
Remove naming the geometry_stream - just call it geometry_stream ever…
ashleyharris-maptek-com-au efe825d
Revert my earlier change - detecting geometry emition in the parser i…
ashleyharris-maptek-com-au 6447d77
Don't worry about naming the geometry stream - it's strongly typed in…
ashleyharris-maptek-com-au c674dc4
Add maybe_unused to dismiss compilation warning in non-debug builds.
ashleyharris-maptek-com-au 155f9a1
PR changes - Geometry shader handling wasn't needed in all paths, and…
ashleyharris-maptek-com-au be91880
Update tests for latest PR suggested changes - indentation of geometr…
ashleyharris-maptek-com-au File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| static float4 gl_Position; | ||
| static float4 vPositionIn[1]; | ||
| static float3 vColorIn[1]; | ||
| static float3 gColor; | ||
|
|
||
| struct SPIRV_Cross_Input | ||
| { | ||
| float4 vPositionIn : TEXCOORD0; | ||
| float3 vColorIn : TEXCOORD1; | ||
| }; | ||
|
|
||
| struct SPIRV_Cross_Output | ||
| { | ||
| float3 gColor : TEXCOORD0; | ||
| float4 gl_Position : SV_Position; | ||
| }; | ||
|
|
||
| void geom_main(point SPIRV_Cross_Input stage_input[1], inout TriangleStream<SPIRV_Cross_Output> triStream) | ||
| { | ||
| gColor = vColorIn[0]; | ||
| gl_Position = vPositionIn[0] + float4(-0.100000001490116119384765625f, -0.100000001490116119384765625f, 0.0f, 0.0f); | ||
| { | ||
| SPIRV_Cross_Output stage_output; | ||
| stage_output.gl_Position = gl_Position; | ||
| stage_output.gColor = gColor; | ||
| triStream.Append(stage_output); | ||
| } | ||
| gColor = vColorIn[0]; | ||
| gl_Position = vPositionIn[0] + float4(0.100000001490116119384765625f, -0.100000001490116119384765625f, 0.0f, 0.0f); | ||
| { | ||
| SPIRV_Cross_Output stage_output; | ||
| stage_output.gl_Position = gl_Position; | ||
| stage_output.gColor = gColor; | ||
| triStream.Append(stage_output); | ||
| } | ||
| gColor = vColorIn[0]; | ||
| gl_Position = vPositionIn[0] + float4(0.0f, 0.100000001490116119384765625f, 0.0f, 0.0f); | ||
| { | ||
| SPIRV_Cross_Output stage_output; | ||
| stage_output.gl_Position = gl_Position; | ||
| stage_output.gColor = gColor; | ||
| triStream.Append(stage_output); | ||
| } | ||
| triStream.RestartStrip(); | ||
| } | ||
|
|
||
| [maxvertexcount(3)] | ||
| void main(point SPIRV_Cross_Input stage_input[1], inout TriangleStream<SPIRV_Cross_Output> triStream) | ||
| { | ||
| for(int i = 0; i < 1; i++) | ||
| vPositionIn[i] = stage_input[i].vPositionIn; | ||
| for(int i = 0; i < 1; i++) | ||
| vColorIn[i] = stage_input[i].vColorIn; | ||
| geom_main(stage_input, triStream); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| static float4 gl_Position; | ||
| static float4 vPositionIn[1]; | ||
| static float3 vColorIn[1]; | ||
| static float3 gColor; | ||
|
|
||
| struct SPIRV_Cross_Input | ||
| { | ||
| float4 vPositionIn : TEXCOORD0; | ||
| float3 vColorIn : TEXCOORD1; | ||
| }; | ||
|
|
||
| struct SPIRV_Cross_Output | ||
| { | ||
| float3 gColor : TEXCOORD0; | ||
| float4 gl_Position : SV_Position; | ||
| }; | ||
|
|
||
| void geom_main(point SPIRV_Cross_Input stage_input[1], inout TriangleStream<SPIRV_Cross_Output> triStream) | ||
| { | ||
| float4 center = vPositionIn[0]; | ||
| float3 color = vColorIn[0]; | ||
| gColor = color; | ||
| gl_Position = center + float4(-0.100000001490116119384765625f, -0.100000001490116119384765625f, 0.0f, 0.0f); | ||
| { | ||
| SPIRV_Cross_Output stage_output; | ||
| stage_output.gl_Position = gl_Position; | ||
| stage_output.gColor = gColor; | ||
| triStream.Append(stage_output); | ||
| } | ||
| gColor = color; | ||
| gl_Position = center + float4(0.100000001490116119384765625f, -0.100000001490116119384765625f, 0.0f, 0.0f); | ||
| { | ||
| SPIRV_Cross_Output stage_output; | ||
| stage_output.gl_Position = gl_Position; | ||
| stage_output.gColor = gColor; | ||
| triStream.Append(stage_output); | ||
| } | ||
| gColor = color; | ||
| gl_Position = center + float4(0.0f, 0.100000001490116119384765625f, 0.0f, 0.0f); | ||
| { | ||
| SPIRV_Cross_Output stage_output; | ||
| stage_output.gl_Position = gl_Position; | ||
| stage_output.gColor = gColor; | ||
| triStream.Append(stage_output); | ||
| } | ||
| triStream.RestartStrip(); | ||
| } | ||
|
|
||
| [maxvertexcount(3)] | ||
| void main(point SPIRV_Cross_Input stage_input[1], inout TriangleStream<SPIRV_Cross_Output> triStream) | ||
| { | ||
| for(int i = 0; i < 1; i++) | ||
| vPositionIn[i] = stage_input[i].vPositionIn; | ||
| for(int i = 0; i < 1; i++) | ||
| vColorIn[i] = stage_input[i].vColorIn; | ||
| geom_main(stage_input, triStream); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #version 450 | ||
|
|
||
| layout(points) in; | ||
| layout(triangle_strip, max_vertices = 3) out; | ||
|
|
||
| layout(location = 0) in vec4 vPositionIn[1]; | ||
| layout(location = 1) in vec3 vColorIn[1]; | ||
|
|
||
| layout(location = 0) out vec3 gColor; | ||
|
|
||
| void main() { | ||
| vec4 center = vPositionIn[0]; | ||
| vec3 color = vColorIn[0]; | ||
|
|
||
| gColor = color; | ||
| gl_Position = center + vec4(-0.1, -0.1, 0.0, 0.0); | ||
| EmitVertex(); | ||
|
|
||
| gColor = color; | ||
| gl_Position = center + vec4(0.1, -0.1, 0.0, 0.0); | ||
| EmitVertex(); | ||
|
|
||
| gColor = color; | ||
| gl_Position = center + vec4(0.0, 0.1, 0.0, 0.0); | ||
| EmitVertex(); | ||
|
|
||
| EndPrimitive(); | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.