Skip to content

Commit

Permalink
fix review 2
Browse files Browse the repository at this point in the history
  • Loading branch information
shrekshao committed Jan 28, 2025
1 parent 672c5d6 commit e32e433
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 52 deletions.
5 changes: 2 additions & 3 deletions src/webgpu/api/operation/texture_view/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,13 @@ TODO: Test rgb10a2uint when TexelRepresentation.numericRange is made per-compone
// Still need to filter again for compat mode.
t.skipIfTextureFormatNotUsableAsStorageTexture(format);
if (sampleCount > 1) {
t.skipIfMultisampleNotSupportedForFormat(format);
t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(format);
}
break;
case 'render-pass-resolve':
case 'render-pass-store':
// Requires multisample in `writeTextureAndGetExpectedTexelView`
t.skipIfMultisampleNotSupportedForFormat(format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(format);
break;
}
})
Expand Down
5 changes: 1 addition & 4 deletions src/webgpu/api/validation/createTexture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,6 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies')
const { dimension, sampleCount, format, mipLevelCount, arrayLayerCount, usage } = t.params;
const { blockWidth, blockHeight } = kTextureFormatInfo[format];

if (sampleCount > 1) {
t.skipIfMultisampleNotSupportedForFormat(format);
}

const size =
dimension === '1d'
? [32 * blockWidth, 1 * blockHeight, 1]
Expand All @@ -391,6 +387,7 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies')
const success =
(sampleCount === 1 && satisfyWithStorageUsageRequirement) ||
(sampleCount === 4 &&
isMultisampledTextureFormat(format, t.isCompatibility) &&
(dimension === '2d' || dimension === undefined) &&
kTextureFormatInfo[format].multisample &&
mipLevelCount === 1 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,7 @@ g.test('resolveTarget,format_supports_resolve')
.beforeAllSubcases(t => {
const { format } = t.params;
t.skipIfTextureFormatNotSupported(format);
t.skipIfMultisampleNotSupportedForFormat(format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(format);
})
.fn(t => {
const { format } = t.params;
Expand Down
5 changes: 1 addition & 4 deletions src/webgpu/api/validation/texture/destroy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ g.test('invalid_texture')
invalidTexture.destroy();
});

const kColorTextureFormat: GPUTextureFormat = 'rgba32float';
const kColorTextureFormat: GPUTextureFormat = 'rgba8unorm';

g.test('submit_a_destroyed_texture_as_attachment')
.desc(
Expand All @@ -66,9 +66,6 @@ that was destroyed {before, after} encoding finishes.
'destroyedAfterEncode',
] as const)
)
.beforeAllSubcases(t => {
t.selectDeviceForRenderableColorFormatOrSkipTestCase(kColorTextureFormat);
})
.fn(t => {
const { colorTextureState, depthStencilTextureAspect, depthStencilTextureState } = t.params;

Expand Down
46 changes: 13 additions & 33 deletions src/webgpu/gpu_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,31 +289,17 @@ export class GPUTestSubcaseBatchState extends SubcaseBatchState {
}
}

skipIfMultisampleNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) {
skipIfMultisampleNotSupportedForFormatOrSelectDevice(
...formats: (GPUTextureFormat | undefined)[]
) {
for (const format of formats) {
if (format === undefined) continue;
if (!isMultisampledTextureFormat(format, this.isCompatibility)) {
this.skip(`texture format '${format}' is not supported to be multisampled`);
}
}
}

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

for (const format of formats) {
if (format === undefined) continue;
if (!kTextureFormatInfo[format].color) {
this.skip(`texture format '${format} is not color renderable`);
// float16 and float32 format need to be color renderable first to support multisampled in compat mode
if (is16Float(format) || is32Float(format)) {
this.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
}
}
}
Expand Down Expand Up @@ -573,23 +559,17 @@ export class GPUTestBase extends Fixture<GPUTestSubcaseBatchState> {
}
}

skipIfMultisampleNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) {
for (const format of formats) {
if (format === undefined) continue;
if (!isMultisampledTextureFormat(format, this.isCompatibility)) {
this.skip(`texture format '${format}' is not supported to be multisampled`);
}
}
}

skipIfColorRenderableNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) {
if (this.isCompatibility) {
const is16FloatRenderable = this.device.features.has('float16-renderable');
const is32FloatRenderable = this.device.features.has('float32-renderable');
for (const format of formats) {
if (format === undefined) continue;
if (is16Float(format) || is32Float(format)) {
this.skip(
`texture format '${format} is not guaranteed to be color renderable in compat mode`
);
if (
(is16Float(format) && !is16FloatRenderable) ||
(is32Float(format) && !is32FloatRenderable)
) {
this.skip(`texture format '${format} is not color renderable in compat mode`);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ Parameters:
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.skipIfMultisampleNotSupportedForFormatOrSelectDevice(t.params.format);
}
t.selectDeviceOrSkipTestCase(info.feature);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,7 @@ Parameters:
const { format, texture_type } = t.params;
t.skipIfTextureFormatNotSupported(format);
t.skipIfTextureLoadNotSupportedForTextureType(texture_type);
t.skipIfMultisampleNotSupportedForFormat(format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
t.selectDeviceForTextureFormatOrSkipTestCase(format);
t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(format);
})
.fn(async t => {
const { texture_type, format, stage, samplePoints, C, S } = t.params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ g.test('readTextureToTexelViews')
.beforeAllSubcases(t => {
t.skipIfTextureViewDimensionNotSupported(t.params.viewDimension);
// recheck if multisampled is supported with compat mode flag
t.skipIfMultisampleNotSupportedForFormat(t.params.srcFormat);
t.skipIfMultisampleNotSupportedForFormatOrSelectDevice(t.params.srcFormat);
})
.fn(async t => {
const { srcFormat, texelViewFormat, viewDimension, sampleCount } = t.params;
Expand Down

0 comments on commit e32e433

Please sign in to comment.