diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-10-23 20:32:59 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-10-24 02:25:13 +0300 |
commit | aa8b4c5d8124c0379eeee9eacd1a0887a573d7d7 (patch) | |
tree | 8ac75f05a26897b1aa4235a6fbfb93045ade3979 /intern/cycles | |
parent | 7ad9333fad25b9a7cabea0d659eaf724f89912c8 (diff) |
Code refactor: use device_only_memory and device_vector in more places.
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_cuda.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_split_kernel.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_split_kernel.h | 2 | ||||
-rw-r--r-- | intern/cycles/device/opencl/memory_manager.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/device/opencl/memory_manager.h | 2 | ||||
-rw-r--r-- | intern/cycles/device/opencl/opencl.h | 9 | ||||
-rw-r--r-- | intern/cycles/device/opencl/opencl_base.cpp | 18 | ||||
-rw-r--r-- | intern/cycles/device/opencl/opencl_split.cpp | 4 |
9 files changed, 23 insertions, 28 deletions
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 60c06462d4d..b4398f21014 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -745,7 +745,7 @@ public: while(task.acquire_tile(this, tile)) { if(tile.task == RenderTile::PATH_TRACE) { if(use_split_kernel) { - device_memory void_buffer(this, "void_buffer", MEM_READ_ONLY); + device_only_memory<uchar> void_buffer(this, "void_buffer"); split_kernel->path_trace(&task, tile, kgbuffer, void_buffer); } else { diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 1295ec86355..be606a92434 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1728,7 +1728,7 @@ public: while(task->acquire_tile(this, tile)) { if(tile.task == RenderTile::PATH_TRACE) { if(use_split_kernel()) { - device_memory void_buffer(this, "void_buffer", MEM_READ_ONLY); + device_only_memory<uchar> void_buffer(this, "void_buffer"); split_kernel->path_trace(task, tile, void_buffer, void_buffer); } else { diff --git a/intern/cycles/device/device_split_kernel.cpp b/intern/cycles/device/device_split_kernel.cpp index 5283bd60bd5..6c8befa89be 100644 --- a/intern/cycles/device/device_split_kernel.cpp +++ b/intern/cycles/device/device_split_kernel.cpp @@ -28,7 +28,7 @@ static const double alpha = 0.1; /* alpha for rolling average */ DeviceSplitKernel::DeviceSplitKernel(Device *device) : device(device), - split_data(device, "split_data", MEM_READ_WRITE), + split_data(device, "split_data"), ray_state(device, "ray_state", MEM_READ_WRITE), queue_index(device, "queue_index"), use_queues_flag(device, "use_queues_flag"), diff --git a/intern/cycles/device/device_split_kernel.h b/intern/cycles/device/device_split_kernel.h index 9c42cb58520..0647c664447 100644 --- a/intern/cycles/device/device_split_kernel.h +++ b/intern/cycles/device/device_split_kernel.h @@ -79,7 +79,7 @@ private: * kernel will be available to another kernel via this global * memory. */ - device_memory split_data; + device_only_memory<uchar> split_data; device_vector<uchar> ray_state; device_only_memory<int> queue_index; /* Array of size num_queues that tracks the size of each queue. */ diff --git a/intern/cycles/device/opencl/memory_manager.cpp b/intern/cycles/device/opencl/memory_manager.cpp index 6deed4e3f0d..e48367b8987 100644 --- a/intern/cycles/device/opencl/memory_manager.cpp +++ b/intern/cycles/device/opencl/memory_manager.cpp @@ -73,9 +73,8 @@ void MemoryManager::DeviceBuffer::update_device_memory(OpenCLDeviceBase *device) return; } - device_memory *new_buffer = new device_memory(device, - "memory manager buffer", - MEM_READ_ONLY); + device_only_memory<uchar> *new_buffer = + new device_only_memory<uchar>(device, "memory manager buffer"); new_buffer->resize(total_size); device->mem_alloc(*new_buffer); @@ -167,9 +166,8 @@ MemoryManager::MemoryManager(OpenCLDeviceBase *device) : device(device), need_update(false) { foreach(DeviceBuffer& device_buffer, device_buffers) { - device_buffer.buffer = new device_memory(device, - "memory manager buffer", - MEM_READ_ONLY); + device_buffer.buffer = + new device_only_memory<uchar>(device, "memory manager buffer"); } } diff --git a/intern/cycles/device/opencl/memory_manager.h b/intern/cycles/device/opencl/memory_manager.h index 7ef74a79834..b3d861275f0 100644 --- a/intern/cycles/device/opencl/memory_manager.h +++ b/intern/cycles/device/opencl/memory_manager.h @@ -56,7 +56,7 @@ private: }; struct DeviceBuffer { - device_memory *buffer; + device_only_memory<uchar> *buffer; vector<Allocation*> allocations; size_t size; /* Size of all allocations. */ diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h index 1dd4ad7df7f..55848c8112d 100644 --- a/intern/cycles/device/opencl/opencl.h +++ b/intern/cycles/device/opencl/opencl.h @@ -458,6 +458,11 @@ protected: } template<typename T> + ArgumentWrapper(device_only_memory<T>& argument) : size(sizeof(void*)), + pointer((void*)(&argument.device_pointer)) + { + } + template<typename T> ArgumentWrapper(T& argument) : size(sizeof(argument)), pointer(&argument) { @@ -543,9 +548,7 @@ private: friend class MemoryManager; static_assert_align(TextureInfo, 16); - - vector<TextureInfo> texture_info; - device_memory texture_info_buffer; + device_vector<TextureInfo> texture_info; typedef map<string, device_memory*> TexturesMap; TexturesMap textures; diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index 89ab1a43e68..90f461b4c98 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -138,11 +138,9 @@ OpenCLDeviceBase::OpenCLDeviceBase(DeviceInfo& info, Stats &stats, bool backgrou return; } - /* Allocate this right away so that texture_info_buffer is placed at offset 0 in the device memory buffers */ + /* Allocate this right away so that texture_info is placed at offset 0 in the device memory buffers */ texture_info.resize(1); - texture_info_buffer.resize(1); - texture_info_buffer.data_pointer = (device_ptr)&texture_info[0]; - memory_manager.alloc("texture_info", texture_info_buffer); + memory_manager.alloc("texture_info", texture_info); fprintf(stderr, "Device init success\n"); device_initialized = true; @@ -647,13 +645,9 @@ void OpenCLDeviceBase::flush_texture_buffers() } /* Realloc texture descriptors buffer. */ - memory_manager.free(texture_info_buffer); - + memory_manager.free(texture_info); texture_info.resize(num_slots); - texture_info_buffer.resize(num_slots * sizeof(TextureInfo)); - texture_info_buffer.data_pointer = (device_ptr)&texture_info[0]; - - memory_manager.alloc("texture_info", texture_info_buffer); + memory_manager.alloc("texture_info", texture_info); /* Fill in descriptors */ foreach(texture_slot_t& slot, texture_slots) { @@ -676,8 +670,8 @@ void OpenCLDeviceBase::flush_texture_buffers() } /* Force write of descriptors. */ - memory_manager.free(texture_info_buffer); - memory_manager.alloc("texture_info", texture_info_buffer); + memory_manager.free(texture_info); + memory_manager.alloc("texture_info", texture_info); } void OpenCLDeviceBase::film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half) diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp index 3edb2442070..c966ebe0c5e 100644 --- a/intern/cycles/device/opencl/opencl_split.cpp +++ b/intern/cycles/device/opencl/opencl_split.cpp @@ -127,8 +127,8 @@ public: } KernelGlobals; /* Allocate buffer for kernel globals */ - device_memory kgbuffer(this, "kernel_globals", MEM_READ_WRITE); - kgbuffer.resize(sizeof(KernelGlobals)); + device_only_memory<KernelGlobals> kgbuffer(this, "kernel_globals"); + kgbuffer.resize(1); mem_alloc(kgbuffer); /* Keep rendering tiles until done. */ |