diff --git a/src/webgpu/api/operation/render_pass/resolve.spec.ts b/src/webgpu/api/operation/render_pass/resolve.spec.ts index 778489b8351c..f9e11d8abecf 100644 --- a/src/webgpu/api/operation/render_pass/resolve.spec.ts +++ b/src/webgpu/api/operation/render_pass/resolve.spec.ts @@ -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'; @@ -11,7 +12,6 @@ const kSlotsToResolve = [ ]; const kSize = 4; -const kFormat: GPUTextureFormat = 'rgba8unorm'; const kDepthStencilFormat: GPUTextureFormat = 'depth24plus-stencil8'; export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest); @@ -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) @@ -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() @@ -55,6 +56,9 @@ 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(); @@ -62,7 +66,7 @@ Test basic render pass resolve behavior for combinations of: const targets: GPUColorTargetState[] = []; for (let i = 0; i < t.params.numColorAttachments; i++) { - targets.push({ format: kFormat }); + targets.push({ format: colorFormat }); } let depthStencil: GPUDepthStencilState | undefined; @@ -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, @@ -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, @@ -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 } }, diff --git a/src/webgpu/format_info.ts b/src/webgpu/format_info.ts index 0e537063c9b6..cab60c8dee89 100644 --- a/src/webgpu/format_info.ts +++ b/src/webgpu/format_info.ts @@ -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.