diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-09-04 17:29:07 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-09-04 17:29:07 +0400 |
commit | adea12cb01e4c4f18f345dfbbf49e9e622192e4e (patch) | |
tree | b43018344c696e4d59437fabc7f17f5b9d6a8e80 /intern/cycles/device/device_opencl.cpp | |
parent | 68563134d4800be4eb46aa6b598fd719cdaf2980 (diff) |
Cycles: merge of changes from tomato branch.
Regular rendering now works tiled, and supports save buffers to save memory
during render and cache render results.
Brick texture node by Thomas.
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Textures#Brick_Texture
Image texture Blended Box Mapping.
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Textures#Image_Texture
http://mango.blender.org/production/blended_box/
Various bug fixes by Sergey and Campbell.
* Fix for reading freed memory in some node setups.
* Fix incorrect memory read when synchronizing mesh motion.
* Fix crash appearing when direct light usage is different on different layers.
* Fix for vector pass gives wrong result in some circumstances.
* Fix for wrong resolution used for rendering Render Layer node.
* Option to cancel rendering when doing initial synchronization.
* No more texture limit when using CPU render.
* Many fixes for new tiled rendering.
Diffstat (limited to 'intern/cycles/device/device_opencl.cpp')
-rw-r--r-- | intern/cycles/device/device_opencl.cpp | 82 |
1 files changed, 57 insertions, 25 deletions
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index c9ec7c75063..3c78b4895ae 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -25,6 +25,8 @@ #include "device.h" #include "device_intern.h" +#include "buffers.h" + #include "util_foreach.h" #include "util_map.h" #include "util_math.h" @@ -41,6 +43,7 @@ CCL_NAMESPACE_BEGIN class OpenCLDevice : public Device { public: + TaskPool task_pool; cl_context cxContext; cl_command_queue cqCommandQueue; cl_platform_id cpPlatform; @@ -435,6 +438,8 @@ public: ~OpenCLDevice() { + task_pool.stop(); + if(null_mem) clReleaseMemObject(CL_MEM_PTR(null_mem)); @@ -540,19 +545,19 @@ public: return global_size + ((r == 0)? 0: group_size - r); } - void path_trace(DeviceTask& task) + void path_trace(RenderTile& rtile, int sample) { /* cast arguments to cl types */ cl_mem d_data = CL_MEM_PTR(const_mem_map["__data"]->device_pointer); - cl_mem d_buffer = CL_MEM_PTR(task.buffer); - cl_mem d_rng_state = CL_MEM_PTR(task.rng_state); - cl_int d_x = task.x; - cl_int d_y = task.y; - cl_int d_w = task.w; - cl_int d_h = task.h; - cl_int d_sample = task.sample; - cl_int d_offset = task.offset; - cl_int d_stride = task.stride; + cl_mem d_buffer = CL_MEM_PTR(rtile.buffer); + cl_mem d_rng_state = CL_MEM_PTR(rtile.rng_state); + cl_int d_x = rtile.x; + cl_int d_y = rtile.y; + cl_int d_w = rtile.w; + cl_int d_h = rtile.h; + cl_int d_sample = sample; + cl_int d_offset = rtile.offset; + cl_int d_stride = rtile.stride; /* sample arguments */ int narg = 0; @@ -613,12 +618,12 @@ public: return err; } - void tonemap(DeviceTask& task) + void tonemap(DeviceTask& task, device_ptr buffer, device_ptr rgba) { /* cast arguments to cl types */ cl_mem d_data = CL_MEM_PTR(const_mem_map["__data"]->device_pointer); - cl_mem d_rgba = CL_MEM_PTR(task.rgba); - cl_mem d_buffer = CL_MEM_PTR(task.buffer); + cl_mem d_rgba = CL_MEM_PTR(rgba); + cl_mem d_buffer = CL_MEM_PTR(buffer); cl_int d_x = task.x; cl_int d_y = task.y; cl_int d_w = task.w; @@ -667,30 +672,57 @@ public: opencl_assert(clFinish(cqCommandQueue)); } - void task_add(DeviceTask& maintask) + void thread_run(DeviceTask *task) { - list<DeviceTask> tasks; + if(task->type == DeviceTask::TONEMAP) { + tonemap(*task, task->buffer, task->rgba); + } + else if(task->type == DeviceTask::PATH_TRACE) { + RenderTile tile; + + /* keep rendering tiles until done */ + while(task->acquire_tile(this, tile)) { + int start_sample = tile.start_sample; + int end_sample = tile.start_sample + tile.num_samples; - /* arbitrary limit to work around apple ATI opencl issue */ - if(platform_name == "Apple") - maintask.split_max_size(tasks, 76800); - else - tasks.push_back(maintask); + for(int sample = start_sample; sample < end_sample; sample++) { + if (task->get_cancel()) + break; + + path_trace(tile, sample); + + tile.sample = sample + 1; - foreach(DeviceTask& task, tasks) { - if(task.type == DeviceTask::TONEMAP) - tonemap(task); - else if(task.type == DeviceTask::PATH_TRACE) - path_trace(task); + task->update_progress(tile); + } + + task->release_tile(tile); + } } } + class OpenCLDeviceTask : public DeviceTask { + public: + OpenCLDeviceTask(OpenCLDevice *device, DeviceTask& task) + : DeviceTask(task) + { + run = function_bind(&OpenCLDevice::thread_run, device, this); + } + }; + + void task_add(DeviceTask& task) + { + task_pool.push(new OpenCLDeviceTask(this, task)); + } + void task_wait() { + task_pool.wait_work(); } void task_cancel() { + task_pool.cancel(); } }; |