11import { keysOf } from '../../../../../common/util/data_tables.js' ;
22
33import {
4+ LimitMode ,
5+ getDefaultLimit ,
46 kMaximumLimitBaseParams ,
5- kMaximumLimitValueTestKeys ,
67 makeLimitTestGroup ,
78} from './limit_utils.js' ;
89
@@ -26,6 +27,9 @@ function getSizeAndOffsetForBufferPart(device: GPUDevice, bufferPart: BufferPart
2627const limit = 'maxUniformBufferBindingSize' ;
2728export const { g, description } = makeLimitTestGroup ( limit ) ;
2829
30+ // We also need to update the maxBufferSize limit when testing.
31+ const kExtraLimits = { maxBufferSize : 'maxLimit' as LimitMode } ;
32+
2933g . test ( 'createBindGroup,at_over' )
3034 . desc ( `Test using at and over ${ limit } limit` )
3135 . params ( kMaximumLimitBaseParams . combine ( 'bufferPart' , kBufferPartsKeys ) )
@@ -46,6 +50,13 @@ g.test('createBindGroup,at_over')
4650 } ) ;
4751
4852 const { size, offset } = getSizeAndOffsetForBufferPart ( device , bufferPart , testValue ) ;
53+
54+ // If the size of the buffer exceeds the related but separate maxBufferSize limit, we can
55+ // skip the validation since the allocation will fail with a validation error.
56+ if ( size > device . limits . maxBufferSize ) {
57+ return ;
58+ }
59+
4960 device . pushErrorScope ( 'out-of-memory' ) ;
5061 const uniformBuffer = t . trackForCleanup (
5162 device . createBuffer ( {
@@ -56,36 +67,35 @@ g.test('createBindGroup,at_over')
5667 const outOfMemoryError = await device . popErrorScope ( ) ;
5768
5869 if ( ! outOfMemoryError ) {
59- await t . expectValidationError ( ( ) => {
60- device . createBindGroup ( {
61- layout : bindGroupLayout ,
62- entries : [
63- {
64- binding : 0 ,
65- resource : {
66- buffer : uniformBuffer ,
67- offset,
68- size : testValue ,
70+ await t . expectValidationError (
71+ ( ) => {
72+ device . createBindGroup ( {
73+ layout : bindGroupLayout ,
74+ entries : [
75+ {
76+ binding : 0 ,
77+ resource : {
78+ buffer : uniformBuffer ,
79+ offset,
80+ size : testValue ,
81+ } ,
6982 } ,
70- } ,
71- ] ,
72- } ) ;
73- } , shouldError ) ;
83+ ] ,
84+ } ) ;
85+ } ,
86+ shouldError ,
87+ `size: ${ size } , offset: ${ offset } , testValue: ${ testValue } `
88+ ) ;
7489 }
75- }
90+ } ,
91+ kExtraLimits
7692 ) ;
7793 } ) ;
7894
7995g . test ( 'validate,maxBufferSize' )
8096 . desc ( `Test that ${ limit } <= maxBufferSize` )
81- . params ( u => u . combine ( 'limitTest' , kMaximumLimitValueTestKeys ) )
82- . fn ( async t => {
83- const { limitTest } = t . params ;
84- await t . testDeviceWithRequestedMaximumLimits (
85- limitTest ,
86- 'atLimit' ,
87- ( { device, actualLimit } ) => {
88- t . expect ( actualLimit <= device . limits . maxBufferSize ) ;
89- }
90- ) ;
97+ . fn ( t => {
98+ const { adapter, defaultLimit, adapterLimit } = t ;
99+ t . expect ( defaultLimit <= getDefaultLimit ( 'maxBufferSize' ) ) ;
100+ t . expect ( adapterLimit <= adapter . limits . maxBufferSize ) ;
91101 } ) ;
0 commit comments