Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor api/validation/resource_usages/* #4281

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Buffer Usages Validation Tests in Render Pass and Compute Pass.

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { assert, unreachable } from '../../../../../common/util/util.js';
import { GPUTestBase, MaxLimitsTestMixin } from '../../../../gpu_test.js';
import { ValidationTest } from '../../validation_test.js';
import { GPUTestBase } from '../../../../gpu_test.js';
import { AllFeaturesMaxLimitsValidationTest } from '../../validation_test.js';

const kBoundBufferSize = 256;

Expand All @@ -32,7 +32,7 @@ function resourceVisibilityToVisibility(resourceVisibility: 'compute' | 'fragmen
return resourceVisibility === 'compute' ? GPUShaderStage.COMPUTE : GPUShaderStage.FRAGMENT;
}

export class BufferResourceUsageTest extends ValidationTest {
export class BufferResourceUsageTest extends AllFeaturesMaxLimitsValidationTest {
createBindGroupLayoutForTest(
type: 'uniform' | 'storage' | 'read-only-storage',
resourceVisibility: 'compute' | 'fragment'
Expand Down Expand Up @@ -180,7 +180,7 @@ export function skipIfStorageBuffersUsedAndNotAvailableInStages(
}
}

export const g = makeTestGroup(MaxLimitsTestMixin(BufferResourceUsageTest));
export const g = makeTestGroup(BufferResourceUsageTest);

g.test('subresources,buffer_usage_in_one_compute_pass_with_no_dispatch')
.desc(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Test other buffer usage validation rules that are not tests in ./in_pass_encoder

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { unreachable } from '../../../../../common/util/util.js';
import { MaxLimitsTestMixin } from '../../../../gpu_test.js';

import {
BufferUsage,
Expand All @@ -13,7 +12,7 @@ import {
skipIfStorageBuffersUsedAndNotAvailableInStages,
} from './in_pass_encoder.spec.js';

export const g = makeTestGroup(MaxLimitsTestMixin(BufferResourceUsageTest));
export const g = makeTestGroup(BufferResourceUsageTest);

const kBufferSize = 256;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import { GPUConst } from '../../../../constants.js';
import {
kDepthStencilFormats,
kDepthStencilFormatResolvedAspect,
kTextureFormatInfo,
isMultisampledTextureFormatDeprecated,
isStencilTextureFormat,
isDepthTextureFormat,
} from '../../../../format_info.js';
import { MaxLimitsTestMixin } from '../../../../gpu_test.js';
import { ValidationTest } from '../../validation_test.js';
import { AllFeaturesMaxLimitsValidationTest } from '../../validation_test.js';

type TextureBindingType =
| 'sampled-texture'
Expand All @@ -30,7 +29,7 @@ const kTextureBindingTypes = [
] as const;

const SIZE = 32;
class TextureUsageTracking extends ValidationTest {
class TextureUsageTracking extends AllFeaturesMaxLimitsValidationTest {
createTestTexture(
options: {
width?: number;
Expand Down Expand Up @@ -268,7 +267,7 @@ class TextureUsageTracking extends ValidationTest {
}
}

export const g = makeTestGroup(MaxLimitsTestMixin(TextureUsageTracking));
export const g = makeTestGroup(TextureUsageTracking);

const BASE_LEVEL = 1;
const TOTAL_LEVELS = 6;
Expand Down Expand Up @@ -680,13 +679,13 @@ g.test('subresources_and_binding_types_combination_for_aspect')
.combine('aspect1', ['all', 'depth-only', 'stencil-only'] as const)
.unless(
p =>
(p.aspect0 === 'stencil-only' && !kTextureFormatInfo[p.format].stencil) ||
(p.aspect1 === 'stencil-only' && !kTextureFormatInfo[p.format].stencil)
(p.aspect0 === 'stencil-only' && !isStencilTextureFormat(p.format)) ||
(p.aspect1 === 'stencil-only' && !isStencilTextureFormat(p.format))
)
.unless(
p =>
(p.aspect0 === 'depth-only' && !kTextureFormatInfo[p.format].depth) ||
(p.aspect1 === 'depth-only' && !kTextureFormatInfo[p.format].depth)
(p.aspect0 === 'depth-only' && !isDepthTextureFormat(p.format)) ||
(p.aspect1 === 'depth-only' && !isDepthTextureFormat(p.format))
)
.combineWithParams([
{
Expand All @@ -703,8 +702,8 @@ g.test('subresources_and_binding_types_combination_for_aspect')
.unless(
// Can't sample a multiplanar texture without selecting an aspect.
p =>
!!kTextureFormatInfo[p.format].depth &&
!!kTextureFormatInfo[p.format].stencil &&
isDepthTextureFormat(p.format) &&
isStencilTextureFormat(p.format) &&
((p.aspect0 === 'all' && p.type0 === 'sampled-texture') ||
(p.aspect1 === 'all' && p.type1 === 'sampled-texture'))
)
Expand All @@ -724,15 +723,11 @@ g.test('subresources_and_binding_types_combination_for_aspect')
// Depth-stencil attachment views must encompass all aspects of the texture. Invalid
// cases are for depth-stencil textures when the aspect is not 'all'.
p.type1 === 'render-target' &&
!!kTextureFormatInfo[p.format].depth &&
!!kTextureFormatInfo[p.format].stencil &&
isDepthTextureFormat(p.format) &&
isStencilTextureFormat(p.format) &&
p.aspect1 !== 'all'
)
)
.beforeAllSubcases(t => {
const { format } = t.params;
t.selectDeviceOrSkipTestCase(kTextureFormatInfo[format].feature);
})
.fn(t => {
const {
compute,
Expand All @@ -749,6 +744,7 @@ g.test('subresources_and_binding_types_combination_for_aspect')
_usageSuccess,
} = t.params;

t.skipIfTextureFormatNotSupported(format);
t.skipIf(t.isCompatibility, 'sub ranges of layers are not supported in compat mode');

const texture = t.createTestTexture({
Expand All @@ -775,8 +771,8 @@ g.test('subresources_and_binding_types_combination_for_aspect')
aspect: aspect1,
});
const view1ResolvedFormat = kDepthStencilFormatResolvedAspect[format][aspect1]!;
const view1HasDepth = kTextureFormatInfo[view1ResolvedFormat].depth;
const view1HasStencil = kTextureFormatInfo[view1ResolvedFormat].stencil;
const view1HasDepth = isDepthTextureFormat(view1ResolvedFormat);
const view1HasStencil = isStencilTextureFormat(view1ResolvedFormat);

const encoder = t.device.createCommandEncoder();
// Color attachment's size should match depth/stencil attachment's size. Note that if
Expand Down Expand Up @@ -813,8 +809,8 @@ g.test('subresources_and_binding_types_combination_for_aspect')
case 'stencil-only':
return 'uint';
case 'all':
assert(kTextureFormatInfo[format].depth !== kTextureFormatInfo[format].stencil);
if (kTextureFormatInfo[format].stencil) {
assert(isDepthTextureFormat(format) !== isStencilTextureFormat(format));
if (isStencilTextureFormat(format)) {
return 'uint';
}
return 'depth';
Expand Down Expand Up @@ -1157,9 +1153,9 @@ g.test('bindings_in_bundle')

t.skipIfNeedStorageTexturesByResourceTypeAndNoStorageTextures(type0, GPUShaderStage.FRAGMENT);
t.skipIfNeedStorageTexturesByResourceTypeAndNoStorageTextures(type1, GPUShaderStage.FRAGMENT);
t.skipIf(
_sampleCount! > 1 && !isMultisampledTextureFormatDeprecated('r32float', t.isCompatibility)
);
if (_sampleCount! > 1) {
t.skipIfTextureFormatNotMultisampled('r32float');
}

// Two bindings are attached to the same texture view.
const usage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Texture Usages Validation Tests in Same or Different Render Pass Encoders.

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { assert, unreachable } from '../../../../../common/util/util.js';
import { MaxLimitsTestMixin } from '../../../../gpu_test.js';
import { ValidationTest } from '../../validation_test.js';
import { AllFeaturesMaxLimitsValidationTest } from '../../validation_test.js';

export type TextureBindingType =
| 'sampled-texture'
Expand All @@ -22,7 +21,7 @@ export function IsReadOnlyTextureBindingType(t: TextureBindingType): boolean {
return t === 'sampled-texture' || t === 'readonly-storage-texture';
}

class F extends ValidationTest {
class F extends AllFeaturesMaxLimitsValidationTest {
getColorAttachment(
texture: GPUTexture,
textureViewDescriptor?: GPUTextureViewDescriptor
Expand Down Expand Up @@ -93,7 +92,7 @@ class F extends ValidationTest {
}
}

export const g = makeTestGroup(MaxLimitsTestMixin(F));
export const g = makeTestGroup(F);

const kTextureSize = 16;
const kTextureLevels = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ Texture Usages Validation Tests on All Kinds of WebGPU Subresource Usage Scopes.
import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { unreachable } from '../../../../../common/util/util.js';
import { kTextureUsages } from '../../../../capability_info.js';
import { MaxLimitsTestMixin } from '../../../../gpu_test.js';
import { ValidationTest } from '../../validation_test.js';
import { AllFeaturesMaxLimitsValidationTest } from '../../validation_test.js';
import {
TextureBindingType,
kTextureBindingTypes,
IsReadOnlyTextureBindingType,
} from '../texture/in_render_common.spec.js';

function skipIfStorageTexturesUsedAndNotAvailableInFragmentStage(
t: ValidationTest,
t: AllFeaturesMaxLimitsValidationTest,
usage: (typeof kTextureBindingTypes)[number] | 'copy-src' | 'copy-dst' | 'color-attachment',
numRequired: number
) {
Expand All @@ -28,7 +27,7 @@ function skipIfStorageTexturesUsedAndNotAvailableInFragmentStage(
);
}

class F extends ValidationTest {
class F extends AllFeaturesMaxLimitsValidationTest {
createBindGroupLayoutForTest(
textureUsage: TextureBindingType,
sampleType: 'unfilterable-float' | 'depth' | 'uint',
Expand Down Expand Up @@ -86,7 +85,7 @@ class F extends ValidationTest {
}
}

export const g = makeTestGroup(MaxLimitsTestMixin(F));
export const g = makeTestGroup(F);

const kTextureSize = 16;
const kTextureLayers = 3;
Expand Down