Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat: fix float16(32)-renderable tests #4148

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/webgpu/api/operation/render_pass/storeOp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ g.test('render_pass_store_op,color_attachment_only')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.colorFormat);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.colorFormat);
})
.fn(t => {
const colorAttachment = t.createTextureTracked({
Expand Down
6 changes: 5 additions & 1 deletion src/webgpu/api/operation/render_pipeline/overrides.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ g.test('basic')
);
});

const kPrecisionTestFormat = 'rgba32float';
g.test('precision')
.desc(`Test that the float number precision is preserved for constants`)
.params(u =>
Expand All @@ -190,8 +191,11 @@ g.test('precision')
},
])
)
.beforeAllSubcases(t => {
t.selectDeviceForRenderableColorFormatOrSkipTestCase(kPrecisionTestFormat);
})
.fn(async t => {
const format = 'rgba32float';
const format = kPrecisionTestFormat;
await t.ExpectShaderOutputWithConstants(
t.params.isAsync,
format,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ g.test('color,attachments')
.beforeAllSubcases(t => {
const info = kTextureFormatInfo[t.params.format];
t.skipIfTextureFormatNotSupported(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 @@ -159,6 +159,7 @@ function computeBlendOperation(
}
}

const kBlendingGPUBlendComponentFormat = 'rgba16float';
g.test('blending,GPUBlendComponent')
.desc(
`Test all combinations of parameters for GPUBlendComponent.
Expand Down Expand Up @@ -208,9 +209,10 @@ g.test('blending,GPUBlendComponent')
) {
t.selectDeviceOrSkipTestCase('dual-source-blending');
}
t.selectDeviceForRenderableColorFormatOrSkipTestCase(kBlendingGPUBlendComponentFormat);
})
.fn(t => {
const textureFormat: GPUTextureFormat = 'rgba16float';
const textureFormat: GPUTextureFormat = kBlendingGPUBlendComponentFormat;
const srcColor = t.params.srcColor;
const srcColor1 = t.params.srcColor1;
const dstColor = t.params.dstColor;
Expand Down Expand Up @@ -393,6 +395,7 @@ g.test('blending,formats')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
})
.fn(t => {
const { format } = t.params;
Expand Down Expand Up @@ -797,6 +800,9 @@ g.test('blending,clamping')
.combine('srcValue', [0.4, 0.6, 0.8, 1.0])
.combine('dstValue', [0.2, 0.4])
)
.beforeAllSubcases(t => {
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
})
.fn(t => {
const { format, srcValue, dstValue } = t.params;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ g.test('uninitialized_texture_is_zero')
.params(kTestParams)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
t.selectDeviceOrSkipTestCase(kTextureFormatInfo[t.params.format].feature);
})
.fn(t => {
Expand Down
5 changes: 5 additions & 0 deletions src/webgpu/api/operation/sampling/filter_mode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ g.test('magFilter,nearest')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
if (kTextureFormatInfo[t.params.format].color.type === 'unfilterable-float') {
t.selectDeviceOrSkipTestCase('float32-filterable');
}
Expand Down Expand Up @@ -604,6 +605,7 @@ g.test('magFilter,linear')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
if (kTextureFormatInfo[t.params.format].color.type === 'unfilterable-float') {
t.selectDeviceOrSkipTestCase('float32-filterable');
}
Expand Down Expand Up @@ -739,6 +741,7 @@ g.test('minFilter,nearest')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
if (kTextureFormatInfo[t.params.format].color.type === 'unfilterable-float') {
t.selectDeviceOrSkipTestCase('float32-filterable');
}
Expand Down Expand Up @@ -872,6 +875,7 @@ g.test('minFilter,linear')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
if (kTextureFormatInfo[t.params.format].color.type === 'unfilterable-float') {
t.selectDeviceOrSkipTestCase('float32-filterable');
}
Expand Down Expand Up @@ -968,6 +972,7 @@ g.test('mipmapFilter')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
if (kTextureFormatInfo[t.params.format].color.type === 'unfilterable-float') {
t.selectDeviceOrSkipTestCase('float32-filterable');
}
Expand Down
4 changes: 4 additions & 0 deletions src/webgpu/format_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,10 @@ export function canUseAsRenderTarget(format: GPUTextureFormat) {
return kTextureFormatInfo[format].colorRender || isDepthOrStencilTextureFormat(format);
}

export function is16Float(format: GPUTextureFormat) {
return format === 'r16float' || format === 'rg16float' || format === 'rgba16float';
}

export function is32Float(format: GPUTextureFormat) {
return format === 'r32float' || format === 'rg32float' || format === 'rgba32float';
}
Expand Down
24 changes: 24 additions & 0 deletions src/webgpu/gpu_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
isCompressedTextureFormat,
ColorTextureFormat,
isTextureFormatUsableAsStorageFormat,
is32Float,
is16Float,
} from './format_info.js';
import { checkElementsEqual, checkElementsBetween } from './util/check_contents.js';
import { CommandBufferMaker, EncoderType } from './util/command_buffer_maker.js';
Expand Down Expand Up @@ -227,6 +229,13 @@ export class GPUTestSubcaseBatchState extends SubcaseBatchState {
this.selectDeviceOrSkipTestCase(features);
}

/** Skips test if format is float16 or float32 and not color renderable based on device feature availability. */
selectDeviceForRenderableColorFormatOrSkipTestCase(...formats: (GPUTextureFormat | undefined)[]) {
this.selectDeviceOrSkipTestCase({
requiredFeatures: this.getFloatTextureFormatColorRenderableFeatures(...formats),
});
}

/** @internal MAINTENANCE_TODO: Make this not visible to test code? */
acquireMismatchedProvider(): Promise<DeviceProvider> | undefined {
return this.mismatchedProvider;
Expand Down Expand Up @@ -279,6 +288,21 @@ export class GPUTestSubcaseBatchState extends SubcaseBatchState {
}
}

getFloatTextureFormatColorRenderableFeatures(...formats: (GPUTextureFormat | undefined)[]) {
const requiredFeatures: GPUFeatureName[] = [];
if (this.isCompatibility) {
for (const format of formats) {
if (format === undefined) continue;
if (is32Float(format)) {
requiredFeatures.push('float32-renderable' as GPUFeatureName);
} else if (is16Float(format)) {
requiredFeatures.push('float16-renderable' as GPUFeatureName);
}
}
}
return requiredFeatures;
}

skipIfCopyTextureToTextureNotSupportedForFormat(...formats: (GPUTextureFormat | undefined)[]) {
if (this.isCompatibility) {
for (const format of formats) {
Expand Down
Loading