Skip to content

Commit

Permalink
Compat: Skip or expect error for rg32xxx texture formats (#3223)
Browse files Browse the repository at this point in the history
* Compat: Skip or expect error for rg32xxx texture formats

rg32float, rg32sint, rg32uint texture formats don't support
storage texture usage in compat mode.
  • Loading branch information
greggman authored Dec 13, 2023
1 parent 666950d commit 84fae1f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/webgpu/api/validation/createBindGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,10 @@ g.test('storage_texture,format')
.combine('storageTextureFormat', kStorageTextureFormats)
.combine('resourceFormat', kStorageTextureFormats)
)
.beforeAllSubcases(t => {
const { resourceFormat } = t.params;
t.skipIfTextureFormatNotUsableAsStorageTexture(resourceFormat);
})
.fn(t => {
const { storageTextureFormat, resourceFormat } = t.params;

Expand Down
1 change: 1 addition & 0 deletions src/webgpu/api/validation/createBindGroupLayout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ g.test('storage_texture,formats')
)
.beforeAllSubcases(t => {
t.selectDeviceForTextureFormatOrSkipTestCase(t.params.format);
t.skipIfTextureFormatNotUsableAsStorageTexture(t.params.format);
})
.fn(t => {
const { format, access } = t.params;
Expand Down
13 changes: 11 additions & 2 deletions src/webgpu/api/validation/createTexture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
filterFormatsByFeature,
viewCompatible,
textureDimensionAndFormatCompatible,
isTextureFormatUsableAsStorageFormat,
} from '../../format_info.js';
import { maxMipLevelCount } from '../../util/texture/base.js';

Expand Down Expand Up @@ -372,8 +373,12 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies')
usage,
};

const satisfyWithStorageUsageRequirement =
(usage & GPUConst.TextureUsage.STORAGE_BINDING) === 0 ||
isTextureFormatUsableAsStorageFormat(format, t.isCompatibility);

const success =
sampleCount === 1 ||
(sampleCount === 1 && satisfyWithStorageUsageRequirement) ||
(sampleCount === 4 &&
(dimension === '2d' || dimension === undefined) &&
kTextureFormatInfo[format].multisample &&
Expand Down Expand Up @@ -1058,7 +1063,11 @@ g.test('texture_usage')
// Note that we unconditionally test copy usages for all formats. We don't check copySrc/copyDst in kTextureFormatInfo in capability_info.js
// if (!info.copySrc && (usage & GPUTextureUsage.COPY_SRC) !== 0) success = false;
// if (!info.copyDst && (usage & GPUTextureUsage.COPY_DST) !== 0) success = false;
if (!info.color?.storage && (usage & GPUTextureUsage.STORAGE_BINDING) !== 0) success = false;
if (
(usage & GPUTextureUsage.STORAGE_BINDING) !== 0 &&
!isTextureFormatUsableAsStorageFormat(format, t.isCompatibility)
)
success = false;
if (
(!info.renderable || (appliedDimension !== '2d' && appliedDimension !== '3d')) &&
(usage & GPUTextureUsage.RENDER_ATTACHMENT) !== 0
Expand Down
15 changes: 15 additions & 0 deletions src/webgpu/format_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,21 @@ export function isCompressedTextureFormat(format: GPUTextureFormat) {
return format in kCompressedTextureFormatInfo;
}

export function isTextureFormatUsableAsStorageFormat(
format: GPUTextureFormat,
isCompatibilityMode: boolean
) {
if (isCompatibilityMode) {
switch (format) {
case 'rg32float':
case 'rg32sint':
case 'rg32uint':
return false;
}
}
return !!kTextureFormatInfo[format].color?.storage;
}

export function isEncodableTextureformat(format: GPUTextureFormat) {
return format in kEncodableTextureFormatInfo;
}
Expand Down
9 changes: 9 additions & 0 deletions src/webgpu/gpu_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
EncodableTextureFormat,
isCompressedTextureFormat,
ColorTextureFormat,
isTextureFormatUsableAsStorageFormat,
} from './format_info.js';
import { makeBufferWithContents } from './util/buffer.js';
import { checkElementsEqual, checkElementsBetween } from './util/check_contents.js';
Expand Down Expand Up @@ -251,6 +252,14 @@ export class GPUTestSubcaseBatchState extends SubcaseBatchState {
}
}
}

skipIfTextureFormatNotUsableAsStorageTexture(...formats: (GPUTextureFormat | undefined)[]) {
for (const format of formats) {
if (format && !isTextureFormatUsableAsStorageFormat(format, this.isCompatibility)) {
this.skip(`Texture with ${format} is not usable as a storage texture`);
}
}
}
}

/**
Expand Down

0 comments on commit 84fae1f

Please sign in to comment.