Skip to content

Commit

Permalink
Refactor createBindGroup validation test for texture formats (gpuweb#…
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman authored Feb 21, 2025
1 parent 6090e09 commit 1245e3f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
21 changes: 8 additions & 13 deletions src/webgpu/api/validation/createBindGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import {
texBindingTypeInfo,
} from '../../capability_info.js';
import { GPUConst } from '../../constants.js';
import { kAllTextureFormats, kTextureFormatInfo } from '../../format_info.js';
import { kResourceStates, MaxLimitsTestMixin } from '../../gpu_test.js';
import { kPossibleStorageTextureFormats } from '../../format_info.js';
import { kResourceStates } from '../../gpu_test.js';
import { getTextureDimensionFromView } from '../../util/texture/base.js';

import { ValidationTest } from './validation_test.js';
import { AllFeaturesMaxLimitsValidationTest } from './validation_test.js';

const kTestFormat: GPUTextureFormat = 'r32float';

Expand All @@ -37,7 +37,7 @@ function clone<T extends GPUTextureDescriptor>(descriptor: T): T {
}

function skipIfResourceNotSupportedInStages(
t: ValidationTest,
t: AllFeaturesMaxLimitsValidationTest,
entry: BGLEntry,
visibility: number
) {
Expand Down Expand Up @@ -69,9 +69,7 @@ function skipIfResourceNotSupportedInStages(
}
}

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

const kStorageTextureFormats = kAllTextureFormats.filter(f => kTextureFormatInfo[f].color?.storage);
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);

g.test('binding_count_mismatch')
.desc('Test that the number of entries must match the number of entries in the BindGroupLayout.')
Expand Down Expand Up @@ -871,15 +869,12 @@ g.test('storage_texture,format')
)
.params(u =>
u //
.combine('storageTextureFormat', kStorageTextureFormats)
.combine('resourceFormat', kStorageTextureFormats)
.combine('storageTextureFormat', kPossibleStorageTextureFormats)
.combine('resourceFormat', kPossibleStorageTextureFormats)
)
.beforeAllSubcases(t => {
const { storageTextureFormat, resourceFormat } = t.params;
t.skipIfTextureFormatNotUsableAsStorageTextureDeprecated(storageTextureFormat, resourceFormat);
})
.fn(t => {
const { storageTextureFormat, resourceFormat } = t.params;
t.skipIfTextureFormatNotUsableAsStorageTexture(storageTextureFormat, resourceFormat);

const bindGroupLayout = t.device.createBindGroupLayout({
entries: [
Expand Down
5 changes: 0 additions & 5 deletions src/webgpu/api/validation/validation_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,6 @@ class ValidationTestImpl extends GPUTest {
}
}

/**
* Deprecated base fixture for WebGPU validation tests
* @deprecated use AllFeaturesMaxLimitsValidationTest or UniqueFeaturesAndLimitsValidationTest
*/

/**
* Base fixture for WebGPU validation tests.
*/
Expand Down
9 changes: 8 additions & 1 deletion src/webgpu/format_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ const kASTCTextureFormatInfo = formatTableWithDefaults({
},
} as const);

// Definitions for use locally. To access the table entries, use `kTextureFormatInfo`.
// Definitions for use locally.

// MAINTENANCE_TODO: Consider generating the exports below programmatically by filtering the big list, instead
// of using these local constants? Requires some type magic though.
Expand Down Expand Up @@ -1544,6 +1544,13 @@ const kTextureFormatInfo_TypeCheck: {
readonly [F in GPUTextureFormat]: TextureFormatInfo_TypeCheck;
} = kTextureFormatInfo;

// Texture formats that may possibly be used as a storage texture.
// Some may require certain features to be enabled.
export const kPossibleStorageTextureFormats = [
...kAllTextureFormats.filter(f => kTextureFormatInfo[f].color?.storage),
'bgra8unorm',
] as const;

/** Valid GPUTextureFormats for `copyExternalImageToTexture`, by spec. */
export const kValidTextureFormatsForCopyE2T = [
'r8unorm',
Expand Down

0 comments on commit 1245e3f

Please sign in to comment.