From 1f5e883dab0ad471445007988b4be3ac1353cfce Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Fri, 7 Mar 2025 18:58:26 -0800 Subject: [PATCH] Refactor api/validation/texture/* Issue #4178 Issue #4181 --- .../texture/bgra8unorm_storage.spec.ts | 11 ++++++--- .../api/validation/texture/destroy.spec.ts | 10 ++++---- .../texture/float32_filterable.spec.ts | 4 ++-- .../texture/rg11b10ufloat_renderable.spec.ts | 24 ++++++------------- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts b/src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts index 9a4834cdd124..32495e2ea076 100644 --- a/src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts +++ b/src/webgpu/api/validation/texture/bgra8unorm_storage.spec.ts @@ -7,9 +7,9 @@ import { assert } from '../../../../common/util/util.js'; import { kTextureUsages } from '../../../capability_info.js'; import { GPUConst } from '../../../constants.js'; import { kAllCanvasTypes, createCanvas } from '../../../util/create_elements.js'; -import { ValidationTest } from '../validation_test.js'; +import { UniqueFeaturesAndLimitsValidationTest } from '../validation_test.js'; -class BGRA8UnormStorageValidationTests extends ValidationTest { +class BGRA8UnormStorageValidationTests extends UniqueFeaturesAndLimitsValidationTest { testCreateShaderModuleWithBGRA8UnormStorage( shaderType: 'fragment' | 'compute', success: boolean @@ -126,7 +126,12 @@ with 'bgra8unorm-storage' enabled. ` ) .beforeAllSubcases(t => { - t.selectDeviceOrSkipTestCase('bgra8unorm-storage'); + t.selectDeviceOrSkipTestCase({ + requiredFeatures: ['bgra8unorm-storage'], + requiredLimits: { + maxStorageTexturesInFragmentStage: 1, + }, + }); }) .params(u => u diff --git a/src/webgpu/api/validation/texture/destroy.spec.ts b/src/webgpu/api/validation/texture/destroy.spec.ts index a5173923122a..8b122b2636e6 100644 --- a/src/webgpu/api/validation/texture/destroy.spec.ts +++ b/src/webgpu/api/validation/texture/destroy.spec.ts @@ -4,10 +4,10 @@ Destroying a texture more than once is allowed. import { makeTestGroup } from '../../../../common/framework/test_group.js'; import { kTextureAspects } from '../../../capability_info.js'; -import { kTextureFormatInfo } from '../../../format_info.js'; -import { ValidationTest } from '../validation_test.js'; +import { isDepthTextureFormat, isStencilTextureFormat } from '../../../format_info.js'; +import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js'; -export const g = makeTestGroup(ValidationTest); +export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest); g.test('base') .desc(`Test that it is valid to destroy a texture.`) @@ -104,12 +104,12 @@ that was destroyed {before, after} encoding finishes. const depthStencilAttachment: GPURenderPassDepthStencilAttachment = { view: depthStencilTexture.createView({ aspect: depthStencilTextureAspect }), }; - if (kTextureFormatInfo[depthStencilTextureFormat].depth) { + if (isDepthTextureFormat(depthStencilTextureFormat)) { depthStencilAttachment.depthClearValue = 0; depthStencilAttachment.depthLoadOp = 'clear'; depthStencilAttachment.depthStoreOp = 'discard'; } - if (kTextureFormatInfo[depthStencilTextureFormat].stencil) { + if (isStencilTextureFormat(depthStencilTextureFormat)) { depthStencilAttachment.stencilClearValue = 0; depthStencilAttachment.stencilLoadOp = 'clear'; depthStencilAttachment.stencilStoreOp = 'discard'; diff --git a/src/webgpu/api/validation/texture/float32_filterable.spec.ts b/src/webgpu/api/validation/texture/float32_filterable.spec.ts index e075a9b10d7d..d941b26b009a 100644 --- a/src/webgpu/api/validation/texture/float32_filterable.spec.ts +++ b/src/webgpu/api/validation/texture/float32_filterable.spec.ts @@ -4,9 +4,9 @@ Tests for capabilities added by float32-filterable flag. import { makeTestGroup } from '../../../../common/framework/test_group.js'; import { kTextureSampleTypes } from '../../../capability_info.js'; -import { ValidationTest } from '../validation_test.js'; +import { UniqueFeaturesAndLimitsValidationTest } from '../validation_test.js'; -export const g = makeTestGroup(ValidationTest); +export const g = makeTestGroup(UniqueFeaturesAndLimitsValidationTest); const kFloat32Formats: GPUTextureFormat[] = ['r32float', 'rg32float', 'rgba32float']; diff --git a/src/webgpu/api/validation/texture/rg11b10ufloat_renderable.spec.ts b/src/webgpu/api/validation/texture/rg11b10ufloat_renderable.spec.ts index 531112a4de11..be3f8964cfbb 100644 --- a/src/webgpu/api/validation/texture/rg11b10ufloat_renderable.spec.ts +++ b/src/webgpu/api/validation/texture/rg11b10ufloat_renderable.spec.ts @@ -4,9 +4,9 @@ Tests for capabilities added by rg11b10ufloat-renderable flag. import { makeTestGroup } from '../../../../common/framework/test_group.js'; import { GPUConst } from '../../../constants.js'; -import { ValidationTest } from '../validation_test.js'; +import { AllFeaturesMaxLimitsValidationTest } from '../validation_test.js'; -export const g = makeTestGroup(ValidationTest); +export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest); g.test('create_texture') .desc( @@ -17,10 +17,8 @@ Note, the createTexture tests cover these validation cases where this feature is ` ) .params(u => u.combine('sampleCount', [1, 4])) - .beforeAllSubcases(t => { - t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable'); - }) .fn(t => { + t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable'); const { sampleCount } = t.params; const descriptor = { size: [1, 1, 1], @@ -38,10 +36,8 @@ Test that it is valid to begin render pass with rg11b10ufloat texture format iff rg11b10ufloat-renderable feature is enabled. Single sampled case. ` ) - .beforeAllSubcases(t => { - t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable'); - }) .fn(t => { + t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable'); const texture = t.createTextureTracked({ size: [1, 1, 1], format: 'rg11b10ufloat', @@ -70,10 +66,8 @@ Test that it is valid to begin render pass with rg11b10ufloat texture format iff rg11b10ufloat-renderable feature is enabled. MSAA and resolve case. ` ) - .beforeAllSubcases(t => { - t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable'); - }) .fn(t => { + t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable'); const renderTexture = t.createTextureTracked({ size: [1, 1, 1], format: 'rg11b10ufloat', @@ -109,10 +103,8 @@ Test that it is valid to begin render bundle encoder with rg11b10ufloat texture format iff rg11b10ufloat-renderable feature is enabled. ` ) - .beforeAllSubcases(t => { - t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable'); - }) .fn(t => { + t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable'); t.device.createRenderBundleEncoder({ colorFormats: ['rg11b10ufloat'], }); @@ -125,10 +117,8 @@ Test that it is valid to create render pipeline with rg11b10ufloat texture forma in descriptor.fragment.targets iff rg11b10ufloat-renderable feature is enabled. ` ) - .beforeAllSubcases(t => { - t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable'); - }) .fn(t => { + t.skipIfDeviceDoesNotHaveFeature('rg11b10ufloat-renderable'); t.device.createRenderPipeline({ layout: 'auto', vertex: {