Skip to content

Commit acdfa4a

Browse files
committed
Refactor createBindGroup validation test for texture formats
Issue gpuweb#4181
1 parent 5d70ace commit acdfa4a

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

src/webgpu/api/validation/createBindGroup.spec.ts

+8-13
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import {
2424
texBindingTypeInfo,
2525
} from '../../capability_info.js';
2626
import { GPUConst } from '../../constants.js';
27-
import { kAllTextureFormats, kTextureFormatInfo } from '../../format_info.js';
28-
import { kResourceStates, MaxLimitsTestMixin } from '../../gpu_test.js';
27+
import { kPossibleStorageTextureFormats } from '../../format_info.js';
28+
import { kResourceStates } from '../../gpu_test.js';
2929
import { getTextureDimensionFromView } from '../../util/texture/base.js';
3030

31-
import { ValidationTest } from './validation_test.js';
31+
import { AllFeaturesMaxLimitsValidationTest } from './validation_test.js';
3232

3333
const kTestFormat: GPUTextureFormat = 'r32float';
3434

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

3939
function skipIfResourceNotSupportedInStages(
40-
t: ValidationTest,
40+
t: AllFeaturesMaxLimitsValidationTest,
4141
entry: BGLEntry,
4242
visibility: number
4343
) {
@@ -69,9 +69,7 @@ function skipIfResourceNotSupportedInStages(
6969
}
7070
}
7171

72-
export const g = makeTestGroup(MaxLimitsTestMixin(ValidationTest));
73-
74-
const kStorageTextureFormats = kAllTextureFormats.filter(f => kTextureFormatInfo[f].color?.storage);
72+
export const g = makeTestGroup(AllFeaturesMaxLimitsValidationTest);
7573

7674
g.test('binding_count_mismatch')
7775
.desc('Test that the number of entries must match the number of entries in the BindGroupLayout.')
@@ -871,15 +869,12 @@ g.test('storage_texture,format')
871869
)
872870
.params(u =>
873871
u //
874-
.combine('storageTextureFormat', kStorageTextureFormats)
875-
.combine('resourceFormat', kStorageTextureFormats)
872+
.combine('storageTextureFormat', kPossibleStorageTextureFormats)
873+
.combine('resourceFormat', kPossibleStorageTextureFormats)
876874
)
877-
.beforeAllSubcases(t => {
878-
const { storageTextureFormat, resourceFormat } = t.params;
879-
t.skipIfTextureFormatNotUsableAsStorageTextureDeprecated(storageTextureFormat, resourceFormat);
880-
})
881875
.fn(t => {
882876
const { storageTextureFormat, resourceFormat } = t.params;
877+
t.skipIfTextureFormatNotUsableAsStorageTexture(storageTextureFormat, resourceFormat);
883878

884879
const bindGroupLayout = t.device.createBindGroupLayout({
885880
entries: [

src/webgpu/api/validation/validation_test.ts

-5
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,6 @@ class ValidationTestImpl extends GPUTest {
436436
}
437437
}
438438

439-
/**
440-
* Deprecated base fixture for WebGPU validation tests
441-
* @deprecated use AllFeaturesMaxLimitsValidationTest or UniqueFeaturesAndLimitsValidationTest
442-
*/
443-
444439
/**
445440
* Base fixture for WebGPU validation tests.
446441
*/

src/webgpu/format_info.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ const kASTCTextureFormatInfo = formatTableWithDefaults({
13931393
},
13941394
} as const);
13951395

1396-
// Definitions for use locally. To access the table entries, use `kTextureFormatInfo`.
1396+
// Definitions for use locally.
13971397

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

1547+
// Texture formats that may possibly be used as a storage texture.
1548+
// Some may require certain features to be enabled.
1549+
export const kPossibleStorageTextureFormats = [
1550+
...kAllTextureFormats.filter(f => kTextureFormatInfo[f].color?.storage),
1551+
'bgra8unorm',
1552+
] as const;
1553+
15471554
/** Valid GPUTextureFormats for `copyExternalImageToTexture`, by spec. */
15481555
export const kValidTextureFormatsForCopyE2T = [
15491556
'r8unorm',

0 commit comments

Comments
 (0)