Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/device_cuda.cpp
| Show All 19 Lines | |||||
| #include "device.h" | #include "device.h" | ||||
| #include "device_intern.h" | #include "device_intern.h" | ||||
| #include "buffers.h" | #include "buffers.h" | ||||
| #include "cuew.h" | #include "cuew.h" | ||||
| #include "util_debug.h" | #include "util_debug.h" | ||||
| #include "util_foreach.h" | |||||
| #include "util_map.h" | #include "util_map.h" | ||||
| #include "util_opengl.h" | #include "util_opengl.h" | ||||
| #include "util_path.h" | #include "util_path.h" | ||||
| #include "util_system.h" | #include "util_system.h" | ||||
| #include "util_types.h" | #include "util_types.h" | ||||
| #include "util_time.h" | #include "util_time.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| ▲ Show 20 Lines • Show All 925 Lines • ▼ Show 20 Lines | public: | ||||
| : DeviceTask(task) | : DeviceTask(task) | ||||
| { | { | ||||
| run = function_bind(&CUDADevice::thread_run, device, this); | run = function_bind(&CUDADevice::thread_run, device, this); | ||||
| } | } | ||||
| }; | }; | ||||
| int get_split_task_count(DeviceTask& task) | int get_split_task_count(DeviceTask& task) | ||||
| { | { | ||||
| if (task.type == DeviceTask::SHADER) | |||||
| return task.get_subtask_count(TaskScheduler::num_threads(), 1024 * 1024); | |||||
| else | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| void task_add(DeviceTask& task) | void task_add(DeviceTask& task) | ||||
| { | { | ||||
| if(task.type == DeviceTask::FILM_CONVERT) { | if(task.type == DeviceTask::FILM_CONVERT) { | ||||
| /* must be done in main thread due to opengl access */ | /* must be done in main thread due to opengl access */ | ||||
| film_convert(task, task.buffer, task.rgba_byte, task.rgba_half); | film_convert(task, task.buffer, task.rgba_byte, task.rgba_half); | ||||
| cuda_push_context(); | cuda_push_context(); | ||||
| cuda_assert(cuCtxSynchronize()); | cuda_assert(cuCtxSynchronize()); | ||||
| cuda_pop_context(); | cuda_pop_context(); | ||||
| } | } | ||||
| else if(task.type == DeviceTask::SHADER) { | |||||
| /* split task into smaller ones */ | |||||
| list<DeviceTask> tasks; | |||||
| task.split(tasks, TaskScheduler::num_threads(), 1024 * 1024); | |||||
| foreach(DeviceTask& task, tasks) | |||||
| task_pool.push(new CUDADeviceTask(this, task)); | |||||
| } | |||||
| else { | else { | ||||
| task_pool.push(new CUDADeviceTask(this, task)); | task_pool.push(new CUDADeviceTask(this, task)); | ||||
| } | } | ||||
| } | } | ||||
| void task_wait() | void task_wait() | ||||
| { | { | ||||
| task_pool.wait(); | task_pool.wait(); | ||||
| ▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines | |||||