Skip to content

Commit 44173ed

Browse files
authored
Test all stencil formats, and address some nits in depth_bias/stencil tests (#2096)
* make depth_bias expectations params private * remove infinity cases, WebIDL throws an exception in these cases * spencil -> stencil * Parameterize stencil tests over all stencil formats * make stencil expectation params private
1 parent 1720022 commit 44173ed

File tree

2 files changed

+119
-113
lines changed

2 files changed

+119
-113
lines changed

src/webgpu/api/operation/rendering/depth_bias.spec.ts

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const description = `
2-
Tests render results with different depth bias values like 'positive', 'negative', 'infinity',
2+
Tests render results with different depth bias values like 'positive', 'negative',
33
'slope', 'clamp', etc.
44
`;
55

@@ -11,7 +11,6 @@ import {
1111
kTextureFormatInfo,
1212
} from '../../../capability_info.js';
1313
import { GPUTest } from '../../../gpu_test.js';
14-
import { kValue } from '../../../util/constants.js';
1514
import { TexelView } from '../../../util/texture/texel_view.js';
1615
import { textureContentIsOKByT2B } from '../../../util/texture/texture_ok.js';
1716

@@ -155,13 +154,13 @@ class DepthBiasTest extends GPUTest {
155154
bias,
156155
biasSlopeScale,
157156
biasClamp,
158-
expectedDepth,
157+
_expectedDepth,
159158
}: {
160159
quadAngle: QuadAngle;
161160
bias: number;
162161
biasSlopeScale: number;
163162
biasClamp: number;
164-
expectedDepth: number;
163+
_expectedDepth: number;
165164
}
166165
) {
167166
const { renderTarget, depthTexture } = this.runDepthBiasTestInternal(depthFormat, {
@@ -172,7 +171,7 @@ class DepthBiasTest extends GPUTest {
172171
initialDepth: 0,
173172
});
174173

175-
const expColor = { Depth: expectedDepth };
174+
const expColor = { Depth: _expectedDepth };
176175
const expTexelView = TexelView.fromTexelsAsColors(depthFormat, coords => expColor);
177176

178177
const result = textureContentIsOKByT2B(
@@ -194,13 +193,13 @@ class DepthBiasTest extends GPUTest {
194193
bias,
195194
biasSlopeScale,
196195
biasClamp,
197-
expectedColor,
196+
_expectedColor,
198197
}: {
199198
quadAngle: QuadAngle;
200199
bias: number;
201200
biasSlopeScale: number;
202201
biasClamp: number;
203-
expectedColor: Float32Array;
202+
_expectedColor: Float32Array;
204203
}
205204
) {
206205
const { renderTarget, depthTexture } = this.runDepthBiasTestInternal(depthFormat, {
@@ -213,10 +212,10 @@ class DepthBiasTest extends GPUTest {
213212

214213
const renderTargetFormat = 'rgba8unorm';
215214
const expColor = {
216-
R: expectedColor[0],
217-
G: expectedColor[1],
218-
B: expectedColor[2],
219-
A: expectedColor[3],
215+
R: _expectedColor[0],
216+
G: _expectedColor[1],
217+
B: _expectedColor[2],
218+
A: _expectedColor[3],
220219
};
221220
const expTexelView = TexelView.fromTexelsAsColors(renderTargetFormat, coords => expColor);
222221

@@ -264,7 +263,7 @@ export const g = makeTestGroup(DepthBiasTest);
264263
g.test('depth_bias')
265264
.desc(
266265
`
267-
Tests that a square with different depth bias values like 'positive', 'negative', 'infinity',
266+
Tests that a square with different depth bias values like 'positive', 'negative',
268267
'slope', 'clamp', etc. is drawn as expected.
269268
`
270269
)
@@ -276,63 +275,49 @@ g.test('depth_bias')
276275
bias: kPointTwoFiveBiasForPointTwoFiveZOnFloat,
277276
biasSlopeScale: 0,
278277
biasClamp: 0,
279-
expectedDepth: 0.5,
278+
_expectedDepth: 0.5,
280279
},
281280
{
282281
quadAngle: QuadAngle.Flat,
283282
bias: kPointTwoFiveBiasForPointTwoFiveZOnFloat,
284283
biasSlopeScale: 0,
285284
biasClamp: 0.125,
286-
expectedDepth: 0.375,
285+
_expectedDepth: 0.375,
287286
},
288287
{
289288
quadAngle: QuadAngle.Flat,
290289
bias: -kPointTwoFiveBiasForPointTwoFiveZOnFloat,
291290
biasSlopeScale: 0,
292291
biasClamp: 0.125,
293-
expectedDepth: 0,
292+
_expectedDepth: 0,
294293
},
295294
{
296295
quadAngle: QuadAngle.Flat,
297296
bias: -kPointTwoFiveBiasForPointTwoFiveZOnFloat,
298297
biasSlopeScale: 0,
299298
biasClamp: -0.125,
300-
expectedDepth: 0.125,
299+
_expectedDepth: 0.125,
301300
},
302301
{
303302
quadAngle: QuadAngle.TiltedX,
304303
bias: 0,
305304
biasSlopeScale: 0,
306305
biasClamp: 0,
307-
expectedDepth: 0.25,
306+
_expectedDepth: 0.25,
308307
},
309308
{
310309
quadAngle: QuadAngle.TiltedX,
311310
bias: 0,
312311
biasSlopeScale: 1,
313312
biasClamp: 0,
314-
expectedDepth: 0.75,
313+
_expectedDepth: 0.75,
315314
},
316315
{
317316
quadAngle: QuadAngle.TiltedX,
318317
bias: 0,
319318
biasSlopeScale: -0.5,
320319
biasClamp: 0,
321-
expectedDepth: 0,
322-
},
323-
{
324-
quadAngle: QuadAngle.TiltedX,
325-
bias: 0,
326-
biasSlopeScale: kValue.f32.infinity.positive,
327-
biasClamp: 0,
328-
expectedDepth: 1,
329-
},
330-
{
331-
quadAngle: QuadAngle.TiltedX,
332-
bias: 0,
333-
biasSlopeScale: kValue.f32.infinity.negative,
334-
biasClamp: 0,
335-
expectedDepth: 0,
320+
_expectedDepth: 0,
336321
},
337322
] as const)
338323
)
@@ -360,21 +345,21 @@ g.test('depth_bias_24bit_format')
360345
bias: 0.25 * (1 << 25),
361346
biasSlopeScale: 0,
362347
biasClamp: 0,
363-
expectedColor: new Float32Array([1.0, 0.0, 0.0, 1.0]),
348+
_expectedColor: new Float32Array([1.0, 0.0, 0.0, 1.0]),
364349
},
365350
{
366351
quadAngle: QuadAngle.TiltedX,
367352
bias: 0.25 * (1 << 25),
368353
biasSlopeScale: 1,
369354
biasClamp: 0,
370-
expectedColor: new Float32Array([1.0, 0.0, 0.0, 1.0]),
355+
_expectedColor: new Float32Array([1.0, 0.0, 0.0, 1.0]),
371356
},
372357
{
373358
quadAngle: QuadAngle.Flat,
374359
bias: 0.25 * (1 << 25),
375360
biasSlopeScale: 0,
376361
biasClamp: 0.1,
377-
expectedColor: new Float32Array([0.0, 0.0, 0.0, 0.0]),
362+
_expectedColor: new Float32Array([0.0, 0.0, 0.0, 0.0]),
378363
},
379364
] as const)
380365
)

0 commit comments

Comments
 (0)