diff --git a/src/webgpu/format_info.ts b/src/webgpu/format_info.ts index 8c1e9b7d7d0..d582a2005b4 100644 --- a/src/webgpu/format_info.ts +++ b/src/webgpu/format_info.ts @@ -1856,7 +1856,20 @@ export function isSintOrUintFormat(format: GPUTextureFormat) { /** * Returns true of format can be multisampled. */ -export function isMultisampledTextureFormat(format: GPUTextureFormat): boolean { +export const kCompatModeUnsupportedMultisampledTextureFormats: readonly GPUTextureFormat[] = [ + 'rgba16float', + 'r32float', +] as const; + +export function isMultisampledTextureFormat( + format: GPUTextureFormat, + isCompatibilityMode: boolean +): boolean { + if (isCompatibilityMode) { + if (kCompatModeUnsupportedMultisampledTextureFormats.indexOf(format) >= 0) { + return false; + } + } return kAllTextureFormatInfo[format].multisample; } diff --git a/src/webgpu/gpu_test.ts b/src/webgpu/gpu_test.ts index 149d57f85ba..45d6d407082 100644 --- a/src/webgpu/gpu_test.ts +++ b/src/webgpu/gpu_test.ts @@ -290,21 +290,10 @@ export class GPUTestSubcaseBatchState extends SubcaseBatchState { } skipIfMultisampleNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) { - if (this.isCompatibility) { - for (const format of formats) { - if (format === undefined) continue; - if (format === 'rgba16float' || is32Float(format)) { - this.skip( - `texture format '${format} is not guaranteed to be multisampled support in compat mode` - ); - } - } - } - for (const format of formats) { if (format === undefined) continue; - if (!isMultisampledTextureFormat(format)) { - this.skip(`texture format '${format} is not supported to be multisampled`); + if (!isMultisampledTextureFormat(format, this.isCompatibility)) { + this.skip(`texture format '${format}' is not supported to be multisampled`); } } } @@ -585,21 +574,10 @@ export class GPUTestBase extends Fixture { } skipIfMultisampleNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) { - if (this.isCompatibility) { - for (const format of formats) { - if (format === undefined) continue; - if (format === 'rgba16float' || is32Float(format)) { - this.skip( - `texture format '${format} is not guaranteed to be multisampled support in compat mode` - ); - } - } - } - for (const format of formats) { if (format === undefined) continue; - if (!isMultisampledTextureFormat(format)) { - this.skip(`texture format '${format} is not supported to be multisampled`); + if (!isMultisampledTextureFormat(format, this.isCompatibility)) { + this.skip(`texture format '${format}' is not supported to be multisampled`); } } } diff --git a/src/webgpu/shader/execution/expression/call/builtin/textureDimensions.spec.ts b/src/webgpu/shader/execution/expression/call/builtin/textureDimensions.spec.ts index cebf3a4dafb..c28c8a94f36 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/textureDimensions.spec.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/textureDimensions.spec.ts @@ -300,6 +300,11 @@ Parameters: .beforeAllSubcases(t => { const info = kTextureFormatInfo[t.params.format]; t.skipIfTextureFormatNotSupported(t.params.format); + if (t.params.samples > 1) { + // multisampled texture requires GPUTextureUsage.RENDER_ATTACHMENT usage + t.skipIfMultisampleNotSupportedForFormat(t.params.format); + t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format); + } t.selectDeviceOrSkipTestCase(info.feature); }) .fn(t => { diff --git a/src/webgpu/shader/execution/expression/call/builtin/textureLoad.spec.ts b/src/webgpu/shader/execution/expression/call/builtin/textureLoad.spec.ts index abbd55a41c2..3d02a52e34f 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/textureLoad.spec.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/textureLoad.spec.ts @@ -19,7 +19,6 @@ If an out of bounds access occurs, the built-in function returns one of: import { makeTestGroup } from '../../../../../../common/framework/test_group.js'; import { - canUseAsRenderTarget, isCompressedFloatTextureFormat, isDepthTextureFormat, isMultisampledTextureFormat, @@ -360,7 +359,7 @@ Parameters: 'texture_depth_multisampled_2d', ] as const) .combine('format', kAllTextureFormats) - .filter(t => isMultisampledTextureFormat(t.format)) + .filter(t => isMultisampledTextureFormat(t.format, false)) .filter(t => !isStencilTextureFormat(t.format)) // Filter out texture_depth_multisampled_2d with non-depth formats .filter( @@ -373,10 +372,11 @@ Parameters: .combine('S', ['i32', 'u32'] as const) ) .beforeAllSubcases(t => { - const { format } = t.params; + const { format, texture_type } = t.params; t.skipIfTextureFormatNotSupported(format); - t.skipIfTextureLoadNotSupportedForTextureType(t.params.texture_type); - t.selectDeviceForTextureFormatOrSkipTestCase(t.params.format); + t.skipIfTextureLoadNotSupportedForTextureType(texture_type); + t.skipIfMultisampleNotSupportedForFormat(format); + t.selectDeviceForTextureFormatOrSkipTestCase(format); }) .fn(async t => { const { texture_type, format, stage, samplePoints, C, S } = t.params; @@ -385,10 +385,7 @@ Parameters: const descriptor: GPUTextureDescriptor = { format, size: [8, 8], - usage: - GPUTextureUsage.COPY_DST | - GPUTextureUsage.TEXTURE_BINDING | - GPUTextureUsage.RENDER_ATTACHMENT, + usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING, sampleCount, }; const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor); @@ -627,10 +624,10 @@ Parameters: ] as const) ) .beforeAllSubcases(t => { - const { format } = t.params; + const { format, texture_type } = t.params; t.skipIfTextureFormatNotSupported(format); - t.skipIfTextureLoadNotSupportedForTextureType(t.params.texture_type); - t.selectDeviceForTextureFormatOrSkipTestCase(t.params.format); + t.skipIfTextureLoadNotSupportedForTextureType(texture_type); + t.selectDeviceForTextureFormatOrSkipTestCase(format); }) .fn(async t => { const { texture_type, format, stage, samplePoints, C, A, L } = t.params; @@ -640,10 +637,7 @@ Parameters: const descriptor: GPUTextureDescriptor = { format, size, - usage: - GPUTextureUsage.COPY_DST | - GPUTextureUsage.TEXTURE_BINDING | - (canUseAsRenderTarget(format) ? GPUTextureUsage.RENDER_ATTACHMENT : 0), + usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING, mipLevelCount: maxMipLevelCount({ size }), }; const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor); diff --git a/src/webgpu/shader/execution/expression/call/builtin/texture_utils.spec.ts b/src/webgpu/shader/execution/expression/call/builtin/texture_utils.spec.ts index 3923e7d3909..6f4bf2a59cb 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/texture_utils.spec.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/texture_utils.spec.ts @@ -90,11 +90,13 @@ g.test('readTextureToTexelViews') .unless( t => t.sampleCount > 1 && - (!isMultisampledTextureFormat(t.srcFormat) || t.viewDimension !== '2d') + (!isMultisampledTextureFormat(t.srcFormat, false) || t.viewDimension !== '2d') ) ) .beforeAllSubcases(t => { t.skipIfTextureViewDimensionNotSupported(t.params.viewDimension); + // recheck if multisampled is supported with compat mode flag + t.skipIfMultisampleNotSupportedForFormat(t.params.srcFormat); }) .fn(async t => { const { srcFormat, texelViewFormat, viewDimension, sampleCount } = t.params;