Skip to content

Commit 9ae0055

Browse files
Add a simple passthrough amplification shader test.
1 parent 05afb4c commit 9ae0055

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Test that has a really simple passthrough amplification shader that halfs the
2+
// green color component on all triangle vertices.
3+
4+
#--- amplification.hlsl
5+
struct Payload {
6+
float3 color;
7+
};
8+
9+
[numthreads(1, 1, 1)]
10+
void main()
11+
{
12+
Payload payload = (Payload)0;
13+
payload.color = float3(1.0, 0.5, 1.0);
14+
DispatchMesh(1, 1, 1, payload);
15+
}
16+
17+
#--- mesh.hlsl
18+
struct Payload {
19+
float3 color;
20+
};
21+
22+
struct PSInput
23+
{
24+
float4 position : SV_POSITION;
25+
float4 color : COLOR;
26+
};
27+
28+
[outputtopology("triangle")]
29+
[numthreads(3, 1, 1)]
30+
void main(
31+
uint groupThreadID: SV_GroupThreadID,
32+
in payload Payload payload,
33+
out vertices PSInput verts[3],
34+
out indices uint3 tris[1]) {
35+
36+
SetMeshOutputCounts(3, 1);
37+
38+
float4 position;
39+
float4 color = float4(payload.color, 1.0);
40+
if (groupThreadID == 0) {
41+
position = float4(0.0, 0.25, 0.0, 1.0);
42+
color *= float4(1.0, 0.0, 0.0, 1.0);
43+
} else if (groupThreadID == 1) {
44+
position = float4(0.25, -0.25, 0.0, 1.0);
45+
color *= float4(0.0, 1.0, 0.0, 1.0);
46+
} else /*if (groupThreadID == 2)*/ {
47+
position = float4(-0.25, -0.25, 0.0, 1.0);
48+
color *= float4(0.0, 0.0, 1.0, 1.0);
49+
}
50+
51+
verts[groupThreadID].position = position;
52+
verts[groupThreadID].color = color;
53+
54+
if (groupThreadID == 0) {
55+
tris[0] = uint3(0, 1, 2);
56+
}
57+
}
58+
59+
#--- pixel.hlsl
60+
struct PSInput
61+
{
62+
float4 position : SV_POSITION;
63+
float4 color : COLOR;
64+
};
65+
66+
float4 main(PSInput input) : SV_TARGET
67+
{
68+
return input.color;
69+
}
70+
#--- pipeline.yaml
71+
---
72+
Shaders:
73+
- Stage: Amplification
74+
Entry: main
75+
- Stage: Mesh
76+
Entry: main
77+
- Stage: Pixel
78+
Entry: main
79+
Buffers:
80+
- Name: Output
81+
Format: Float32
82+
Channels: 4
83+
FillSize: 1048576 # 256x256 @ 16 bytes per pixel
84+
OutputProps:
85+
Height: 256
86+
Width: 256
87+
Depth: 1
88+
Bindings:
89+
RenderTarget: Output
90+
DescriptorSets: []
91+
...
92+
#--- rules.yaml
93+
---
94+
- Type: PixelPercent
95+
Val: 0.2 # No more than 0.2% of pixels may be visibly different.
96+
...
97+
#--- end
98+
99+
REQUIRES: MeshShader
100+
101+
# Unimplemented https://github.com/llvm/llvm-project/issues/136966
102+
# XFAIL: Clang
103+
104+
# RUN: split-file %s %t
105+
# RUN: %dxc_target -T as_6_5 -Fo %t-amplification.o %t/amplification.hlsl
106+
# RUN: %dxc_target -T ms_6_5 -Fo %t-mesh.o %t/mesh.hlsl
107+
# RUN: %dxc_target -T ps_6_5 -Fo %t-pixel.o %t/pixel.hlsl
108+
# RUN: %offloader %t/pipeline.yaml %t-amplification.o %t-mesh.o %t-pixel.o -r Output -o %t/Output.png
109+
# RUN: imgdiff %t/Output.png %goldenimage_dir/hlsl/Graphics/MeshShaders/SimpleAmplification.png -rules %t/rules.yaml

0 commit comments

Comments
 (0)