From a7274c9035492494fe2db16131463fb6dd2cf0a6 Mon Sep 17 00:00:00 2001 From: Greggman Date: Tue, 10 Dec 2024 18:13:13 -0800 Subject: [PATCH] Move MaxLimitsTest to MaxLimitTestMixin (#4085) I wanted to use MaxLimitsTest with resource_compatibility.spec.ts but that file's tests are based on `CreateRenderPipelineValidationTest` which itself is based on `ValidationTest` and so would force making `ValidationTest` be based on `MaxLimitsTest`. I actually think thats a good idea. The default should be max limits. But, it breaks too many things. So, MaxLimitsTest a mixin. --- .../api/operation/rendering/draw.spec.ts | 4 +-- .../sampling/sampler_texture.spec.ts | 4 +-- .../resource_compatibility.spec.ts | 2 +- src/webgpu/gpu_test.ts | 29 +++++++++++++------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/webgpu/api/operation/rendering/draw.spec.ts b/src/webgpu/api/operation/rendering/draw.spec.ts index 262a96aaa7a0..b5df5297795a 100644 --- a/src/webgpu/api/operation/rendering/draw.spec.ts +++ b/src/webgpu/api/operation/rendering/draw.spec.ts @@ -11,10 +11,10 @@ import { TypedArrayBufferView, TypedArrayBufferViewConstructor, } from '../../../../common/util/util.js'; -import { MaxLimitsTest, TextureTestMixin } from '../../../gpu_test.js'; +import { GPUTest, MaxLimitsTestMixin, TextureTestMixin } from '../../../gpu_test.js'; import { PerPixelComparison } from '../../../util/texture/texture_ok.js'; -class DrawTest extends TextureTestMixin(MaxLimitsTest) { +class DrawTest extends TextureTestMixin(MaxLimitsTestMixin(GPUTest)) { checkTriangleDraw(opts: { firstIndex: number | undefined; count: number; diff --git a/src/webgpu/api/operation/sampling/sampler_texture.spec.ts b/src/webgpu/api/operation/sampling/sampler_texture.spec.ts index 1304d2d81608..4a5f2dbd3b36 100644 --- a/src/webgpu/api/operation/sampling/sampler_texture.spec.ts +++ b/src/webgpu/api/operation/sampling/sampler_texture.spec.ts @@ -7,10 +7,10 @@ Tests samplers with textures. import { makeTestGroup } from '../../../../common/framework/test_group.js'; import { assert, range } from '../../../../common/util/util.js'; -import { MaxLimitsTest, TextureTestMixin } from '../../../gpu_test.js'; +import { GPUTest, MaxLimitsTestMixin, TextureTestMixin } from '../../../gpu_test.js'; import { TexelView } from '../../../util/texture/texel_view.js'; -export const g = makeTestGroup(TextureTestMixin(MaxLimitsTest)); +export const g = makeTestGroup(TextureTestMixin(MaxLimitsTestMixin(GPUTest))); g.test('sample_texture_combos') .desc( diff --git a/src/webgpu/api/validation/render_pipeline/resource_compatibility.spec.ts b/src/webgpu/api/validation/render_pipeline/resource_compatibility.spec.ts index 8c516ebb3b85..f14211482164 100644 --- a/src/webgpu/api/validation/render_pipeline/resource_compatibility.spec.ts +++ b/src/webgpu/api/validation/render_pipeline/resource_compatibility.spec.ts @@ -1,5 +1,5 @@ export const description = ` -Tests for resource compatibilty between pipeline layout and shader modules +Tests for resource compatibility between pipeline layout and shader modules `; import { makeTestGroup } from '../../../../common/framework/test_group.js'; diff --git a/src/webgpu/gpu_test.ts b/src/webgpu/gpu_test.ts index d6d6626109d4..ffc20f5f2c22 100644 --- a/src/webgpu/gpu_test.ts +++ b/src/webgpu/gpu_test.ts @@ -1333,16 +1333,27 @@ export class MaxLimitsGPUTestSubcaseBatchState extends GPUTestSubcaseBatchState } } -/** - * A Test that requests all the max limits from the adapter on the device. - */ -export class MaxLimitsTest extends GPUTest { - public static override MakeSharedState( - recorder: TestCaseRecorder, - params: TestParams - ): GPUTestSubcaseBatchState { - return new MaxLimitsGPUTestSubcaseBatchState(recorder, params); +export type MaxLimitsTestMixinType = { + // placeholder. Change to an interface if we need MaxLimits specific methods. +}; + +export function MaxLimitsTestMixin>( + Base: F +): FixtureClassWithMixin { + class MaxLimitsImpl + extends (Base as FixtureClassInterface) + implements MaxLimitsTestMixinType + { + // + public static override MakeSharedState( + recorder: TestCaseRecorder, + params: TestParams + ): GPUTestSubcaseBatchState { + return new MaxLimitsGPUTestSubcaseBatchState(recorder, params); + } } + + return MaxLimitsImpl as unknown as FixtureClassWithMixin; } /**