Skip to content

Commit

Permalink
Compat: fix float16(32)-renderable tests (shader,execution) (#4160)
Browse files Browse the repository at this point in the history
* Compat: fix float16(32)-renderable tests (shader,execution)

* fix GPUTextureUsage.RENDER_ATTACHMENT and multisample
  • Loading branch information
shrekshao authored Jan 25, 2025
1 parent 84c6cd8 commit a9a0106
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 44 deletions.
15 changes: 14 additions & 1 deletion src/webgpu/format_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,20 @@ export function isSintOrUintFormat(format: GPUTextureFormat) {
/**
* Returns true of format can be multisampled.
*/
export function isMultisampledTextureFormat(format: GPUTextureFormat): boolean {
export const kCompatModeUnsupportedMultisampledTextureFormats: readonly GPUTextureFormat[] = [
'rgba16float',
'r32float',
] as const;

export function isMultisampledTextureFormat(
format: GPUTextureFormat,
isCompatibilityMode: boolean
): boolean {
if (isCompatibilityMode) {
if (kCompatModeUnsupportedMultisampledTextureFormats.indexOf(format) >= 0) {
return false;
}
}
return kAllTextureFormatInfo[format].multisample;
}

Expand Down
30 changes: 4 additions & 26 deletions src/webgpu/gpu_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,21 +290,10 @@ export class GPUTestSubcaseBatchState extends SubcaseBatchState {
}

skipIfMultisampleNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) {
if (this.isCompatibility) {
for (const format of formats) {
if (format === undefined) continue;
if (format === 'rgba16float' || is32Float(format)) {
this.skip(
`texture format '${format} is not guaranteed to be multisampled support in compat mode`
);
}
}
}

for (const format of formats) {
if (format === undefined) continue;
if (!isMultisampledTextureFormat(format)) {
this.skip(`texture format '${format} is not supported to be multisampled`);
if (!isMultisampledTextureFormat(format, this.isCompatibility)) {
this.skip(`texture format '${format}' is not supported to be multisampled`);
}
}
}
Expand Down Expand Up @@ -585,21 +574,10 @@ export class GPUTestBase extends Fixture<GPUTestSubcaseBatchState> {
}

skipIfMultisampleNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) {
if (this.isCompatibility) {
for (const format of formats) {
if (format === undefined) continue;
if (format === 'rgba16float' || is32Float(format)) {
this.skip(
`texture format '${format} is not guaranteed to be multisampled support in compat mode`
);
}
}
}

for (const format of formats) {
if (format === undefined) continue;
if (!isMultisampledTextureFormat(format)) {
this.skip(`texture format '${format} is not supported to be multisampled`);
if (!isMultisampledTextureFormat(format, this.isCompatibility)) {
this.skip(`texture format '${format}' is not supported to be multisampled`);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ Parameters:
.beforeAllSubcases(t => {
const info = kTextureFormatInfo[t.params.format];
t.skipIfTextureFormatNotSupported(t.params.format);
if (t.params.samples > 1) {
// multisampled texture requires GPUTextureUsage.RENDER_ATTACHMENT usage
t.skipIfMultisampleNotSupportedForFormat(t.params.format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
}
t.selectDeviceOrSkipTestCase(info.feature);
})
.fn(t => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ If an out of bounds access occurs, the built-in function returns one of:

import { makeTestGroup } from '../../../../../../common/framework/test_group.js';
import {
canUseAsRenderTarget,
isCompressedFloatTextureFormat,
isDepthTextureFormat,
isMultisampledTextureFormat,
Expand Down Expand Up @@ -360,7 +359,7 @@ Parameters:
'texture_depth_multisampled_2d',
] as const)
.combine('format', kAllTextureFormats)
.filter(t => isMultisampledTextureFormat(t.format))
.filter(t => isMultisampledTextureFormat(t.format, false))
.filter(t => !isStencilTextureFormat(t.format))
// Filter out texture_depth_multisampled_2d with non-depth formats
.filter(
Expand All @@ -373,10 +372,11 @@ Parameters:
.combine('S', ['i32', 'u32'] as const)
)
.beforeAllSubcases(t => {
const { format } = t.params;
const { format, texture_type } = t.params;
t.skipIfTextureFormatNotSupported(format);
t.skipIfTextureLoadNotSupportedForTextureType(t.params.texture_type);
t.selectDeviceForTextureFormatOrSkipTestCase(t.params.format);
t.skipIfTextureLoadNotSupportedForTextureType(texture_type);
t.skipIfMultisampleNotSupportedForFormat(format);
t.selectDeviceForTextureFormatOrSkipTestCase(format);
})
.fn(async t => {
const { texture_type, format, stage, samplePoints, C, S } = t.params;
Expand All @@ -385,10 +385,7 @@ Parameters:
const descriptor: GPUTextureDescriptor = {
format,
size: [8, 8],
usage:
GPUTextureUsage.COPY_DST |
GPUTextureUsage.TEXTURE_BINDING |
GPUTextureUsage.RENDER_ATTACHMENT,
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
sampleCount,
};
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor);
Expand Down Expand Up @@ -627,10 +624,10 @@ Parameters:
] as const)
)
.beforeAllSubcases(t => {
const { format } = t.params;
const { format, texture_type } = t.params;
t.skipIfTextureFormatNotSupported(format);
t.skipIfTextureLoadNotSupportedForTextureType(t.params.texture_type);
t.selectDeviceForTextureFormatOrSkipTestCase(t.params.format);
t.skipIfTextureLoadNotSupportedForTextureType(texture_type);
t.selectDeviceForTextureFormatOrSkipTestCase(format);
})
.fn(async t => {
const { texture_type, format, stage, samplePoints, C, A, L } = t.params;
Expand All @@ -640,10 +637,7 @@ Parameters:
const descriptor: GPUTextureDescriptor = {
format,
size,
usage:
GPUTextureUsage.COPY_DST |
GPUTextureUsage.TEXTURE_BINDING |
(canUseAsRenderTarget(format) ? GPUTextureUsage.RENDER_ATTACHMENT : 0),
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
mipLevelCount: maxMipLevelCount({ size }),
};
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ g.test('readTextureToTexelViews')
.unless(
t =>
t.sampleCount > 1 &&
(!isMultisampledTextureFormat(t.srcFormat) || t.viewDimension !== '2d')
(!isMultisampledTextureFormat(t.srcFormat, false) || t.viewDimension !== '2d')
)
)
.beforeAllSubcases(t => {
t.skipIfTextureViewDimensionNotSupported(t.params.viewDimension);
// recheck if multisampled is supported with compat mode flag
t.skipIfMultisampleNotSupportedForFormat(t.params.srcFormat);
})
.fn(async t => {
const { srcFormat, texelViewFormat, viewDimension, sampleCount } = t.params;
Expand Down

0 comments on commit a9a0106

Please sign in to comment.