@@ -45,6 +45,8 @@ impl BufferBuilder {
4545 return self ;
4646 }
4747
48+ /// Builds & binds a buffer of memory to the GPU. If the buffer cannot be
49+ /// bound to the GPU, the buffer memory is freed before the error is returned.
4850 pub fn build < RenderBackend : super :: internal:: Backend > (
4951 self ,
5052 gpu : & mut Gpu < RenderBackend > ,
@@ -57,8 +59,9 @@ impl BufferBuilder {
5759 let logical_device = super :: internal:: logical_device_for ( gpu) ;
5860 let physical_device = super :: internal:: physical_device_for ( gpu) ;
5961
60- // Allocate buffer
61- let mut buffer_result = unsafe {
62+ // TODO(vmarcella): Add the ability for the user to specify the memory
63+ // properties (I.E. SparseFlags::SPARSE_MEMORY).
64+ let buffer_result = unsafe {
6265 logical_device. create_buffer (
6366 self . buffer_length as u64 ,
6467 self . usage ,
@@ -87,6 +90,7 @@ impl BufferBuilder {
8790 . map ( |( id, _) | MemoryTypeId ( id) )
8891 . unwrap ( ) ;
8992
93+ // Allocates the memory on the GPU for the buffer.
9094 let buffer_memory_allocation =
9195 unsafe { logical_device. allocate_memory ( memory_type, requirements. size ) } ;
9296
@@ -96,6 +100,7 @@ impl BufferBuilder {
96100
97101 let buffer_memory = buffer_memory_allocation. unwrap ( ) ;
98102
103+ // Bind the buffer to the GPU memory
99104 let buffer_binding = unsafe {
100105 logical_device. bind_buffer_memory ( & buffer_memory, 0 , & mut buffer)
101106 } ;
0 commit comments