Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/opencl/memory_manager.cpp
| Show All 22 Lines | |||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| void MemoryManager::DeviceBuffer::add_allocation(Allocation& allocation) | void MemoryManager::DeviceBuffer::add_allocation(Allocation& allocation) | ||||
| { | { | ||||
| allocations.push_back(&allocation); | allocations.push_back(&allocation); | ||||
| } | } | ||||
| void MemoryManager::DeviceBuffer::update_device_memory(OpenCLDeviceBase *device) | void MemoryManager::DeviceBuffer::update_device_memory(OpenCLDevice *device) | ||||
| { | { | ||||
| bool need_realloc = false; | bool need_realloc = false; | ||||
| /* Calculate total size and remove any freed. */ | /* Calculate total size and remove any freed. */ | ||||
| size_t total_size = 0; | size_t total_size = 0; | ||||
| for(int i = allocations.size()-1; i >= 0; i--) { | for(int i = allocations.size()-1; i >= 0; i--) { | ||||
| Allocation* allocation = allocations[i]; | Allocation* allocation = allocations[i]; | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | foreach(Allocation* allocation, allocations) { | ||||
| offset += allocation->size; | offset += allocation->size; | ||||
| } | } | ||||
| } | } | ||||
| /* Not really necessary, but seems to improve responsiveness for some reason. */ | /* Not really necessary, but seems to improve responsiveness for some reason. */ | ||||
| clFinish(device->cqCommandQueue); | clFinish(device->cqCommandQueue); | ||||
| } | } | ||||
| void MemoryManager::DeviceBuffer::free(OpenCLDeviceBase *) | void MemoryManager::DeviceBuffer::free(OpenCLDevice *) | ||||
| { | { | ||||
| buffer->free(); | buffer->free(); | ||||
| } | } | ||||
| MemoryManager::DeviceBuffer* MemoryManager::smallest_device_buffer() | MemoryManager::DeviceBuffer* MemoryManager::smallest_device_buffer() | ||||
| { | { | ||||
| DeviceBuffer* smallest = device_buffers; | DeviceBuffer* smallest = device_buffers; | ||||
| foreach(DeviceBuffer& device_buffer, device_buffers) { | foreach(DeviceBuffer& device_buffer, device_buffers) { | ||||
| if(device_buffer.size < smallest->size) { | if(device_buffer.size < smallest->size) { | ||||
| smallest = &device_buffer; | smallest = &device_buffer; | ||||
| } | } | ||||
| } | } | ||||
| return smallest; | return smallest; | ||||
| } | } | ||||
| MemoryManager::MemoryManager(OpenCLDeviceBase *device) | MemoryManager::MemoryManager(OpenCLDevice *device) | ||||
| : device(device), need_update(false) | : device(device), need_update(false) | ||||
| { | { | ||||
| foreach(DeviceBuffer& device_buffer, device_buffers) { | foreach(DeviceBuffer& device_buffer, device_buffers) { | ||||
| device_buffer.buffer = | device_buffer.buffer = | ||||
| new device_only_memory<uchar>(device, "memory manager buffer"); | new device_only_memory<uchar>(device, "memory manager buffer"); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines | |||||