Skip to content

Commit bdee22a

Browse files
authored
Compat: refactor depth_clip_clamp for 0 storage buffers (#4096)
1 parent 2fdc883 commit bdee22a

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

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

+29-13
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ depth ranges as well.
66
import { makeTestGroup } from '../../../../common/framework/test_group.js';
77
import { assert } from '../../../../common/util/util.js';
88
import { kDepthStencilFormats, kTextureFormatInfo } from '../../../format_info.js';
9-
import { GPUTest } from '../../../gpu_test.js';
9+
import { GPUTest, MaxLimitsTestMixin } from '../../../gpu_test.js';
1010
import {
1111
checkElementsBetween,
1212
checkElementsPassPredicate,
1313
CheckElementsSupplementalTableRows,
1414
} from '../../../util/check_contents.js';
1515

16-
export const g = makeTestGroup(GPUTest);
16+
export const g = makeTestGroup(MaxLimitsTestMixin(GPUTest));
1717

1818
g.test('depth_clamp_and_clip')
1919
.desc(
@@ -55,6 +55,10 @@ have unexpected values then get drawn to the color buffer, which is later checke
5555
const info = kTextureFormatInfo[format];
5656
assert(!!info.depth);
5757

58+
const hasStorageBuffers = t.isCompatibility
59+
? t.device.limits.maxStorageBuffersInFragmentStage! > 0
60+
: true;
61+
5862
/** Number of depth values to test for both vertex output and frag_depth output. */
5963
const kNumDepthValues = 8;
6064
/** Test every combination of vertex output and frag_depth output. */
@@ -111,7 +115,13 @@ have unexpected values then get drawn to the color buffer, which is later checke
111115
@group(0) @binding(0) var <storage, read_write> output: Output;
112116
113117
fn checkZ(vf: VFTest) {
114-
output.fragInputZDiff[vf.vertexIndex] = vf.pos.z - expectedFragPosZ(vf.vertexIndex);
118+
${
119+
hasStorageBuffers
120+
? `
121+
output.fragInputZDiff[vf.vertexIndex] = vf.pos.z - expectedFragPosZ(vf.vertexIndex);
122+
`
123+
: ''
124+
}
115125
}
116126
117127
@fragment
@@ -246,10 +256,12 @@ have unexpected values then get drawn to the color buffer, which is later checke
246256
size: 4 * kNumTestPoints,
247257
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
248258
});
249-
const testBindGroup = t.device.createBindGroup({
250-
layout: testPipeline.getBindGroupLayout(0),
251-
entries: [{ binding: 0, resource: { buffer: fragInputZFailedBuffer } }],
252-
});
259+
const testBindGroup = hasStorageBuffers
260+
? t.device.createBindGroup({
261+
layout: testPipeline.getBindGroupLayout(0),
262+
entries: [{ binding: 0, resource: { buffer: fragInputZFailedBuffer } }],
263+
})
264+
: undefined;
253265

254266
const enc = t.device.createCommandEncoder();
255267
{
@@ -266,7 +278,9 @@ have unexpected values then get drawn to the color buffer, which is later checke
266278
},
267279
});
268280
pass.setPipeline(testPipeline);
269-
pass.setBindGroup(0, testBindGroup);
281+
if (hasStorageBuffers) {
282+
pass.setBindGroup(0, testBindGroup);
283+
}
270284
pass.setViewport(0, 0, kNumTestPoints, 1, kViewportMinDepth, kViewportMaxDepth);
271285
pass.draw(kNumTestPoints);
272286
pass.end();
@@ -314,11 +328,13 @@ have unexpected values then get drawn to the color buffer, which is later checke
314328
}
315329
t.device.queue.submit([enc.finish()]);
316330

317-
t.expectGPUBufferValuesPassCheck(
318-
fragInputZFailedBuffer,
319-
a => checkElementsBetween(a, [() => -1e-5, () => 1e-5]),
320-
{ type: Float32Array, typedLength: kNumTestPoints }
321-
);
331+
if (hasStorageBuffers) {
332+
t.expectGPUBufferValuesPassCheck(
333+
fragInputZFailedBuffer,
334+
a => checkElementsBetween(a, [() => -1e-5, () => 1e-5]),
335+
{ type: Float32Array, typedLength: kNumTestPoints }
336+
);
337+
}
322338

323339
const kCheckPassedValue = 0;
324340
const predicatePrinter: CheckElementsSupplementalTableRows = [

0 commit comments

Comments
 (0)