Skip to content

Commit

Permalink
Test all stencil formats, and address some nits in depth_bias/stencil…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
kainino0x authored Dec 23, 2022
1 parent 1720022 commit 44173ed
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 113 deletions.
57 changes: 21 additions & 36 deletions src/webgpu/api/operation/rendering/depth_bias.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const description = `
Tests render results with different depth bias values like 'positive', 'negative', 'infinity',
Tests render results with different depth bias values like 'positive', 'negative',
'slope', 'clamp', etc.
`;

Expand All @@ -11,7 +11,6 @@ import {
kTextureFormatInfo,
} from '../../../capability_info.js';
import { GPUTest } from '../../../gpu_test.js';
import { kValue } from '../../../util/constants.js';
import { TexelView } from '../../../util/texture/texel_view.js';
import { textureContentIsOKByT2B } from '../../../util/texture/texture_ok.js';

Expand Down Expand Up @@ -155,13 +154,13 @@ class DepthBiasTest extends GPUTest {
bias,
biasSlopeScale,
biasClamp,
expectedDepth,
_expectedDepth,
}: {
quadAngle: QuadAngle;
bias: number;
biasSlopeScale: number;
biasClamp: number;
expectedDepth: number;
_expectedDepth: number;
}
) {
const { renderTarget, depthTexture } = this.runDepthBiasTestInternal(depthFormat, {
Expand All @@ -172,7 +171,7 @@ class DepthBiasTest extends GPUTest {
initialDepth: 0,
});

const expColor = { Depth: expectedDepth };
const expColor = { Depth: _expectedDepth };
const expTexelView = TexelView.fromTexelsAsColors(depthFormat, coords => expColor);

const result = textureContentIsOKByT2B(
Expand All @@ -194,13 +193,13 @@ class DepthBiasTest extends GPUTest {
bias,
biasSlopeScale,
biasClamp,
expectedColor,
_expectedColor,
}: {
quadAngle: QuadAngle;
bias: number;
biasSlopeScale: number;
biasClamp: number;
expectedColor: Float32Array;
_expectedColor: Float32Array;
}
) {
const { renderTarget, depthTexture } = this.runDepthBiasTestInternal(depthFormat, {
Expand All @@ -213,10 +212,10 @@ class DepthBiasTest extends GPUTest {

const renderTargetFormat = 'rgba8unorm';
const expColor = {
R: expectedColor[0],
G: expectedColor[1],
B: expectedColor[2],
A: expectedColor[3],
R: _expectedColor[0],
G: _expectedColor[1],
B: _expectedColor[2],
A: _expectedColor[3],
};
const expTexelView = TexelView.fromTexelsAsColors(renderTargetFormat, coords => expColor);

Expand Down Expand Up @@ -264,7 +263,7 @@ export const g = makeTestGroup(DepthBiasTest);
g.test('depth_bias')
.desc(
`
Tests that a square with different depth bias values like 'positive', 'negative', 'infinity',
Tests that a square with different depth bias values like 'positive', 'negative',
'slope', 'clamp', etc. is drawn as expected.
`
)
Expand All @@ -276,63 +275,49 @@ g.test('depth_bias')
bias: kPointTwoFiveBiasForPointTwoFiveZOnFloat,
biasSlopeScale: 0,
biasClamp: 0,
expectedDepth: 0.5,
_expectedDepth: 0.5,
},
{
quadAngle: QuadAngle.Flat,
bias: kPointTwoFiveBiasForPointTwoFiveZOnFloat,
biasSlopeScale: 0,
biasClamp: 0.125,
expectedDepth: 0.375,
_expectedDepth: 0.375,
},
{
quadAngle: QuadAngle.Flat,
bias: -kPointTwoFiveBiasForPointTwoFiveZOnFloat,
biasSlopeScale: 0,
biasClamp: 0.125,
expectedDepth: 0,
_expectedDepth: 0,
},
{
quadAngle: QuadAngle.Flat,
bias: -kPointTwoFiveBiasForPointTwoFiveZOnFloat,
biasSlopeScale: 0,
biasClamp: -0.125,
expectedDepth: 0.125,
_expectedDepth: 0.125,
},
{
quadAngle: QuadAngle.TiltedX,
bias: 0,
biasSlopeScale: 0,
biasClamp: 0,
expectedDepth: 0.25,
_expectedDepth: 0.25,
},
{
quadAngle: QuadAngle.TiltedX,
bias: 0,
biasSlopeScale: 1,
biasClamp: 0,
expectedDepth: 0.75,
_expectedDepth: 0.75,
},
{
quadAngle: QuadAngle.TiltedX,
bias: 0,
biasSlopeScale: -0.5,
biasClamp: 0,
expectedDepth: 0,
},
{
quadAngle: QuadAngle.TiltedX,
bias: 0,
biasSlopeScale: kValue.f32.infinity.positive,
biasClamp: 0,
expectedDepth: 1,
},
{
quadAngle: QuadAngle.TiltedX,
bias: 0,
biasSlopeScale: kValue.f32.infinity.negative,
biasClamp: 0,
expectedDepth: 0,
_expectedDepth: 0,
},
] as const)
)
Expand Down Expand Up @@ -360,21 +345,21 @@ g.test('depth_bias_24bit_format')
bias: 0.25 * (1 << 25),
biasSlopeScale: 0,
biasClamp: 0,
expectedColor: new Float32Array([1.0, 0.0, 0.0, 1.0]),
_expectedColor: new Float32Array([1.0, 0.0, 0.0, 1.0]),
},
{
quadAngle: QuadAngle.TiltedX,
bias: 0.25 * (1 << 25),
biasSlopeScale: 1,
biasClamp: 0,
expectedColor: new Float32Array([1.0, 0.0, 0.0, 1.0]),
_expectedColor: new Float32Array([1.0, 0.0, 0.0, 1.0]),
},
{
quadAngle: QuadAngle.Flat,
bias: 0.25 * (1 << 25),
biasSlopeScale: 0,
biasClamp: 0.1,
expectedColor: new Float32Array([0.0, 0.0, 0.0, 0.0]),
_expectedColor: new Float32Array([0.0, 0.0, 0.0, 0.0]),
},
] as const)
)
Expand Down
Loading

0 comments on commit 44173ed

Please sign in to comment.