Skip to content

Commit b132a88

Browse files
author
Finn Plummer
committed
add static sampler tests
1 parent 7453f8e commit b132a88

File tree

1 file changed

+212
-0
lines changed

1 file changed

+212
-0
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
#--- source.hlsl
2+
3+
Texture2D<float4> In : register(t0);
4+
5+
SamplerState DefaultSampler: register(s0);
6+
SamplerState OtherSampler: register(s1);
7+
8+
RWTexture2D<float4> DefaultOut : register(u1);
9+
RWTexture2D<float4> OtherOut : register(u2);
10+
11+
#define RootSig \
12+
"DescriptorTable( " \
13+
" SRV(t0), " \
14+
" UAV(u1, numDescriptors = 2) " \
15+
"), " \
16+
"StaticSampler(s0), " \
17+
"StaticSampler(s1, " \
18+
" mipLODBias = -15.99, " \
19+
" minLOD = 32.0, " \
20+
" maxLOD = 32.0, " \
21+
" addressV = TEXTURE_ADDRESS_MIRROR, " \
22+
" filter = FILTER_MAXIMUM_MIN_MAG_MIP_POINT " \
23+
")"
24+
25+
[RootSignature(RootSig)]
26+
[numthreads(4,1,1)]
27+
void main(uint GI : SV_GroupIndex) {
28+
uint Width, Height;
29+
uint2 GID = {GI / 2, GI % 2};
30+
float2 UV = GID;
31+
float4 DefaultColor = In.Sample(DefaultSampler, UV);
32+
DefaultOut[GID.xy] = DefaultColor.bgra;
33+
34+
float4 OtherColor = In.Sample(OtherSampler, UV);
35+
OtherOut[GID.xy] = OtherColor.bgra;
36+
}
37+
38+
//--- pipeline.yaml
39+
---
40+
Shaders:
41+
- Stage: Compute
42+
Entry: main
43+
DispatchSize: [1, 1, 1]
44+
Buffers:
45+
- Name: In
46+
Format: Float32
47+
Channels: 4
48+
Data: [1.0, 0.0, 0.0, 1.0,
49+
0.0, 1.0, 0.0, 1.0,
50+
0.0, 0.0, 1.0, 1.0,
51+
1.0, 1.0, 0.0, 1.0]
52+
OutputProps:
53+
Height: 2
54+
Width: 2
55+
Depth: 16
56+
- Name: DefaultOut
57+
Format: Float32
58+
Channels: 4
59+
ZeroInitSize: 64
60+
OutputProps:
61+
Height: 2
62+
Width: 2
63+
Depth: 16
64+
- Name: OtherOut
65+
Format: Float32
66+
Channels: 4
67+
ZeroInitSize: 64
68+
OutputProps:
69+
Height: 2
70+
Width: 2
71+
Depth: 16
72+
- Name: ExpectedDefaultOut
73+
Format: Float32
74+
Channels: 4
75+
Data: [0.25, 0.5, 0.5, 1,
76+
0.25, 0.5, 0.5, 1,
77+
0.25, 0.5, 0.5,
78+
1, 0.25, 0.5, 0.5, 1]
79+
OutputProps:
80+
Height: 2
81+
Width: 2
82+
Depth: 16
83+
## Modifying the LOD parameters does not affect the output. However,
84+
## The applied filter will output [0, 0, 1, 1, ... 0, 0, 1, 1] and then
85+
## setting addressV to mirror outputs [0, 0, 1, 1, ..., 1, 0, 0, 1] as shown
86+
## below
87+
- Name: ExpectedOtherOut
88+
Format: Float32
89+
Channels: 4
90+
Data: [0, 0, 1, 1,
91+
0, 0, 1, 1,
92+
1, 0, 0, 1,
93+
1, 0, 0, 1 ]
94+
OutputProps:
95+
Height: 2
96+
Width: 2
97+
Depth: 16
98+
Results:
99+
- Result: DefaultTest
100+
Rule: BufferExact
101+
Actual: DefaultOut
102+
Expected: ExpectedDefaultOut
103+
- Result: OtherTest
104+
Rule: BufferExact
105+
Actual: OtherOut
106+
Expected: ExpectedOtherOut
107+
DescriptorSets:
108+
- Resources:
109+
- Name: In
110+
Kind: Texture2D
111+
DirectXBinding:
112+
Register: 0
113+
Space: 0
114+
VulkanBinding:
115+
Binding: 0
116+
- Name: DefaultOut
117+
Kind: RWTexture2D
118+
DirectXBinding:
119+
Register: 1
120+
Space: 0
121+
VulkanBinding:
122+
Binding: 1
123+
- Name: OtherOut
124+
Kind: RWTexture2D
125+
DirectXBinding:
126+
Register: 2
127+
Space: 0
128+
VulkanBinding:
129+
Binding: 2
130+
...
131+
#--- end
132+
133+
# UNSUPPORTED: Clang
134+
# RUN: split-file %s %t
135+
# RUN: %dxc_target -T cs_6_6 -Fo %t.o %t/source.hlsl
136+
# RUN: %offloader %t/pipeline.yaml %t.o
137+
# RUN: obj2yaml %t.o | FileCheck %s --check-prefix=OBJ
138+
139+
## Root Signature Header
140+
# OBJ: - Name: RTS0
141+
# OBJ: Size: 196
142+
# OBJ: RootSignature:
143+
# OBJ: Version: 2
144+
# OBJ: NumRootParameters: 1
145+
# OBJ: RootParametersOffset: 24
146+
# OBJ: NumStaticSamplers: 2
147+
# OBJ: StaticSamplersOffset: 92
148+
149+
# OBJ: Parameters:
150+
151+
## Descriptor Table
152+
# OBJ: - ParameterType: 0
153+
# OBJ: ShaderVisibility: 0
154+
# OBJ: Table:
155+
# OBJ: NumRanges: 2
156+
# OBJ: RangesOffset: 44
157+
158+
# OBJ: Ranges:
159+
160+
## SRV(t0)
161+
# OBJ: - RangeType: 0
162+
# OBJ: NumDescriptors: 1
163+
# OBJ: BaseShaderRegister: 0
164+
# OBJ: RegisterSpace: 0
165+
# OBJ: OffsetInDescriptorsFromTableStart: 4294967295
166+
167+
## UAV(u1, numDescriptors = 2)
168+
# OBJ: - RangeType: 1
169+
# OBJ: NumDescriptors: 2
170+
# OBJ: BaseShaderRegister: 1
171+
# OBJ: RegisterSpace: 0
172+
# OBJ: OffsetInDescriptorsFromTableStart: 4294967295
173+
174+
# OBJ: Samplers:
175+
176+
## StaticSampler(s0)
177+
## Ensures the defaults are set as expected
178+
# OBJ: - Filter: 85
179+
# OBJ: AddressU: 1
180+
# OBJ: AddressV: 1
181+
# OBJ: AddressW: 1
182+
# OBJ: MipLODBias: 0
183+
# OBJ: MaxAnisotropy: 16
184+
# OBJ: ComparisonFunc: 4
185+
# OBJ: BorderColor: 2
186+
# OBJ: MinLOD: 0
187+
# OBJ: MaxLOD: 3.40282e+38
188+
# OBJ: ShaderRegister: 0
189+
# OBJ: RegisterSpace: 0
190+
# OBJ: ShaderVisibility: 0
191+
192+
## StaticSampler(s1,
193+
## mipLODBias = -15.99,
194+
## minLOD = 32.0,
195+
## maxLOD = 32.0,
196+
## addressV = TEXTURE_ADDRESS_MIRROR,
197+
## filter = FILTER_MAXIMUM_MIN_MAG_MIP_POINT
198+
## )
199+
## Ensures the specified values are set as expected
200+
# OBJ: - Filter: 384
201+
# OBJ: AddressU: 1
202+
# OBJ: AddressV: 2
203+
# OBJ: AddressW: 1
204+
# OBJ: MipLODBias: -15.99
205+
# OBJ: MaxAnisotropy: 16
206+
# OBJ: ComparisonFunc: 4
207+
# OBJ: BorderColor: 2
208+
# OBJ: MinLOD: 32
209+
# OBJ: MaxLOD: 32
210+
# OBJ: ShaderRegister: 1
211+
# OBJ: RegisterSpace: 0
212+
# OBJ: ShaderVisibility: 0

0 commit comments

Comments
 (0)