@@ -291,6 +291,7 @@ pub enum BinderError {
291291
292292#[ derive( Debug ) ]
293293struct LateBufferBinding {
294+ binding_index : u32 ,
294295 shader_expect_size : wgt:: BufferAddress ,
295296 bound_size : wgt:: BufferAddress ,
296297}
@@ -347,20 +348,25 @@ impl Binder {
347348 self . manager . update_expectations ( & new. bind_group_layouts ) ;
348349
349350 // Update the buffer binding sizes that are required by shaders.
351+
350352 for ( payload, late_group) in self . payloads . iter_mut ( ) . zip ( late_sized_buffer_groups) {
351353 payload. late_bindings_effective_count = late_group. shader_sizes . len ( ) ;
354+ // Update entries that already exist as the bind group was bound before the pipeline
355+ // was bound.
352356 for ( late_binding, & shader_expect_size) in payload
353357 . late_buffer_bindings
354358 . iter_mut ( )
355359 . zip ( late_group. shader_sizes . iter ( ) )
356360 {
357361 late_binding. shader_expect_size = shader_expect_size;
358362 }
363+ // Add new entries for the bindings that were not known when the bind group was bound.
359364 if late_group. shader_sizes . len ( ) > payload. late_buffer_bindings . len ( ) {
360365 for & shader_expect_size in
361366 late_group. shader_sizes [ payload. late_buffer_bindings . len ( ) ..] . iter ( )
362367 {
363368 payload. late_buffer_bindings . push ( LateBufferBinding {
369+ binding_index : 0 ,
364370 shader_expect_size,
365371 bound_size : 0 ,
366372 } ) ;
@@ -389,20 +395,27 @@ impl Binder {
389395
390396 // Fill out the actual binding sizes for buffers,
391397 // whose layout doesn't specify `min_binding_size`.
392- for ( late_binding, late_size) in payload
398+
399+ // Update entries that already exist as the pipeline was bound before the group
400+ // was bound.
401+ for ( late_binding, late_info) in payload
393402 . late_buffer_bindings
394403 . iter_mut ( )
395- . zip ( bind_group. late_buffer_binding_sizes . iter ( ) )
404+ . zip ( bind_group. late_buffer_binding_infos . iter ( ) )
396405 {
397- late_binding. bound_size = late_size. get ( ) ;
406+ late_binding. binding_index = late_info. binding_index ;
407+ late_binding. bound_size = late_info. size . get ( ) ;
398408 }
399- if bind_group. late_buffer_binding_sizes . len ( ) > payload. late_buffer_bindings . len ( ) {
400- for late_size in
401- bind_group. late_buffer_binding_sizes [ payload. late_buffer_bindings . len ( ) ..] . iter ( )
409+
410+ // Add new entries for the bindings that were not known when the pipeline was bound.
411+ if bind_group. late_buffer_binding_infos . len ( ) > payload. late_buffer_bindings . len ( ) {
412+ for late_info in
413+ bind_group. late_buffer_binding_infos [ payload. late_buffer_bindings . len ( ) ..] . iter ( )
402414 {
403415 payload. late_buffer_bindings . push ( LateBufferBinding {
416+ binding_index : late_info. binding_index ,
404417 shader_expect_size : 0 ,
405- bound_size : late_size . get ( ) ,
418+ bound_size : late_info . size . get ( ) ,
406419 } ) ;
407420 }
408421 }
@@ -469,15 +482,13 @@ impl Binder {
469482 ) -> Result < ( ) , LateMinBufferBindingSizeMismatch > {
470483 for group_index in self . manager . list_active ( ) {
471484 let payload = & self . payloads [ group_index] ;
472- for ( compact_index, late_binding) in payload. late_buffer_bindings
473- [ ..payload. late_bindings_effective_count ]
474- . iter ( )
475- . enumerate ( )
485+ for late_binding in
486+ & payload. late_buffer_bindings [ ..payload. late_bindings_effective_count ]
476487 {
477488 if late_binding. bound_size < late_binding. shader_expect_size {
478489 return Err ( LateMinBufferBindingSizeMismatch {
479490 group_index : group_index as u32 ,
480- compact_index ,
491+ binding_index : late_binding . binding_index ,
481492 shader_size : late_binding. shader_expect_size ,
482493 bound_size : late_binding. bound_size ,
483494 } ) ;
0 commit comments