Skip to content

Commit

Permalink
Loosen precision in multisample resolve operation test (gpuweb#446)
Browse files Browse the repository at this point in the history
* Loosen precision in multisample resolve operation test

Some platforms produce 0x7f and others 0x80 when a pixel is
half-covered.

* rebase / address comment
  • Loading branch information
kainino0x committed Feb 2, 2021
1 parent 5d365e2 commit a0ea80f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/webgpu/api/operation/render_pass/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const g = makeTestGroup(GPUTest);
g.test('render_pass_resolve')
.params(
params()
.combine(poptions('storeOperation', ['clear', 'store'] as const))
.combine(poptions('numColorAttachments', [2, 4] as const))
.combine(poptions('slotsToResolve', kSlotsToResolve))
.combine(poptions('storeOperation', ['clear', 'store'] as const))
.combine(poptions('resolveTargetBaseMipLevel', [0, 1] as const))
.combine(poptions('resolveTargetBaseArrayLayer', [0, 1] as const))
)
Expand Down Expand Up @@ -161,10 +161,10 @@ g.test('render_pass_resolve')
t.device.queue.submit([encoder.finish()]);

// Verify the resolve targets contain the correct values.
for (let i = 0; i < resolveTargets.length; i++) {
for (const resolveTarget of resolveTargets) {
// Test top left pixel, which should be {255, 255, 255, 255}.
t.expectSinglePixelIn2DTexture(
resolveTargets[i],
resolveTarget,
kFormat,
{ x: 0, y: 0 },
{
Expand All @@ -176,7 +176,7 @@ g.test('render_pass_resolve')

// Test bottom right pixel, which should be {0, 0, 0, 0}.
t.expectSinglePixelIn2DTexture(
resolveTargets[i],
resolveTarget,
kFormat,
{ x: kSize - 1, y: kSize - 1 },
{
Expand All @@ -187,12 +187,12 @@ g.test('render_pass_resolve')
);

// Test top right pixel, which should be {127, 127, 127, 127} due to the multisampled resolve.
t.expectSinglePixelIn2DTexture(
resolveTargets[i],
t.expectSinglePixelBetweenTwoValuesIn2DTexture(
resolveTarget,
kFormat,
{ x: kSize - 1, y: 0 },
{
exp: new Uint8Array([0x7f, 0x7f, 0x7f, 0x7f]),
exp: [new Uint8Array([0x7f, 0x7f, 0x7f, 0x7f]), new Uint8Array([0x80, 0x80, 0x80, 0x80])],
slice: t.params.resolveTargetBaseArrayLayer,
layout: { mipLevel: t.params.resolveTargetBaseMipLevel },
}
Expand Down
7 changes: 3 additions & 4 deletions src/webgpu/gpu_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ got [${failedByteActualValues.join(', ')}]`;
src: GPUTexture,
format: SizedTextureFormat,
{ x, y }: { x: number; y: number },
slice = 0,
layout?: TextureLayoutOptions
{ slice = 0, layout }: { slice?: number; layout?: TextureLayoutOptions }
): GPUBuffer {
const { byteLength, bytesPerRow, rowsPerImage, mipSize } = getTextureCopyLayout(
format,
Expand Down Expand Up @@ -487,7 +486,7 @@ got [${failedByteActualValues.join(', ')}]`;
generateWarningOnly?: boolean;
}
): void {
const buffer = this.readSinglePixelFrom2DTexture(src, format, { x, y }, slice, layout);
const buffer = this.readSinglePixelFrom2DTexture(src, format, { x, y }, { slice, layout });
this.expectContents(buffer, exp, 0, { generateWarningOnly });
}

Expand All @@ -507,7 +506,7 @@ got [${failedByteActualValues.join(', ')}]`;
generateWarningOnly?: boolean;
}
): void {
const buffer = this.readSinglePixelFrom2DTexture(src, format, { x, y }, slice, layout);
const buffer = this.readSinglePixelFrom2DTexture(src, format, { x, y }, { slice, layout });
this.expectContentsBetweenTwoValues(buffer, exp, 0, { generateWarningOnly });
}

Expand Down

0 comments on commit a0ea80f

Please sign in to comment.