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 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 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 split_data; device_vector ray_state; device_only_memory 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 *new_buffer = + new device_only_memory(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(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 *buffer; vector 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 @@ -457,6 +457,11 @@ protected: { } + template + ArgumentWrapper(device_only_memory& argument) : size(sizeof(void*)), + pointer((void*)(&argument.device_pointer)) + { + } template ArgumentWrapper(T& argument) : size(sizeof(argument)), pointer(&argument) @@ -543,9 +548,7 @@ private: friend class MemoryManager; static_assert_align(TextureInfo, 16); - - vector texture_info; - device_memory texture_info_buffer; + device_vector texture_info; typedef map 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 kgbuffer(this, "kernel_globals"); + kgbuffer.resize(1); mem_alloc(kgbuffer); /* Keep rendering tiles until done. */