@@ -130,8 +130,6 @@ pub struct Device {
130130 pub ( crate ) usage_scopes : UsageScopePool ,
131131 pub ( crate ) last_acceleration_structure_build_command_index : AtomicU64 ,
132132 pub ( crate ) indirect_validation : Option < crate :: indirect_validation:: IndirectValidation > ,
133- pub ( crate ) indirect_draw_validation :
134- Option < crate :: indirect_draw_validation:: IndirectDrawValidation > ,
135133 // needs to be dropped last
136134 #[ cfg( feature = "trace" ) ]
137135 pub ( crate ) trace : Mutex < Option < trace:: Trace > > ,
@@ -164,9 +162,6 @@ impl Drop for Device {
164162 if let Some ( indirect_validation) = self . indirect_validation . take ( ) {
165163 indirect_validation. dispose ( self . raw . as_ref ( ) ) ;
166164 }
167- if let Some ( indirect_draw_validation) = self . indirect_draw_validation . take ( ) {
168- indirect_draw_validation. dispose ( self . raw . as_ref ( ) ) ;
169- }
170165 unsafe {
171166 self . raw . destroy_buffer ( zero_buffer) ;
172167 self . raw . destroy_fence ( fence) ;
@@ -258,31 +253,11 @@ impl Device {
258253 . contains ( wgt:: DownlevelFlags :: INDIRECT_EXECUTION ) ;
259254
260255 let indirect_validation = if enable_indirect_validation {
261- match crate :: indirect_validation:: IndirectValidation :: new (
256+ Some ( crate :: indirect_validation:: IndirectValidation :: new (
262257 raw_device. as_ref ( ) ,
263258 & desc. required_limits ,
264- ) {
265- Ok ( indirect_validation) => Some ( indirect_validation) ,
266- Err ( e) => {
267- log:: error!( "indirect-validation error: {e:?}" ) ;
268- return Err ( DeviceError :: Lost ) ;
269- }
270- }
271- } else {
272- None
273- } ;
274-
275- let indirect_draw_validation = if enable_indirect_validation {
276- match crate :: indirect_draw_validation:: IndirectDrawValidation :: new (
277- raw_device. as_ref ( ) ,
278259 & desc. required_features ,
279- ) {
280- Ok ( indirect_draw_validation) => Some ( indirect_draw_validation) ,
281- Err ( e) => {
282- log:: error!( "indirect-draw-validation error: {e:?}" ) ;
283- return Err ( DeviceError :: Lost ) ;
284- }
285- }
260+ ) ?)
286261 } else {
287262 None
288263 } ;
@@ -333,7 +308,6 @@ impl Device {
333308 // By starting at one, we can put the result in a NonZeroU64.
334309 last_acceleration_structure_build_command_index : AtomicU64 :: new ( 1 ) ,
335310 indirect_validation,
336- indirect_draw_validation,
337311 } )
338312 }
339313
@@ -671,11 +645,8 @@ impl Device {
671645 let buffer =
672646 unsafe { self . raw ( ) . create_buffer ( & hal_desc) } . map_err ( |e| self . handle_hal_error ( e) ) ?;
673647
674- let raw_indirect_validation_bind_group =
675- self . create_indirect_validation_bind_group ( buffer. as_ref ( ) , desc. size , desc. usage ) ?;
676-
677- let raw_indirect_draw_validation_bind_group = self
678- . create_indirect_draw_validation_bind_group ( buffer. as_ref ( ) , desc. size , desc. usage ) ?;
648+ let indirect_validation_bind_groups =
649+ self . create_indirect_validation_bind_groups ( buffer. as_ref ( ) , desc. size , desc. usage ) ?;
679650
680651 let buffer = Buffer {
681652 raw : Snatchable :: new ( buffer) ,
@@ -690,8 +661,7 @@ impl Device {
690661 label : desc. label . to_string ( ) ,
691662 tracking_data : TrackingData :: new ( self . tracker_indices . buffers . clone ( ) ) ,
692663 bind_groups : Mutex :: new ( rank:: BUFFER_BIND_GROUPS , WeakVec :: new ( ) ) ,
693- raw_indirect_validation_bind_group,
694- raw_indirect_draw_validation_bind_group,
664+ indirect_validation_bind_groups,
695665 } ;
696666
697667 let buffer = Arc :: new ( buffer) ;
@@ -773,7 +743,7 @@ impl Device {
773743 hal_buffer : Box < dyn hal:: DynBuffer > ,
774744 desc : & resource:: BufferDescriptor ,
775745 ) -> ( Fallible < Buffer > , Option < resource:: CreateBufferError > ) {
776- let raw_indirect_validation_bind_group = match self . create_indirect_validation_bind_group (
746+ let indirect_validation_bind_groups = match self . create_indirect_validation_bind_groups (
777747 hal_buffer. as_ref ( ) ,
778748 desc. size ,
779749 desc. usage ,
@@ -782,13 +752,6 @@ impl Device {
782752 Err ( e) => return ( Fallible :: Invalid ( Arc :: new ( desc. label . to_string ( ) ) ) , Some ( e) ) ,
783753 } ;
784754
785- let raw_indirect_draw_validation_bind_group = match self
786- . create_indirect_draw_validation_bind_group ( hal_buffer. as_ref ( ) , desc. size , desc. usage )
787- {
788- Ok ( ok) => ok,
789- Err ( e) => return ( Fallible :: Invalid ( Arc :: new ( desc. label . to_string ( ) ) ) , Some ( e) ) ,
790- } ;
791-
792755 unsafe { self . raw ( ) . add_raw_buffer ( & * hal_buffer) } ;
793756
794757 let buffer = Buffer {
@@ -804,8 +767,7 @@ impl Device {
804767 label : desc. label . to_string ( ) ,
805768 tracking_data : TrackingData :: new ( self . tracker_indices . buffers . clone ( ) ) ,
806769 bind_groups : Mutex :: new ( rank:: BUFFER_BIND_GROUPS , WeakVec :: new ( ) ) ,
807- raw_indirect_validation_bind_group,
808- raw_indirect_draw_validation_bind_group,
770+ indirect_validation_bind_groups,
809771 } ;
810772
811773 let buffer = Arc :: new ( buffer) ;
@@ -818,12 +780,13 @@ impl Device {
818780 ( Fallible :: Valid ( buffer) , None )
819781 }
820782
821- fn create_indirect_validation_bind_group (
783+ fn create_indirect_validation_bind_groups (
822784 & self ,
823785 raw_buffer : & dyn hal:: DynBuffer ,
824786 buffer_size : u64 ,
825787 usage : wgt:: BufferUsages ,
826- ) -> Result < Snatchable < Box < dyn hal:: DynBindGroup > > , resource:: CreateBufferError > {
788+ ) -> Result < Snatchable < crate :: indirect_validation:: BindGroups > , resource:: CreateBufferError >
789+ {
827790 if !usage. contains ( wgt:: BufferUsages :: INDIRECT ) {
828791 return Ok ( Snatchable :: empty ( ) ) ;
829792 }
@@ -832,40 +795,19 @@ impl Device {
832795 return Ok ( Snatchable :: empty ( ) ) ;
833796 } ;
834797
835- let bind_group = indirect_validation
836- . create_src_bind_group ( self . raw ( ) , & self . limits , buffer_size, raw_buffer)
837- . map_err ( resource:: CreateBufferError :: IndirectValidationBindGroup ) ?;
838-
839- let Some ( bind_group) = bind_group else {
840- return Ok ( Snatchable :: empty ( ) ) ;
841- } ;
842-
843- Ok ( Snatchable :: new ( bind_group) )
844- }
798+ let bind_groups = crate :: indirect_validation:: BindGroups :: new (
799+ indirect_validation,
800+ self ,
801+ buffer_size,
802+ raw_buffer,
803+ )
804+ . map_err ( resource:: CreateBufferError :: IndirectValidationBindGroup ) ?;
845805
846- fn create_indirect_draw_validation_bind_group (
847- & self ,
848- raw_buffer : & dyn hal:: DynBuffer ,
849- buffer_size : u64 ,
850- usage : wgt:: BufferUsages ,
851- ) -> Result < Snatchable < Box < dyn hal:: DynBindGroup > > , resource:: CreateBufferError > {
852- if !usage. contains ( wgt:: BufferUsages :: INDIRECT ) {
853- return Ok ( Snatchable :: empty ( ) ) ;
806+ if let Some ( bind_groups) = bind_groups {
807+ Ok ( Snatchable :: new ( bind_groups) )
808+ } else {
809+ Ok ( Snatchable :: empty ( ) )
854810 }
855-
856- let Some ( ref indirect_draw_validation) = self . indirect_draw_validation else {
857- return Ok ( Snatchable :: empty ( ) ) ;
858- } ;
859-
860- let bind_group = indirect_draw_validation
861- . create_src_bind_group ( self . raw ( ) , & self . adapter . limits ( ) , buffer_size, raw_buffer)
862- . map_err ( resource:: CreateBufferError :: IndirectValidationBindGroup ) ?;
863-
864- let Some ( bind_group) = bind_group else {
865- return Ok ( Snatchable :: empty ( ) ) ;
866- } ;
867-
868- Ok ( Snatchable :: new ( bind_group) )
869811 }
870812
871813 pub ( crate ) fn create_texture (
0 commit comments