Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/metal/mtl_vertex_buffer.mm
| Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | if (src->vbo_) { | ||||
| MTLContext *ctx = MTLContext::get(); | MTLContext *ctx = MTLContext::get(); | ||||
| BLI_assert(ctx); | BLI_assert(ctx); | ||||
| /* Ensure destination does not have an active VBO. */ | /* Ensure destination does not have an active VBO. */ | ||||
| BLI_assert(dst->vbo_ == nullptr); | BLI_assert(dst->vbo_ == nullptr); | ||||
| /* Allocate VBO for destination vertbuf. */ | /* Allocate VBO for destination vertbuf. */ | ||||
| uint length = src->vbo_->get_size(); | uint length = src->vbo_->get_size(); | ||||
| dst->vbo_ = MTLContext::get_global_memory_manager().allocate( | dst->vbo_ = MTLContext::get_global_memory_manager()->allocate( | ||||
| length, (dst->get_usage_type() != GPU_USAGE_DEVICE_ONLY)); | length, (dst->get_usage_type() != GPU_USAGE_DEVICE_ONLY)); | ||||
| dst->alloc_size_ = length; | dst->alloc_size_ = length; | ||||
| /* Fetch Metal buffer handles. */ | /* Fetch Metal buffer handles. */ | ||||
| id<MTLBuffer> src_buffer = src->vbo_->get_metal_buffer(); | id<MTLBuffer> src_buffer = src->vbo_->get_metal_buffer(); | ||||
| id<MTLBuffer> dest_buffer = dst->vbo_->get_metal_buffer(); | id<MTLBuffer> dest_buffer = dst->vbo_->get_metal_buffer(); | ||||
| /* Use blit encoder to copy data to duplicate buffer allocation. */ | /* Use blit encoder to copy data to duplicate buffer allocation. */ | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | if (requires_reallocation || (new_data_ready && contents_in_flight_)) { | ||||
| if (requires_reallocation) { | if (requires_reallocation) { | ||||
| this->flag &= ~GPU_VERTBUF_DATA_UPLOADED; | this->flag &= ~GPU_VERTBUF_DATA_UPLOADED; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Create MTLBuffer of requested size. */ | /* Create MTLBuffer of requested size. */ | ||||
| if (vbo_ == nullptr) { | if (vbo_ == nullptr) { | ||||
| vbo_ = MTLContext::get_global_memory_manager().allocate( | vbo_ = MTLContext::get_global_memory_manager()->allocate( | ||||
| required_size, (this->get_usage_type() != GPU_USAGE_DEVICE_ONLY)); | required_size, (this->get_usage_type() != GPU_USAGE_DEVICE_ONLY)); | ||||
| vbo_->set_label(@"Vertex Buffer"); | vbo_->set_label(@"Vertex Buffer"); | ||||
| BLI_assert(vbo_ != nullptr); | BLI_assert(vbo_ != nullptr); | ||||
| BLI_assert(vbo_->get_metal_buffer() != nil); | BLI_assert(vbo_->get_metal_buffer() != nil); | ||||
| is_wrapper_ = false; | is_wrapper_ = false; | ||||
| alloc_size_ = required_size; | alloc_size_ = required_size; | ||||
| contents_in_flight_ = false; | contents_in_flight_ = false; | ||||
| ▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines | |||||