Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd3c719

Browse files
author
Yunchao He
authored
Add texture size tests for 1D/2D/3D textures (gpuweb#479)
* Add texture size tests for 1D/2D/3D textures * Update webgpu/types to 0.0.42 for texture dimension limits * Fixes/Skip: total texture footprint issue, compressed texture alignment issue
1 parent a9ac8c3 commit dd3c719

File tree

4 files changed

+141
-14
lines changed

4 files changed

+141
-14
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"@types/morgan": "^1.9.2",
3737
"@types/node": "^14.11.10",
3838
"@types/offscreencanvas": "^2019.6.2",
39-
"@webgpu/types": "0.0.41",
39+
"@webgpu/types": "0.0.42",
4040
"babel-plugin-add-header-comment": "^1.0.3",
4141
"babel-plugin-const-enum": "^1.0.1",
4242
"chokidar": "^3.4.3",

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

Lines changed: 133 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ TODO: review existing tests and merge with this plan:
1010
> - with format that supports multisample, with all possible dimensions
1111
> - with dimension that support multisample, with all possible formats
1212
> - with format-dimension that support multisample, with {mipLevelCount, array layer count} = {1, 2}
13-
> - 1d, {width, height, depthOrArrayLayers} > whatever the max is
14-
> - height max is 1 (unless 1d-array is added)
15-
> - depthOrArrayLayers max is 1
16-
> - x= every texture format
17-
> - 2d, {width, height, depthOrArrayLayers} > whatever the max is
18-
> - depthOrArrayLayers max differs from width/height
19-
> - x= every texture format
20-
> - 3d, {width, height, depthOrArrayLayers} > whatever the max is
21-
> - x= every texture format
2213
> - usage flags
2314
> - {0, ... each single usage flag}
2415
> - x= every texture format
@@ -32,7 +23,13 @@ TODO: move destroy tests out of this file
3223

3324
import { poptions, params } from '../../../common/framework/params_builder.js';
3425
import { makeTestGroup } from '../../../common/framework/test_group.js';
35-
import { kAllTextureFormats, kAllTextureFormatInfo } from '../../capability_info.js';
26+
import {
27+
kAllTextureFormats,
28+
kAllTextureFormatInfo,
29+
kUncompressedTextureFormats,
30+
kUncompressedTextureFormatInfo,
31+
} from '../../capability_info.js';
32+
import { DefaultLimits } from '../../constants.js';
3633
import { maxMipLevelCount } from '../../util/texture/base.js';
3734

3835
import { ValidationTest } from './validation_test.js';
@@ -238,6 +235,132 @@ g.test('sampleCount')
238235
}, !_success);
239236
});
240237

238+
g.test('texture_size,1d_texture')
239+
.desc(`Test texture size requirement for 1D texture`)
240+
.subcases(() =>
241+
params()
242+
.combine(poptions('format', kAllTextureFormats))
243+
.combine(
244+
poptions('width', [
245+
DefaultLimits.maxTextureDimension1D - 1,
246+
DefaultLimits.maxTextureDimension1D,
247+
DefaultLimits.maxTextureDimension1D + 1,
248+
])
249+
)
250+
.combine(poptions('height', [1, 2]))
251+
.combine(poptions('depthOrArrayLayers', [1, 2]))
252+
)
253+
.fn(async t => {
254+
const { format, width, height, depthOrArrayLayers } = t.params;
255+
256+
await t.selectDeviceOrSkipTestCase(kAllTextureFormatInfo[format].extension);
257+
258+
const descriptor: GPUTextureDescriptor = {
259+
size: [width, height, depthOrArrayLayers],
260+
dimension: '1d' as const,
261+
format,
262+
usage: GPUTextureUsage.SAMPLED,
263+
};
264+
265+
const success =
266+
width <= DefaultLimits.maxTextureDimension1D && height === 1 && depthOrArrayLayers === 1;
267+
268+
t.expectValidationError(() => {
269+
t.device.createTexture(descriptor);
270+
}, !success);
271+
});
272+
273+
g.test('texture_size,2d_texture')
274+
.desc(
275+
`Test texture size requirement for 2D texture.
276+
TODO: add tests for compressed texture.`
277+
)
278+
.subcases(() =>
279+
params()
280+
.combine(poptions('format', kUncompressedTextureFormats))
281+
.combine(poptions('dimension', [undefined, '2d'] as const))
282+
.combine([
283+
// Test the bound of width
284+
{ size: [DefaultLimits.maxTextureDimension2D - 1, 1, 1] },
285+
{ size: [DefaultLimits.maxTextureDimension2D, 1, 1] },
286+
{ size: [DefaultLimits.maxTextureDimension2D + 1, 1, 1] },
287+
// Test the bound of height
288+
{ size: [1, DefaultLimits.maxTextureDimension2D - 1, 1] },
289+
{ size: [1, DefaultLimits.maxTextureDimension2D, 1] },
290+
{ size: [1, DefaultLimits.maxTextureDimension2D + 1, 1] },
291+
// Test the bound of array layers
292+
{ size: [1, 1, DefaultLimits.maxTextureArrayLayers - 1] },
293+
{ size: [1, 1, DefaultLimits.maxTextureArrayLayers] },
294+
{ size: [1, 1, DefaultLimits.maxTextureArrayLayers + 1] },
295+
])
296+
)
297+
.fn(async t => {
298+
const { format, dimension, size } = t.params;
299+
300+
await t.selectDeviceOrSkipTestCase(kUncompressedTextureFormatInfo[format].extension);
301+
302+
const descriptor: GPUTextureDescriptor = {
303+
size,
304+
dimension,
305+
format,
306+
usage: GPUTextureUsage.SAMPLED,
307+
};
308+
309+
const success =
310+
size[0] <= DefaultLimits.maxTextureDimension2D &&
311+
size[1] <= DefaultLimits.maxTextureDimension2D &&
312+
size[2] <= DefaultLimits.maxTextureArrayLayers;
313+
314+
t.expectValidationError(() => {
315+
t.device.createTexture(descriptor);
316+
}, !success);
317+
});
318+
319+
g.test('texture_size,3d_texture')
320+
.desc(
321+
`Test texture size requirement for 3D texture.
322+
TODO: add tests for compressed texture.`
323+
)
324+
.subcases(() =>
325+
params()
326+
.combine(poptions('format', kUncompressedTextureFormats))
327+
.combine([
328+
// Test the bound of width
329+
{ size: [DefaultLimits.maxTextureDimension3D - 1, 1, 1] },
330+
{ size: [DefaultLimits.maxTextureDimension3D, 1, 1] },
331+
{ size: [DefaultLimits.maxTextureDimension3D + 1, 1, 1] },
332+
// Test the bound of height
333+
{ size: [1, DefaultLimits.maxTextureDimension3D - 1, 1] },
334+
{ size: [1, DefaultLimits.maxTextureDimension3D, 1] },
335+
{ size: [1, DefaultLimits.maxTextureDimension3D + 1, 1] },
336+
// Test the bound of depth
337+
{ size: [1, 1, DefaultLimits.maxTextureDimension3D - 1] },
338+
{ size: [1, 1, DefaultLimits.maxTextureDimension3D] },
339+
{ size: [1, 1, DefaultLimits.maxTextureDimension3D + 1] },
340+
])
341+
)
342+
.fn(async t => {
343+
const { format, size } = t.params;
344+
345+
await t.selectDeviceOrSkipTestCase(kUncompressedTextureFormatInfo[format].extension);
346+
347+
const descriptor: GPUTextureDescriptor = {
348+
size,
349+
dimension: '3d' as const,
350+
format,
351+
usage: GPUTextureUsage.SAMPLED,
352+
};
353+
354+
const success =
355+
size[0] <= DefaultLimits.maxTextureDimension3D &&
356+
size[1] <= DefaultLimits.maxTextureDimension3D &&
357+
size[2] <= DefaultLimits.maxTextureDimension3D;
358+
359+
t.expectValidationError(() => {
360+
t.device.createTexture(descriptor);
361+
}, !success);
362+
});
363+
241364
g.test('it_is_valid_to_destroy_a_texture').fn(t => {
242365
const descriptor = t.getDescriptor();
243366
const texture = t.device.createTexture(descriptor);

src/webgpu/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export const GPUConst = {
4444

4545
// Type ensures every field is specified.
4646
export const DefaultLimits: ResolveType<Required<Readonly<GPULimits>>> = {
47+
maxTextureDimension1D: 8192,
48+
maxTextureDimension2D: 8192,
49+
maxTextureDimension3D: 2048,
50+
maxTextureArrayLayers: 2048,
4751
maxBindGroups: 4,
4852
maxDynamicUniformBuffersPerPipelineLayout: 8,
4953
maxDynamicStorageBuffersPerPipelineLayout: 4,

0 commit comments

Comments
 (0)