// Helper function that allocates a buffer to hold transforms for all draws in a batch and
// copies data into it
Helper function that allocates a buffer to hold transforms for all draws in a batch and
copies data into it
Helper function that allocates a buffer to hold transforms for all draws in a batch and copies data into it
fn create_buffer_from_atomic_once_stack<T: Copy + 'static>(
            dyn_resource_allocator_set: &DynResourceAllocatorSet,
            transforms: &Arc<AtomicOnceCellStack<T>>,
            memory_usage: RafxMemoryUsage,
            resource_type: RafxResourceType,
        ) -> Option<ResourceArc<BufferResource>> {
            if transforms.len() > 0 {
                let buffer_size = transforms.len() as u64 * std::mem::size_of::<T>() as u64;
                let buffer = dyn_resource_allocator_set
                    .device_context
                    .create_buffer(&RafxBufferDef {
                        size: buffer_size,
                        memory_usage,
                        resource_type,
                        ..Default::default()
                    })
                    .unwrap();
                let data = unsafe { transforms.get_all_unchecked() };
                buffer.copy_to_host_visible_buffer(data).unwrap();
                Some(dyn_resource_allocator_set.insert_buffer(buffer))
            } else {
                None
            }
        }
fn create_buffer_from_atomic_once_stack < T : Copy + ' static > ( dyn_resource_allocator_set : & DynResourceAllocatorSet , transforms : & Arc < AtomicOnceCellStack < T > > , memory_usage : RafxMemoryUsage , resource_type : RafxResourceType , ) -> Option < ResourceArc < BufferResource > > { if transforms . len ( ) > 0 { let buffer_size = transforms . len ( ) as u64 * std :: mem :: size_of :: < T > ( ) as u64 ; let buffer = dyn_resource_allocator_set . device_context . create_buffer ( & RafxBufferDef { size : buffer_size , memory_usage , resource_type , .. Default :: default ( ) } ) . unwrap ( ) ; let data = unsafe { transforms . get_all_unchecked ( ) } ; buffer . copy_to_host_visible_buffer ( data ) . unwrap ( ) ; Some ( dyn_resource_allocator_set . insert_buffer ( buffer ) ) } else { None } }
Helper function that allocates a buffer to hold transforms for all draws in a batch and
copies data into it
Helper function that allocates a buffer to hold transforms for all draws in a batch and copies data into it
dyn_resource_allocator_set
&DynResourceAllocatorSet
transforms
&Arc<AtomicOnceCellStack<T>>
memory_usage
RafxMemoryUsage
resource_type
RafxResourceType