mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
* Features and draw commands added * Tried to implement the pipeline creation (completely untested) * Fixed clippy issues * Fixed something I think * A little bit of work on the mesh shader example (currently doesn't work on dx12) * Reached a new kind of error state * Fixed an alignment issue * DirectX 12 mesh shaders working :party: * Removed stupid change and updated changelog * Fixed typo * Added backends option to example framework * Removed silly no write fragment shader from tests to see if anything breaks * Tried to make mesh shader tests run elsewhere too * Removed printlns and checked that dx12 mesh shader tests run * Documented very strange issue * I'm so lost * Fixed stupid typos * Fixed all issues * Removed unnecessary example stuff, updated tests * Updated typos.toml * Updated limits * Apply suggestion from @cwfitzgerald Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com> * Apply suggestion from @cwfitzgerald Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com> * Removed supported backends, made example & tests always pass the filename to shader compilers * Removed excessive bools in test params * Added new tests to the list * I'm a sinner for this one (unused import) * Replaced random stuff with test params hashing * Updated typos.toml * Updated -Fo typo thing * Actually fixed typo issue this time * Update CHANGELOG.md Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com> * Update tests/tests/wgpu-gpu/mesh_shader/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update wgpu-hal/src/dx12/mod.rs Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com> * Addressed comments * Lmao --------- Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
54 lines
1.6 KiB
HLSL
54 lines
1.6 KiB
HLSL
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;
|
|
}
|