@@ -720,23 +720,32 @@ impl crate::CommandEncoder for super::CommandEncoder {
720
720
if let Some(ref encoder) = self.state.render {
721
721
let mut changes_sizes_buffer = false;
722
722
for index in 0..group.counters.vs.buffers {
723
- let buf = &group.buffers[index as usize];
724
- let mut offset = buf.offset;
725
- if let Some(dyn_index) = buf.dynamic_index {
726
- offset += dynamic_offsets[dyn_index as usize] as wgt::BufferAddress;
727
- }
728
- encoder.set_vertex_buffer(
729
- (bg_info.base_resource_indices.vs.buffers + index) as u64,
730
- Some(buf.ptr.as_native()),
731
- offset,
732
- );
733
- if let Some(size) = buf.binding_size {
734
- let br = naga::ResourceBinding {
735
- group: group_index,
736
- binding: buf.binding_location,
737
- };
738
- self.state.storage_buffer_length_map.insert(br, size);
739
- changes_sizes_buffer = true;
723
+ match &group.buffers[index as usize] {
724
+ super::BufferResource::Buffer(binding) => {
725
+ let mut offset = binding.offset;
726
+ if let Some(dyn_index) = binding.dynamic_index {
727
+ offset += dynamic_offsets[dyn_index as usize] as wgt::BufferAddress;
728
+ }
729
+ encoder.set_vertex_buffer(
730
+ (bg_info.base_resource_indices.vs.buffers + index) as u64,
731
+ Some(binding.ptr.as_native()),
732
+ offset,
733
+ );
734
+ if let Some(size) = binding.binding_size {
735
+ let br = naga::ResourceBinding {
736
+ group: group_index,
737
+ binding: binding.binding_location,
738
+ };
739
+ self.state.storage_buffer_length_map.insert(br, size);
740
+ changes_sizes_buffer = true;
741
+ }
742
+ }
743
+ super::BufferResource::AccelerationStructure(ptr) => {
744
+ encoder.set_vertex_acceleration_structure(
745
+ (bg_info.base_resource_indices.vs.buffers + index) as u64,
746
+ Some(ptr.as_native()),
747
+ );
748
+ }
740
749
}
741
750
}
742
751
if changes_sizes_buffer {
@@ -754,23 +763,32 @@ impl crate::CommandEncoder for super::CommandEncoder {
754
763
755
764
changes_sizes_buffer = false;
756
765
for index in 0..group.counters.fs.buffers {
757
- let buf = &group.buffers[(group.counters.vs.buffers + index) as usize];
758
- let mut offset = buf.offset;
759
- if let Some(dyn_index) = buf.dynamic_index {
760
- offset += dynamic_offsets[dyn_index as usize] as wgt::BufferAddress;
761
- }
762
- encoder.set_fragment_buffer(
763
- (bg_info.base_resource_indices.fs.buffers + index) as u64,
764
- Some(buf.ptr.as_native()),
765
- offset,
766
- );
767
- if let Some(size) = buf.binding_size {
768
- let br = naga::ResourceBinding {
769
- group: group_index,
770
- binding: buf.binding_location,
771
- };
772
- self.state.storage_buffer_length_map.insert(br, size);
773
- changes_sizes_buffer = true;
766
+ match &group.buffers[(group.counters.vs.buffers + index) as usize] {
767
+ super::BufferResource::Buffer(binding) => {
768
+ let mut offset = binding.offset;
769
+ if let Some(dyn_index) = binding.dynamic_index {
770
+ offset += dynamic_offsets[dyn_index as usize] as wgt::BufferAddress;
771
+ }
772
+ encoder.set_fragment_buffer(
773
+ (bg_info.base_resource_indices.fs.buffers + index) as u64,
774
+ Some(binding.ptr.as_native()),
775
+ offset,
776
+ );
777
+ if let Some(size) = binding.binding_size {
778
+ let br = naga::ResourceBinding {
779
+ group: group_index,
780
+ binding: binding.binding_location,
781
+ };
782
+ self.state.storage_buffer_length_map.insert(br, size);
783
+ changes_sizes_buffer = true;
784
+ }
785
+ }
786
+ super::BufferResource::AccelerationStructure(ptr) => {
787
+ encoder.set_fragment_acceleration_structure(
788
+ (bg_info.base_resource_indices.fs.buffers + index) as u64,
789
+ Some(ptr.as_native()),
790
+ );
791
+ }
774
792
}
775
793
}
776
794
if changes_sizes_buffer {
@@ -832,22 +850,32 @@ impl crate::CommandEncoder for super::CommandEncoder {
832
850
let mut changes_sizes_buffer = false;
833
851
for index in 0..group.counters.cs.buffers {
834
852
let buf = &group.buffers[(index_base.buffers + index) as usize];
835
- let mut offset = buf.offset;
836
- if let Some(dyn_index) = buf.dynamic_index {
837
- offset += dynamic_offsets[dyn_index as usize] as wgt::BufferAddress;
838
- }
839
- encoder.set_buffer(
840
- (bg_info.base_resource_indices.cs.buffers + index) as u64,
841
- Some(buf.ptr.as_native()),
842
- offset,
843
- );
844
- if let Some(size) = buf.binding_size {
845
- let br = naga::ResourceBinding {
846
- group: group_index,
847
- binding: buf.binding_location,
848
- };
849
- self.state.storage_buffer_length_map.insert(br, size);
850
- changes_sizes_buffer = true;
853
+ match buf {
854
+ super::BufferResource::Buffer(binding) => {
855
+ let mut offset = binding.offset;
856
+ if let Some(dyn_index) = binding.dynamic_index {
857
+ offset += dynamic_offsets[dyn_index as usize] as wgt::BufferAddress;
858
+ }
859
+ encoder.set_buffer(
860
+ (bg_info.base_resource_indices.cs.buffers + index) as u64,
861
+ Some(binding.ptr.as_native()),
862
+ offset,
863
+ );
864
+ if let Some(size) = binding.binding_size {
865
+ let br = naga::ResourceBinding {
866
+ group: group_index,
867
+ binding: binding.binding_location,
868
+ };
869
+ self.state.storage_buffer_length_map.insert(br, size);
870
+ changes_sizes_buffer = true;
871
+ }
872
+ }
873
+ super::BufferResource::AccelerationStructure(ptr) => {
874
+ encoder.set_acceleration_structure(
875
+ (bg_info.base_resource_indices.cs.buffers + index) as u64,
876
+ Some(ptr.as_native()),
877
+ );
878
+ }
851
879
}
852
880
}
853
881
if changes_sizes_buffer {
0 commit comments