Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat: refactor depth_clip_clamp for 0 storage buffers #4096

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions src/webgpu/api/operation/rendering/depth_clip_clamp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ depth ranges as well.
import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { assert } from '../../../../common/util/util.js';
import { kDepthStencilFormats, kTextureFormatInfo } from '../../../format_info.js';
import { GPUTest } from '../../../gpu_test.js';
import { GPUTest, MaxLimitsTestMixin } from '../../../gpu_test.js';
import {
checkElementsBetween,
checkElementsPassPredicate,
CheckElementsSupplementalTableRows,
} from '../../../util/check_contents.js';

export const g = makeTestGroup(GPUTest);
export const g = makeTestGroup(MaxLimitsTestMixin(GPUTest));

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

const hasStorageBuffers = t.isCompatibility
? t.device.limits.maxStorageBuffersInFragmentStage! > 0
: true;

/** Number of depth values to test for both vertex output and frag_depth output. */
const kNumDepthValues = 8;
/** Test every combination of vertex output and frag_depth output. */
Expand Down Expand Up @@ -111,7 +115,13 @@ have unexpected values then get drawn to the color buffer, which is later checke
@group(0) @binding(0) var <storage, read_write> output: Output;
fn checkZ(vf: VFTest) {
output.fragInputZDiff[vf.vertexIndex] = vf.pos.z - expectedFragPosZ(vf.vertexIndex);
${
hasStorageBuffers
? `
output.fragInputZDiff[vf.vertexIndex] = vf.pos.z - expectedFragPosZ(vf.vertexIndex);
`
: ''
}
}
@fragment
Expand Down Expand Up @@ -246,10 +256,12 @@ have unexpected values then get drawn to the color buffer, which is later checke
size: 4 * kNumTestPoints,
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
});
const testBindGroup = t.device.createBindGroup({
layout: testPipeline.getBindGroupLayout(0),
entries: [{ binding: 0, resource: { buffer: fragInputZFailedBuffer } }],
});
const testBindGroup = hasStorageBuffers
? t.device.createBindGroup({
layout: testPipeline.getBindGroupLayout(0),
entries: [{ binding: 0, resource: { buffer: fragInputZFailedBuffer } }],
})
: undefined;

const enc = t.device.createCommandEncoder();
{
Expand All @@ -266,7 +278,9 @@ have unexpected values then get drawn to the color buffer, which is later checke
},
});
pass.setPipeline(testPipeline);
pass.setBindGroup(0, testBindGroup);
if (hasStorageBuffers) {
pass.setBindGroup(0, testBindGroup!);
greggman marked this conversation as resolved.
Show resolved Hide resolved
}
pass.setViewport(0, 0, kNumTestPoints, 1, kViewportMinDepth, kViewportMaxDepth);
pass.draw(kNumTestPoints);
pass.end();
Expand Down Expand Up @@ -314,11 +328,13 @@ have unexpected values then get drawn to the color buffer, which is later checke
}
t.device.queue.submit([enc.finish()]);

t.expectGPUBufferValuesPassCheck(
fragInputZFailedBuffer,
a => checkElementsBetween(a, [() => -1e-5, () => 1e-5]),
{ type: Float32Array, typedLength: kNumTestPoints }
);
if (hasStorageBuffers) {
t.expectGPUBufferValuesPassCheck(
fragInputZFailedBuffer,
a => checkElementsBetween(a, [() => -1e-5, () => 1e-5]),
{ type: Float32Array, typedLength: kNumTestPoints }
);
}

const kCheckPassedValue = 0;
const predicatePrinter: CheckElementsSupplementalTableRows = [
Expand Down
Loading