[Bf-blender-cvs] [f869231] cycles_split_kernel: Cycles: Remove overloaded Device::mem_alloc function
Mai Lavelle
noreply at git.blender.org
Wed Dec 7 09:27:50 CET 2016
Commit: f869231abd1524a0d9f48639c8ec4bb41e10c141
Author: Mai Lavelle
Date: Wed Dec 7 03:08:17 2016 -0500
Branches: cycles_split_kernel
https://developer.blender.org/rBf869231abd1524a0d9f48639c8ec4bb41e10c141
Cycles: Remove overloaded Device::mem_alloc function
It was a bit confusing having two versions of this function, only one is
needed really. Added `device_memory::resize()` to take over the behavior
the overload provided.
===================================================================
M intern/cycles/device/device.h
M intern/cycles/device/device_cpu.cpp
M intern/cycles/device/device_memory.h
M intern/cycles/device/device_split_kernel.cpp
M intern/cycles/device/opencl/opencl.h
M intern/cycles/device/opencl/opencl_split.cpp
===================================================================
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index dd0df57..b5e8f25 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -254,25 +254,6 @@ public:
virtual void mem_zero(device_memory& mem) = 0;
virtual void mem_free(device_memory& mem) = 0;
- /* setup and allocate a device_memory object for use on device only (no host side buffer)*/
- void mem_alloc(device_memory& mem, size_t size, MemoryType type = MEM_READ_WRITE)
- {
- mem.data_type = device_type_traits<uchar>::data_type;
- mem.data_elements = 1;
- mem.data_pointer = 0;
- mem.data_size = size;
- mem.device_size = 0;
- mem.data_width = size;
- mem.data_height = 1;
- mem.data_depth = 1;
-
- assert(mem.data_elements > 0);
-
- mem.device_pointer = 0;
-
- mem_alloc(mem, type);
- }
-
/* constant memory */
virtual void const_copy_to(const char *name, void *host, size_t size) = 0;
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index fac0296..730bd5e 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -232,8 +232,6 @@ public:
task_pool.stop();
}
- using Device::mem_alloc;
-
void mem_alloc(device_memory& mem, MemoryType /*type*/)
{
mem.device_pointer = mem.data_pointer;
@@ -820,7 +818,8 @@ protected:
virtual void alloc_kernel_globals(device_memory& mem)
{
- mem_alloc(mem, sizeof(KernelGlobals));
+ mem.resize(sizeof(KernelGlobals));
+ mem_alloc(mem, MEM_READ_WRITE);
KernelGlobals *kg = (KernelGlobals*)mem.device_pointer;
*kg = thread_kernel_globals_init();
diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h
index 483e6aa..b69c3da 100644
--- a/intern/cycles/device/device_memory.h
+++ b/intern/cycles/device/device_memory.h
@@ -180,9 +180,10 @@ public:
/* device pointer */
device_ptr device_pointer;
- device_memory() {
- data_type = device_type_traits<float>::data_type;
- data_elements = device_type_traits<float>::num_elements;
+ device_memory()
+ {
+ data_type = device_type_traits<uchar>::data_type;
+ data_elements = device_type_traits<uchar>::num_elements;
data_pointer = 0;
data_size = 0;
device_size = 0;
@@ -193,6 +194,12 @@ public:
}
virtual ~device_memory() { assert(!device_pointer); }
+ void resize(size_t size)
+ {
+ data_size = size;
+ data_width = size;
+ }
+
protected:
/* no copying */
device_memory(const device_memory&);
diff --git a/intern/cycles/device/device_split_kernel.cpp b/intern/cycles/device/device_split_kernel.cpp
index db1e79d..65e7872 100644
--- a/intern/cycles/device/device_split_kernel.cpp
+++ b/intern/cycles/device/device_split_kernel.cpp
@@ -175,19 +175,25 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
(local_size[0] * local_size[1]);
/* Allocate work_pool_wgs memory. */
- device->mem_alloc(work_pool_wgs, max_work_groups * sizeof(unsigned int));
+ work_pool_wgs.resize(max_work_groups * sizeof(unsigned int));
+ device->mem_alloc(work_pool_wgs, MEM_READ_WRITE);
#endif /* __WORK_STEALING__ */
- device->mem_alloc(queue_index, NUM_QUEUES * sizeof(int));
- device->mem_alloc(use_queues_flag, sizeof(char));
+ queue_index.resize(NUM_QUEUES * sizeof(int));
+ device->mem_alloc(queue_index, MEM_READ_WRITE);
+
+ use_queues_flag.resize(sizeof(char));
+ device->mem_alloc(use_queues_flag, MEM_READ_WRITE);
+
device->alloc_kernel_globals(kgbuffer);
ray_state.resize(num_global_elements);
device->mem_alloc(ray_state, MEM_READ_WRITE);
- device->mem_alloc(split_data, split_data_buffer_size(num_global_elements,
- current_max_closure,
- per_thread_output_buffer_size));
+ split_data.resize(split_data_buffer_size(num_global_elements,
+ current_max_closure,
+ per_thread_output_buffer_size));
+ device->mem_alloc(split_data, MEM_READ_WRITE);
}
if(!device->enqueue_split_kernel_data_init(KernelDimensions(global_size, local_size),
diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h
index fe052f8..e5a5014 100644
--- a/intern/cycles/device/opencl/opencl.h
+++ b/intern/cycles/device/opencl/opencl.h
@@ -249,7 +249,6 @@ public:
vector<OpenCLProgram*> &programs) = 0;
void mem_alloc(device_memory& mem, MemoryType type);
- using Device::mem_alloc;
void mem_copy_to(device_memory& mem);
void mem_copy_from(device_memory& mem, int y, int w, int h, int elem);
void mem_zero(device_memory& mem);
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp
index 2ab78f8..6bbf1b5 100644
--- a/intern/cycles/device/opencl/opencl_split.cpp
+++ b/intern/cycles/device/opencl/opencl_split.cpp
@@ -99,7 +99,8 @@ public:
SplitParams split_param_data;
} KernelGlobals;
- mem_alloc(mem, sizeof(KernelGlobals));
+ mem.resize(sizeof(KernelGlobals));
+ mem_alloc(mem, MEM_READ_WRITE);
}
virtual void free_kernel_globals(device_memory& mem)
More information about the Bf-blender-cvs
mailing list