Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 10 additions & 5 deletions src/webgpu/api/operation/render_pass/resolve.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const description = `API Operation Tests for multisample resolve in render passes.`;

import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { isTextureFormatPossiblyResolvable, kColorTextureFormats } from '../../../format_info.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../../gpu_test.js';
import * as ttu from '../../../texture_test_utils.js';

Expand All @@ -11,7 +12,6 @@ const kSlotsToResolve = [
];

const kSize = 4;
const kFormat: GPUTextureFormat = 'rgba8unorm';
const kDepthStencilFormat: GPUTextureFormat = 'depth24plus-stencil8';

export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);
Expand All @@ -28,7 +28,6 @@ Test basic render pass resolve behavior for combinations of:
TODO: cases where color attachment and resolve target don't have the same mip level
- resolveTarget {2d array layer, TODO: 3d slice} {0, >0} with {2d, TODO: 3d} resolveTarget
TODO: cases where color attachment and resolve target don't have the same z (slice or layer)
- TODO: test all renderable color formats
- TODO: test that any not-resolved attachments are rendered to correctly.
- TODO: test different loadOps
- TODO?: resolveTarget mip level {0, >0} (TODO?: different mip level from colorAttachment)
Expand All @@ -38,6 +37,8 @@ Test basic render pass resolve behavior for combinations of:
)
.params(u =>
u
.combine('colorFormat', kColorTextureFormats)
.filter(t => isTextureFormatPossiblyResolvable(t.colorFormat))
.combine('separateResolvePass', [false, true])
.combine('storeOperation', ['discard', 'store'] as const)
.beginSubcases()
Expand All @@ -55,14 +56,17 @@ Test basic render pass resolve behavior for combinations of:
.unless(t => !t.depthStencilAttachment && t.transientDepthStencilAttachment)
)
.fn(t => {
const { colorFormat } = t.params;
t.skipIfTextureFormatNotSupported(colorFormat);
t.skipIfTextureFormatNotResolvable(colorFormat);
// MAINTENANCE_TODO(#4509): Remove this when TRANSIENT_ATTACHMENT is added to the WebGPU spec.
if (t.params.transientColorAttachment || t.params.transientDepthStencilAttachment) {
t.skipIfTransientAttachmentNotSupported();
}

const targets: GPUColorTargetState[] = [];
for (let i = 0; i < t.params.numColorAttachments; i++) {
targets.push({ format: kFormat });
targets.push({ format: colorFormat });
}

let depthStencil: GPUDepthStencilState | undefined;
Expand Down Expand Up @@ -133,7 +137,7 @@ Test basic render pass resolve behavior for combinations of:
for (let i = 0; i < t.params.numColorAttachments; i++) {
const colorAttachment = t
.createTextureTracked({
format: kFormat,
format: colorFormat,
size: [kSize, kSize, 1],
sampleCount: 4,
mipLevelCount: 1,
Expand All @@ -146,7 +150,7 @@ Test basic render pass resolve behavior for combinations of:
let resolveTarget: GPUTextureView | undefined;
if (t.params.slotsToResolve.includes(i)) {
const resolveTargetTexture = t.createTextureTracked({
format: kFormat,
format: colorFormat,
size: [kResolveTargetSize, kResolveTargetSize, t.params.resolveTargetBaseArrayLayer + 1],
sampleCount: 1,
mipLevelCount: t.params.resolveTargetBaseMipLevel + 1,
Expand Down Expand Up @@ -230,6 +234,7 @@ Test basic render pass resolve behavior for combinations of:
ttu.expectSinglePixelComparisonsAreOkInTexture(
t,
{ texture: resolveTarget, mipLevel: t.params.resolveTargetBaseMipLevel },
// Note: Channels that do not exist in the actual texture are not compared.
[
// Top left pixel should be {1.0, 1.0, 1.0, 1.0}.
{ coord: { x: 0, y: 0, z }, exp: { R: 1.0, G: 1.0, B: 1.0, A: 1.0 } },
Expand Down
15 changes: 15 additions & 0 deletions src/webgpu/format_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,21 @@ export function isTextureFormatPossiblyMultisampled(format: GPUTextureFormat) {
);
}

/**
* Returns true if a texture can possibly be resolved.
* The texture may require certain features to be enabled.
*/
export function isTextureFormatPossiblyResolvable(format: GPUTextureFormat) {
if (format === 'rg11b10ufloat') {
return true;
}
if (isTextureFormatTier1EnablesResolve(format)) {
return true;
}
const info = kTextureFormatInfo[format];
return !!info.colorRender?.resolve;
}

/**
* Returns true if a texture can possibly be used as a storage texture.
* The texture may require certain features to be enabled.
Expand Down