@@ -10,15 +10,6 @@ TODO: review existing tests and merge with this plan:
10
10
> - with format that supports multisample, with all possible dimensions
11
11
> - with dimension that support multisample, with all possible formats
12
12
> - 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
22
13
> - usage flags
23
14
> - {0, ... each single usage flag}
24
15
> - x= every texture format
@@ -32,7 +23,13 @@ TODO: move destroy tests out of this file
32
23
33
24
import { poptions , params } from '../../../common/framework/params_builder.js' ;
34
25
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' ;
36
33
import { maxMipLevelCount } from '../../util/texture/base.js' ;
37
34
38
35
import { ValidationTest } from './validation_test.js' ;
@@ -238,6 +235,132 @@ g.test('sampleCount')
238
235
} , ! _success ) ;
239
236
} ) ;
240
237
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
+
241
364
g . test ( 'it_is_valid_to_destroy_a_texture' ) . fn ( t => {
242
365
const descriptor = t . getDescriptor ( ) ;
243
366
const texture = t . device . createTexture ( descriptor ) ;
0 commit comments