-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[hal/dx12] Mesh Shaders #8110
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
cwfitzgerald
merged 51 commits into
gfx-rs:trunk
from
inner-daemons:mesh-shading/dx12-backend
Sep 25, 2025
Merged
[hal/dx12] Mesh Shaders #8110
Changes from 44 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
fe68bf2
Features and draw commands added
inner-daemons 7558c76
Tried to implement the pipeline creation (completely untested)
inner-daemons 302d3c4
Fixed clippy issues
inner-daemons 794fa2a
Fixed something I think
inner-daemons be5ccb0
A little bit of work on the mesh shader example (currently doesn't wo…
inner-daemons e5bd6b2
Reached a new kind of error state
inner-daemons 50a80f4
Fixed an alignment issue
inner-daemons 01dca60
DirectX 12 mesh shaders working :party:
inner-daemons ef36e29
Removed stupid change and updated changelog
inner-daemons 4e83a8c
Fixed typo
inner-daemons 99e4fd9
Added backends option to example framework
inner-daemons c941407
Removed silly no write fragment shader from tests to see if anything …
inner-daemons 2a52d6e
Tried to make mesh shader tests run elsewhere too
inner-daemons 313c270
Removed printlns and checked that dx12 mesh shader tests run
inner-daemons d93830c
Documented very strange issue
inner-daemons bfbf6ee
I'm so lost
inner-daemons 62b582e
Fixed stupid typos
inner-daemons 684ef2c
Fixed all issues
inner-daemons 35f422d
Removed unnecessary example stuff, updated tests
inner-daemons 0d800b0
Updated typos.toml
inner-daemons fafa2c8
Updated limits
inner-daemons 5d18b20
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons f3c4c85
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons 3ff325a
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons 7f5839a
Apply suggestion from @cwfitzgerald
inner-daemons 5414538
Apply suggestion from @cwfitzgerald
inner-daemons fafac8c
Removed supported backends, made example & tests always pass the file…
inner-daemons 8f53f75
Merge branch 'mesh-shading/dx12-backend' of https://github.com/supama…
inner-daemons 2ea5c1a
Removed excessive bools in test params
inner-daemons 9054c63
Added new tests to the list
inner-daemons 2e96f2d
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons d3473d2
I'm a sinner for this one (unused import)
inner-daemons ccd58bb
Replaced random stuff with test params hashing
inner-daemons 01277ee
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons c5a92ae
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons 53a0b7f
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons bab62f8
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons f371a88
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons 88340df
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons 41f0fa8
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons 7b166b0
Updated typos.toml
inner-daemons 9494999
Updated -Fo typo thing
inner-daemons 6aea9f2
Actually fixed typo issue this time
inner-daemons 1657863
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons 872bbf5
Update CHANGELOG.md
inner-daemons 0c7b087
Update tests/tests/wgpu-gpu/mesh_shader/mod.rs
inner-daemons 72e6b78
Update wgpu-hal/src/dx12/mod.rs
inner-daemons 16e2284
Addressed comments
inner-daemons 5d19505
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons 16ed713
Lmao
inner-daemons fa4105c
Merge branch 'trunk' into mesh-shading/dx12-backend
inner-daemons 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
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
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
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,53 @@ | ||
struct OutVertex { | ||
float4 Position : SV_POSITION; | ||
float4 Color: COLOR; | ||
}; | ||
struct OutPrimitive { | ||
float4 ColorMask : COLOR_MASK : PRIMITIVE; | ||
bool CullPrimitive: SV_CullPrimitive; | ||
}; | ||
struct InVertex { | ||
float4 Color: COLOR; | ||
}; | ||
struct InPrimitive { | ||
float4 ColorMask : COLOR_MASK : PRIMITIVE; | ||
}; | ||
struct PayloadData { | ||
float4 ColorMask; | ||
bool Visible; | ||
}; | ||
|
||
|
||
static const float4 positions[3] = {float4(0., 1.0, 0., 1.0), float4(-1.0, -1.0, 0., 1.0), float4(1.0, -1.0, 0., 1.0)}; | ||
static const float4 colors[3] = {float4(0., 1., 0., 1.), float4(0., 0., 1., 1.), float4(1., 0., 0., 1.)}; | ||
|
||
groupshared PayloadData outPayload; | ||
|
||
[numthreads(1, 1, 1)] | ||
void Task() { | ||
outPayload.ColorMask = float4(1.0, 1.0, 0.0, 1.0); | ||
outPayload.Visible = true; | ||
DispatchMesh(3, 1, 1, outPayload); | ||
} | ||
|
||
[outputtopology("triangle")] | ||
[numthreads(1, 1, 1)] | ||
void Mesh(out indices uint3 triangles[1], out vertices OutVertex vertices[3], out primitives OutPrimitive primitives[1], in payload PayloadData payload) { | ||
SetMeshOutputCounts(3, 1); | ||
|
||
vertices[0].Position = positions[0]; | ||
vertices[1].Position = positions[1]; | ||
vertices[2].Position = positions[2]; | ||
|
||
vertices[0].Color = colors[0] * payload.ColorMask; | ||
vertices[1].Color = colors[1] * payload.ColorMask; | ||
vertices[2].Color = colors[2] * payload.ColorMask; | ||
|
||
triangles[0] = uint3(0, 1, 2); | ||
primitives[0].ColorMask = float4(1.0, 0.0, 0.0, 1.0); | ||
primitives[0].CullPrimitive = !payload.Visible; | ||
} | ||
|
||
float4 Frag(InVertex vertex, InPrimitive primitive) : SV_Target { | ||
return vertex.Color * primitive.ColorMask; | ||
} |
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
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
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
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
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,41 @@ | ||
struct OutVertex { | ||
float4 Position : SV_POSITION; | ||
float4 Color: COLOR; | ||
}; | ||
struct InVertex { | ||
float4 Color: COLOR; | ||
}; | ||
|
||
|
||
static const float4 positions[3] = {float4(0., 1.0, 0., 1.0), float4(-1.0, -1.0, 0., 1.0), float4(1.0, -1.0, 0., 1.0)}; | ||
static const float4 colors[3] = {float4(0., 1., 0., 1.), float4(0., 0., 1., 1.), float4(1., 0., 0., 1.)}; | ||
|
||
struct EmptyPayload { | ||
uint _nullField; | ||
}; | ||
groupshared EmptyPayload _emptyPayload; | ||
|
||
[numthreads(4, 1, 1)] | ||
void Task() { | ||
DispatchMesh(1, 1, 1, _emptyPayload); | ||
} | ||
|
||
[outputtopology("triangle")] | ||
[numthreads(1, 1, 1)] | ||
void Mesh(out indices uint3 triangles[1], out vertices OutVertex vertices[3], in payload EmptyPayload _emptyPayload) { | ||
SetMeshOutputCounts(3, 1); | ||
|
||
vertices[0].Position = positions[0]; | ||
vertices[1].Position = positions[1]; | ||
vertices[2].Position = positions[2]; | ||
|
||
vertices[0].Color = colors[0]; | ||
vertices[1].Color = colors[1]; | ||
vertices[2].Color = colors[2]; | ||
|
||
triangles[0] = uint3(0, 1, 2); | ||
} | ||
|
||
float4 Frag(InVertex vertex) : SV_Target { | ||
return vertex.Color; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.