diff --git a/shaders/hlsl/meshshader/meshshader.frag b/shaders/hlsl/meshshader/meshshader.frag new file mode 100644 index 00000000..d4e1e8de --- /dev/null +++ b/shaders/hlsl/meshshader/meshshader.frag @@ -0,0 +1,15 @@ +/* Copyright (c) 2023, Sascha Willems + * + * SPDX-License-Identifier: MIT + * + */ + +struct VSOutput +{ +[[vk::location(0)]] float4 color : COLOR0; +}; + +float4 main(VSOutput input) : SV_TARGET +{ + return float4(input.color); +} \ No newline at end of file diff --git a/shaders/hlsl/meshshader/meshshader.frag.spv b/shaders/hlsl/meshshader/meshshader.frag.spv new file mode 100644 index 00000000..93ce5e69 Binary files /dev/null and b/shaders/hlsl/meshshader/meshshader.frag.spv differ diff --git a/shaders/hlsl/meshshader/meshshader.mesh b/shaders/hlsl/meshshader/meshshader.mesh new file mode 100644 index 00000000..840e009b --- /dev/null +++ b/shaders/hlsl/meshshader/meshshader.mesh @@ -0,0 +1,50 @@ +/* Copyright (c) 2023, Sascha Willems + * + * SPDX-License-Identifier: MIT + * + */ + +struct UBO +{ + float4x4 projection; + float4x4 model; + float4x4 view; +}; + +cbuffer ubo : register(b0) { UBO ubo; } + +struct VertexOutput +{ + float4 position: SV_Position; + float4 color: COLOR0; +}; + +static const float4 positions[3] = { + float4( 0.0, -1.0, 0.0, 1.0), + float4(-1.0, 1.0, 0.0, 1.0), + float4( 1.0, 1.0, 0.0, 1.0) +}; + +static const float4 colors[3] = { + float4(0.0, 1.0, 0.0, 1.0), + float4(0.0, 0.0, 1.0, 1.0), + float4(1.0, 0.0, 0.0, 1.0) +}; + +[outputtopology("triangle")] +[numthreads(1, 1, 1)] +void main(out indices uint3 triangles[1], out vertices VertexOutput vertices[3], uint3 DispatchThreadID : SV_DispatchThreadID) +{ + float4x4 mvp = mul(ubo.projection, mul(ubo.view, ubo.model)); + + float4 offset = float4(0.0, 0.0, (float)DispatchThreadID, 0.0); + + SetMeshOutputCounts(3, 1); + for (uint i = 0; i < 3; i++) { + vertices[i].position = mul(mvp, positions[i] + offset); + vertices[i].color = colors[i]; + } + + SetMeshOutputCounts(3, 1); + triangles[0] = uint3(0, 1, 2); +} diff --git a/shaders/hlsl/meshshader/meshshader.mesh.spv b/shaders/hlsl/meshshader/meshshader.mesh.spv new file mode 100644 index 00000000..7e7eb60d Binary files /dev/null and b/shaders/hlsl/meshshader/meshshader.mesh.spv differ diff --git a/shaders/hlsl/meshshader/meshshader.task b/shaders/hlsl/meshshader/meshshader.task new file mode 100644 index 00000000..3b3b524e --- /dev/null +++ b/shaders/hlsl/meshshader/meshshader.task @@ -0,0 +1,19 @@ +/* Copyright (c) 2023, Sascha Willems + * + * SPDX-License-Identifier: MIT + * + */ + +struct DummyPayLoad +{ + uint dummyData; +}; + +// We don't use pay loads in this sample, but the fn call requires one +groupshared DummyPayLoad dummyPayLoad; + +[numthreads(1,1,1)] +void main() +{ + DispatchMesh(3, 1, 1, dummyPayLoad); +} diff --git a/shaders/hlsl/meshshader/meshshader.task.spv b/shaders/hlsl/meshshader/meshshader.task.spv new file mode 100644 index 00000000..97278132 Binary files /dev/null and b/shaders/hlsl/meshshader/meshshader.task.spv differ