Skip to content

Commit 74e5db6

Browse files
committed
Compat: fix float16(32)-renderable tests (validation)
1 parent 9273480 commit 74e5db6

File tree

11 files changed

+87
-18
lines changed

11 files changed

+87
-18
lines changed

src/webgpu/api/validation/capability_checks/limits/maxColorAttachmentBytesPerSample.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import {
1111
} from './limit_utils.js';
1212

1313
const kFormatsToUseBySize: GPUTextureFormat[] = [
14-
'rgba32float',
15-
'rgba16float',
14+
'rgba32uint',
15+
'rgba16uint',
1616
'rgba8unorm',
1717
'rg8unorm',
1818
'r8unorm',
1919
];
2020

2121
const kInterleaveFormats: GPUTextureFormat[] = [
22-
'rgba16float',
23-
'rg16float',
22+
'rgba16uint',
23+
'rg16uint',
2424
'rgba8unorm',
2525
'rg8unorm',
2626
'r8unorm',

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import { getTextureDimensionFromView } from '../../util/texture/base.js';
3030

3131
import { ValidationTest } from './validation_test.js';
3232

33+
const kTestFormat: GPUTextureFormat = 'r32float';
34+
3335
function clone<T extends GPUTextureDescriptor>(descriptor: T): T {
3436
return JSON.parse(JSON.stringify(descriptor));
3537
}
@@ -144,7 +146,7 @@ g.test('binding_must_contain_resource_defined_in_layout')
144146
.params(u =>
145147
u //
146148
.combine('resourceType', kBindableResources)
147-
.combine('entry', allBindingEntries(false))
149+
.combine('entry', allBindingEntries(false, kTestFormat))
148150
)
149151
.fn(t => {
150152
const { resourceType, entry } = t.params;
@@ -195,14 +197,20 @@ g.test('texture_binding_must_have_correct_usage')
195197
.desc('Tests that texture bindings must have the correct usage.')
196198
.paramsSubcasesOnly(u =>
197199
u //
198-
.combine('entry', sampledAndStorageBindingEntries(false))
200+
.combine('entry', sampledAndStorageBindingEntries(false, kTestFormat))
199201
.combine('usage', kTextureUsages)
200202
.unless(({ entry, usage }) => {
201203
const info = texBindingTypeInfo(entry);
202204
// Can't create the texture for this (usage=STORAGE_BINDING and sampleCount=4), so skip.
203205
return usage === GPUConst.TextureUsage.STORAGE_BINDING && info.resource === 'sampledTexMS';
204206
})
205207
)
208+
.beforeAllSubcases(t => {
209+
t.skipIf(
210+
t.isCompatibility,
211+
"The test requires 'r32float' renderable and multisampled support which compat mode doesn't guarantee."
212+
);
213+
})
206214
.fn(t => {
207215
const { entry, usage } = t.params;
208216
const info = texBindingTypeInfo(entry);
@@ -217,7 +225,7 @@ g.test('texture_binding_must_have_correct_usage')
217225

218226
const descriptor = {
219227
size: { width: 16, height: 16, depthOrArrayLayers: 1 },
220-
format: 'r32float' as const,
228+
format: kTestFormat,
221229
usage: appliedUsage,
222230
sampleCount: info.resource === 'sampledTexMS' ? 4 : 1,
223231
};
@@ -601,7 +609,7 @@ g.test('texture,resource_state')
601609
.paramsSubcasesOnly(u =>
602610
u
603611
.combine('state', kResourceStates)
604-
.combine('entry', sampledAndStorageBindingEntries(true))
612+
.combine('entry', sampledAndStorageBindingEntries(true, kTestFormat))
605613
.combine('visibilityMask', [kAllShaderStages, GPUConst.ShaderStage.COMPUTE] as const)
606614
)
607615
.fn(t => {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
viewCompatible,
1717
textureDimensionAndFormatCompatible,
1818
isTextureFormatUsableAsStorageFormat,
19+
is32Float,
1920
} from '../../format_info.js';
2021
import { maxMipLevelCount } from '../../util/texture/base.js';
2122

@@ -355,11 +356,17 @@ g.test('sampleCount,valid_sampleCount_with_other_parameter_varies')
355356
const info = kTextureFormatInfo[format];
356357
t.skipIfTextureFormatNotSupported(format);
357358
t.selectDeviceOrSkipTestCase(info.feature);
359+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
358360
})
359361
.fn(t => {
360362
const { dimension, sampleCount, format, mipLevelCount, arrayLayerCount, usage } = t.params;
361363
const { blockWidth, blockHeight } = kTextureFormatInfo[format];
362364

365+
t.skipIf(
366+
sampleCount === 4 && t.isCompatibility && (format === 'rgba16float' || is32Float(format)),
367+
'Multisample support for this format is not guaranteed in comapt mode'
368+
);
369+
363370
const size =
364371
dimension === '1d'
365372
? [32 * blockWidth, 1 * blockHeight, 1]
@@ -1047,6 +1054,7 @@ g.test('texture_usage')
10471054
const info = kTextureFormatInfo[format];
10481055
t.skipIfTextureFormatNotSupported(format);
10491056
t.selectDeviceOrSkipTestCase(info.feature);
1057+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
10501058
})
10511059
.fn(t => {
10521060
const { dimension, format, usage0, usage1 } = t.params;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ g.test('texture_view_usage')
378378
if (textureUsage & GPUTextureUsage.STORAGE_BINDING) {
379379
t.skipIfTextureFormatNotUsableAsStorageTexture(format);
380380
}
381+
if (textureUsage & GPUTextureUsage.RENDER_ATTACHMENT) {
382+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
383+
}
381384
})
382385
.fn(t => {
383386
const { format, textureUsage0, textureUsage1, textureViewUsage0, textureViewUsage1 } = t.params;

src/webgpu/api/validation/encoding/createRenderBundleEncoder.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ g.test('attachment_state,limits,maxColorAttachmentBytesPerSample,aligned')
6363
)
6464
.beforeAllSubcases(t => {
6565
t.skipIfTextureFormatNotSupported(t.params.format);
66+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
6667
})
6768
.fn(t => {
6869
const { format, colorFormatCount } = t.params;
@@ -118,6 +119,9 @@ g.test('attachment_state,limits,maxColorAttachmentBytesPerSample,unaligned')
118119
},
119120
])
120121
)
122+
.beforeAllSubcases(t => {
123+
t.selectDeviceForRenderableColorFormatOrSkipTestCase('r32float');
124+
})
121125
.fn(t => {
122126
const { formats } = t.params;
123127

@@ -168,6 +172,7 @@ g.test('valid_texture_formats')
168172
.beforeAllSubcases(t => {
169173
const { format } = t.params;
170174
t.selectDeviceForTextureFormatOrSkipTestCase(format);
175+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
171176
})
172177
.fn(t => {
173178
const { format, attachment } = t.params;

src/webgpu/api/validation/queue/copyToTexture/CopyExternalImageToTexture.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ g.test('destination_texture,format')
682682
const { format } = t.params;
683683
t.skipIfTextureFormatNotSupported(format);
684684
t.selectDeviceOrSkipTestCase(kTextureFormatInfo[format].feature);
685+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
685686
})
686687
.fn(async t => {
687688
const { format, copySize } = t.params;

src/webgpu/api/validation/render_pass/attachment_compatibility.spec.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
kTextureFormatInfo,
1515
filterFormatsByFeature,
1616
getFeaturesForFormats,
17+
is16Float,
18+
is32Float,
1719
} from '../../../format_info.js';
1820
import { ValidationTest } from '../validation_test.js';
1921

@@ -182,6 +184,14 @@ g.test('render_pass_and_bundle,color_format')
182184
const { passFormat, bundleFormat } = t.params;
183185

184186
t.skipIfTextureFormatNotSupported(passFormat, bundleFormat);
187+
// float16 and float32 might miss color renderablity under compat mode
188+
t.skipIf(
189+
t.isCompatibility &&
190+
(is16Float(passFormat) ||
191+
is32Float(passFormat) ||
192+
is16Float(bundleFormat) ||
193+
is32Float(bundleFormat))
194+
);
185195

186196
const bundleEncoder = t.device.createRenderBundleEncoder({
187197
colorFormats: [bundleFormat],
@@ -358,7 +368,7 @@ g.test('render_pass_and_bundle,device_mismatch')
358368
const { mismatched } = t.params;
359369
const sourceDevice = mismatched ? t.mismatchedDevice : t.device;
360370

361-
const format = 'r16float';
371+
const format = 'r16uint';
362372
const bundleEncoder = sourceDevice.createRenderBundleEncoder({
363373
colorFormats: [format],
364374
});
@@ -390,6 +400,14 @@ Test that color attachment formats in render passes or bundles match the pipelin
390400
const { encoderType, encoderFormat, pipelineFormat } = t.params;
391401

392402
t.skipIfTextureFormatNotSupported(encoderFormat, pipelineFormat);
403+
// float16 and float32 might miss color renderablity under compat mode
404+
t.skipIf(
405+
t.isCompatibility &&
406+
(is16Float(encoderFormat) ||
407+
is32Float(encoderFormat) ||
408+
is16Float(pipelineFormat) ||
409+
is32Float(pipelineFormat))
410+
);
393411

394412
const pipeline = t.createRenderPipeline([{ format: pipelineFormat, writeMask: 0 }]);
395413

src/webgpu/api/validation/render_pass/render_pass_descriptor.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getDefaultLimits, kQueryTypes } from '../../../capability_info.js';
1111
import { GPUConst } from '../../../constants.js';
1212
import {
1313
computeBytesPerSampleFromFormats,
14+
is32Float,
1415
kDepthStencilFormats,
1516
kRenderableColorTextureFormats,
1617
kTextureFormatInfo,
@@ -211,6 +212,7 @@ g.test('color_attachments,limits,maxColorAttachmentBytesPerSample,aligned')
211212
)
212213
.beforeAllSubcases(t => {
213214
t.skipIfTextureFormatNotSupported(t.params.format);
215+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
214216
})
215217
.fn(t => {
216218
const { format, attachmentCount } = t.params;
@@ -267,6 +269,9 @@ g.test('color_attachments,limits,maxColorAttachmentBytesPerSample,unaligned')
267269
},
268270
])
269271
)
272+
.beforeAllSubcases(t => {
273+
t.selectDeviceForRenderableColorFormatOrSkipTestCase('r32float');
274+
})
270275
.fn(t => {
271276
const { formats } = t.params;
272277

@@ -1168,7 +1173,13 @@ g.test('resolveTarget,format_supports_resolve')
11681173
.filter(t => kTextureFormatInfo[t.format].multisample)
11691174
)
11701175
.beforeAllSubcases(t => {
1171-
t.skipIfTextureFormatNotSupported(t.params.format);
1176+
const { format } = t.params;
1177+
t.skipIfTextureFormatNotSupported(format);
1178+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(format);
1179+
t.skipIf(
1180+
t.isCompatibility && (format === 'rgba16float' || is32Float(format)),
1181+
'Multisample support for this format is not guaranteed in comapt mode'
1182+
);
11721183
})
11731184
.fn(t => {
11741185
const { format } = t.params;

src/webgpu/api/validation/render_pipeline/float32_blendable.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pipeline that uses blending with any float32-format attachment.
3030
if (t.params.enabled) {
3131
t.selectDeviceOrSkipTestCase('float32-blendable');
3232
}
33+
t.selectDeviceForRenderableColorFormatOrSkipTestCase('r32float');
3334
})
3435
.fn(t => {
3536
const { isAsync, enabled, hasBlend, format } = t.params;

src/webgpu/api/validation/render_pipeline/fragment_state.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ g.test('limits,maxColorAttachmentBytesPerSample,aligned')
181181
)
182182
.beforeAllSubcases(t => {
183183
t.skipIfTextureFormatNotSupported(t.params.format);
184+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
184185
})
185186
.fn(t => {
186187
const { format, attachmentCount, isAsync } = t.params;
@@ -228,6 +229,9 @@ g.test('limits,maxColorAttachmentBytesPerSample,unaligned')
228229
.beginSubcases()
229230
.combine('isAsync', [false, true])
230231
)
232+
.beforeAllSubcases(t => {
233+
t.selectDeviceForRenderableColorFormatOrSkipTestCase('r32float');
234+
})
231235
.fn(t => {
232236
const { formats, isAsync } = t.params;
233237

@@ -394,6 +398,7 @@ g.test('pipeline_output_targets')
394398
)
395399
.beforeAllSubcases(t => {
396400
t.selectDeviceForTextureFormatOrSkipTestCase(t.params.format);
401+
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
397402
})
398403
.fn(t => {
399404
const { isAsync, format, writeMask, shaderOutput } = t.params;

0 commit comments

Comments
 (0)