Skip to content

Commit 855a1aa

Browse files
Add a simple passthrough amplification shader test.
1 parent 05afb4c commit 855a1aa

1 file changed

Lines changed: 112 additions & 0 deletions

File tree

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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(-1.0, -1.0, 0.0, 1.0);
42+
position = float4(0.0, 0.25, 0.0, 1.0);
43+
color *= float4(1.0, 0.0, 0.0, 1.0);
44+
} else if (groupThreadID == 1) {
45+
// position = float4(0.0, 1.0, 0.0, 1.0);
46+
position = float4(0.25, -0.25, 0.0, 1.0);
47+
color *= float4(0.0, 1.0, 0.0, 1.0);
48+
} else /*if (groupThreadID == 2)*/ {
49+
// position = float4(1.0, -1.0, 0.0, 1.0);
50+
position = float4(-0.25, -0.25, 0.0, 1.0);
51+
color *= float4(0.0, 0.0, 1.0, 1.0);
52+
}
53+
54+
verts[groupThreadID].position = position;
55+
verts[groupThreadID].color = color;
56+
57+
if (groupThreadID == 0) {
58+
tris[0] = uint3(0, 1, 2);
59+
}
60+
}
61+
62+
#--- pixel.hlsl
63+
struct PSInput
64+
{
65+
float4 position : SV_POSITION;
66+
float4 color : COLOR;
67+
};
68+
69+
float4 main(PSInput input) : SV_TARGET
70+
{
71+
return input.color;
72+
}
73+
#--- pipeline.yaml
74+
---
75+
Shaders:
76+
- Stage: Amplification
77+
Entry: main
78+
- Stage: Mesh
79+
Entry: main
80+
- Stage: Pixel
81+
Entry: main
82+
Buffers:
83+
- Name: Output
84+
Format: Float32
85+
Channels: 4
86+
FillSize: 1048576 # 256x256 @ 16 bytes per pixel
87+
OutputProps:
88+
Height: 256
89+
Width: 256
90+
Depth: 1
91+
Bindings:
92+
RenderTarget: Output
93+
DescriptorSets: []
94+
...
95+
#--- rules.yaml
96+
---
97+
- Type: PixelPercent
98+
Val: 0.2 # No more than 0.2% of pixels may be visibly different.
99+
...
100+
#--- end
101+
102+
REQUIRES: MeshShader
103+
104+
# Unimplemented https://github.com/llvm/llvm-project/issues/136966
105+
# XFAIL: Clang
106+
107+
# RUN: split-file %s %t
108+
# RUN: %dxc_target -T as_6_5 -Fo %t-amplification.o %t/amplification.hlsl
109+
# RUN: %dxc_target -T ms_6_5 -Fo %t-mesh.o %t/mesh.hlsl
110+
# RUN: %dxc_target -T ps_6_5 -Fo %t-pixel.o %t/pixel.hlsl
111+
# RUN: %offloader %t/pipeline.yaml %t-amplification.o %t-mesh.o %t-pixel.o -r Output -o %t/Output.png
112+
# RUN: imgdiff %t/Output.png %goldenimage_dir/hlsl/Graphics/MeshShaders/SimpleAmplification.png -rules %t/rules.yaml

0 commit comments

Comments
 (0)