From e32e43356695c7b624c58a3fb9c6cb0f886714fc Mon Sep 17 00:00:00 2001 From: Shrek Shao Date: Tue, 28 Jan 2025 13:44:21 -0800 Subject: [PATCH] fix review 2 --- .../api/operation/texture_view/write.spec.ts | 5 +- .../api/validation/createTexture.spec.ts | 5 +- .../render_pass_descriptor.spec.ts | 3 +- .../api/validation/texture/destroy.spec.ts | 5 +- src/webgpu/gpu_test.ts | 46 ++++++------------- .../call/builtin/textureDimensions.spec.ts | 3 +- .../call/builtin/textureLoad.spec.ts | 4 +- .../call/builtin/texture_utils.spec.ts | 2 +- 8 files changed, 21 insertions(+), 52 deletions(-) diff --git a/src/webgpu/api/operation/texture_view/write.spec.ts b/src/webgpu/api/operation/texture_view/write.spec.ts index 465216e036c..9de136080f0 100644 --- a/src/webgpu/api/operation/texture_view/write.spec.ts +++ b/src/webgpu/api/operation/texture_view/write.spec.ts @@ -350,14 +350,13 @@ TODO: Test rgb10a2uint when TexelRepresentation.numericRange is made per-compone // Still need to filter again for compat mode. t.skipIfTextureFormatNotUsableAsStorageTexture(format); if (sampleCount > 1) { - t.skipIfMultisampleNotSupportedForFormat(format); + t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(format); } break; case 'render-pass-resolve': case 'render-pass-store': // Requires multisample in `writeTextureAndGetExpectedTexelView` - t.skipIfMultisampleNotSupportedForFormat(format); - t.selectDeviceForRenderableColorFormatOrSkipTestCase(format); + t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(format); break; } }) diff --git a/src/webgpu/api/validation/createTexture.spec.ts b/src/webgpu/api/validation/createTexture.spec.ts index 52cbda19f38..958faae4009 100644 --- a/src/webgpu/api/validation/createTexture.spec.ts +++ b/src/webgpu/api/validation/createTexture.spec.ts @@ -365,10 +365,6 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies') const { dimension, sampleCount, format, mipLevelCount, arrayLayerCount, usage } = t.params; const { blockWidth, blockHeight } = kTextureFormatInfo[format]; - if (sampleCount > 1) { - t.skipIfMultisampleNotSupportedForFormat(format); - } - const size = dimension === '1d' ? [32 * blockWidth, 1 * blockHeight, 1] @@ -391,6 +387,7 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies') const success = (sampleCount === 1 && satisfyWithStorageUsageRequirement) || (sampleCount === 4 && + isMultisampledTextureFormat(format, t.isCompatibility) && (dimension === '2d' || dimension === undefined) && kTextureFormatInfo[format].multisample && mipLevelCount === 1 && diff --git a/src/webgpu/api/validation/render_pass/render_pass_descriptor.spec.ts b/src/webgpu/api/validation/render_pass/render_pass_descriptor.spec.ts index 3a563d70d97..468f719bdbf 100644 --- a/src/webgpu/api/validation/render_pass/render_pass_descriptor.spec.ts +++ b/src/webgpu/api/validation/render_pass/render_pass_descriptor.spec.ts @@ -1174,8 +1174,7 @@ g.test('resolveTarget,format_supports_resolve') .beforeAllSubcases(t => { const { format } = t.params; t.skipIfTextureFormatNotSupported(format); - t.skipIfMultisampleNotSupportedForFormat(format); - t.selectDeviceForRenderableColorFormatOrSkipTestCase(format); + t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(format); }) .fn(t => { const { format } = t.params; diff --git a/src/webgpu/api/validation/texture/destroy.spec.ts b/src/webgpu/api/validation/texture/destroy.spec.ts index 0522d9d94c4..a5173923122 100644 --- a/src/webgpu/api/validation/texture/destroy.spec.ts +++ b/src/webgpu/api/validation/texture/destroy.spec.ts @@ -43,7 +43,7 @@ g.test('invalid_texture') invalidTexture.destroy(); }); -const kColorTextureFormat: GPUTextureFormat = 'rgba32float'; +const kColorTextureFormat: GPUTextureFormat = 'rgba8unorm'; g.test('submit_a_destroyed_texture_as_attachment') .desc( @@ -66,9 +66,6 @@ that was destroyed {before, after} encoding finishes. 'destroyedAfterEncode', ] as const) ) - .beforeAllSubcases(t => { - t.selectDeviceForRenderableColorFormatOrSkipTestCase(kColorTextureFormat); - }) .fn(t => { const { colorTextureState, depthStencilTextureAspect, depthStencilTextureState } = t.params; diff --git a/src/webgpu/gpu_test.ts b/src/webgpu/gpu_test.ts index 45d6d407082..2c859ee9b26 100644 --- a/src/webgpu/gpu_test.ts +++ b/src/webgpu/gpu_test.ts @@ -289,31 +289,17 @@ export class GPUTestSubcaseBatchState extends SubcaseBatchState { } } - skipIfMultisampleNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) { + skipIfMultisampleNotSupportedForFormatOrSelectDevice( + ...formats: (GPUTextureFormat | undefined)[] + ) { for (const format of formats) { if (format === undefined) continue; if (!isMultisampledTextureFormat(format, this.isCompatibility)) { this.skip(`texture format '${format}' is not supported to be multisampled`); } - } - } - - skipIfColorRenderableNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) { - if (this.isCompatibility) { - for (const format of formats) { - if (format === undefined) continue; - if (is16Float(format) || is32Float(format)) { - this.skip( - `texture format '${format} is not guaranteed to be color renderable in compat mode` - ); - } - } - } - - for (const format of formats) { - if (format === undefined) continue; - if (!kTextureFormatInfo[format].color) { - this.skip(`texture format '${format} is not color renderable`); + // float16 and float32 format need to be color renderable first to support multisampled in compat mode + if (is16Float(format) || is32Float(format)) { + this.selectDeviceForRenderableColorFormatOrSkipTestCase(format); } } } @@ -573,23 +559,17 @@ export class GPUTestBase extends Fixture { } } - skipIfMultisampleNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) { - for (const format of formats) { - if (format === undefined) continue; - if (!isMultisampledTextureFormat(format, this.isCompatibility)) { - this.skip(`texture format '${format}' is not supported to be multisampled`); - } - } - } - skipIfColorRenderableNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) { if (this.isCompatibility) { + const is16FloatRenderable = this.device.features.has('float16-renderable'); + const is32FloatRenderable = this.device.features.has('float32-renderable'); for (const format of formats) { if (format === undefined) continue; - if (is16Float(format) || is32Float(format)) { - this.skip( - `texture format '${format} is not guaranteed to be color renderable in compat mode` - ); + if ( + (is16Float(format) && !is16FloatRenderable) || + (is32Float(format) && !is32FloatRenderable) + ) { + this.skip(`texture format '${format} is not color renderable in compat mode`); } } } 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 c28c8a94f36..1f26b0ee275 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/textureDimensions.spec.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/textureDimensions.spec.ts @@ -302,8 +302,7 @@ Parameters: 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.skipIfMultisampleNotSupportedForFormatOrSelectDevice(t.params.format); } t.selectDeviceOrSkipTestCase(info.feature); }) 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 f20abd96013..6355d2c979a 100644 --- a/src/webgpu/shader/execution/expression/call/builtin/textureLoad.spec.ts +++ b/src/webgpu/shader/execution/expression/call/builtin/textureLoad.spec.ts @@ -375,9 +375,7 @@ Parameters: const { format, texture_type } = t.params; t.skipIfTextureFormatNotSupported(format); t.skipIfTextureLoadNotSupportedForTextureType(texture_type); - t.skipIfMultisampleNotSupportedForFormat(format); - t.selectDeviceForRenderableColorFormatOrSkipTestCase(format); - t.selectDeviceForTextureFormatOrSkipTestCase(format); + t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(format); }) .fn(async t => { const { texture_type, format, stage, samplePoints, C, S } = t.params; 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 6f4bf2a59cb..e2eed0e4bba 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 @@ -96,7 +96,7 @@ g.test('readTextureToTexelViews') .beforeAllSubcases(t => { t.skipIfTextureViewDimensionNotSupported(t.params.viewDimension); // recheck if multisampled is supported with compat mode flag - t.skipIfMultisampleNotSupportedForFormat(t.params.srcFormat); + t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(t.params.srcFormat); }) .fn(async t => { const { srcFormat, texelViewFormat, viewDimension, sampleCount } = t.params;