Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mours <pmours@nvidia.com>2020-02-26 18:30:42 +0300
committerPatrick Mours <pmours@nvidia.com>2020-02-28 18:12:29 +0300
commitaf54bbd61c769c69891c9b39df19eb3cad9dafe2 (patch)
tree927403db3791116c9a760f6791426e8164ca9804 /intern/cycles/device
parent03e04d4db78972709ea9c6889afcf72fdaae80a2 (diff)
Cycles: Rework tile scheduling for denoising
This fixes denoising being delayed until after all rendering has finished. Instead, tile-based denoising is now part of the "RENDER" task again, so that it is all in one task and does not cause issues with dedicated task pools where tasks are serialized. Reviewed By: brecht Differential Revision: https://developer.blender.org/D6940
Diffstat (limited to 'intern/cycles/device')
-rw-r--r--intern/cycles/device/cuda/device_cuda_impl.cpp4
-rw-r--r--intern/cycles/device/device_cpu.cpp4
-rw-r--r--intern/cycles/device/device_multi.cpp23
-rw-r--r--intern/cycles/device/device_optix.cpp11
-rw-r--r--intern/cycles/device/device_task.cpp4
-rw-r--r--intern/cycles/device/device_task.h5
-rw-r--r--intern/cycles/device/opencl/device_opencl_impl.cpp4
7 files changed, 37 insertions, 18 deletions
diff --git a/intern/cycles/device/cuda/device_cuda_impl.cpp b/intern/cycles/device/cuda/device_cuda_impl.cpp
index f6a4f93a690..4a7c45d8b93 100644
--- a/intern/cycles/device/cuda/device_cuda_impl.cpp
+++ b/intern/cycles/device/cuda/device_cuda_impl.cpp
@@ -2144,7 +2144,7 @@ void CUDADevice::thread_run(DeviceTask *task)
{
CUDAContextScope scope(this);
- if (task->type == DeviceTask::RENDER || task->type == DeviceTask::DENOISE) {
+ if (task->type == DeviceTask::RENDER) {
DeviceRequestedFeatures requested_features;
if (use_split_kernel()) {
if (split_kernel == NULL) {
@@ -2159,7 +2159,7 @@ void CUDADevice::thread_run(DeviceTask *task)
RenderTile tile;
DenoisingTask denoising(this, *task);
- while (task->acquire_tile(this, tile)) {
+ while (task->acquire_tile(this, tile, task->tile_types)) {
if (tile.task == RenderTile::PATH_TRACE) {
if (use_split_kernel()) {
device_only_memory<uchar> void_buffer(this, "void_buffer");
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 795781ee072..1c9d2227ac3 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -511,7 +511,7 @@ class CPUDevice : public Device {
void thread_run(DeviceTask *task)
{
- if (task->type == DeviceTask::RENDER || task->type == DeviceTask::DENOISE)
+ if (task->type == DeviceTask::RENDER)
thread_render(*task);
else if (task->type == DeviceTask::SHADER)
thread_shader(*task);
@@ -927,7 +927,7 @@ class CPUDevice : public Device {
DenoisingTask denoising(this, task);
denoising.profiler = &kg->profiler;
- while (task.acquire_tile(this, tile)) {
+ while (task.acquire_tile(this, tile, task.tile_types)) {
if (tile.task == RenderTile::PATH_TRACE) {
if (use_split_kernel) {
device_only_memory<uchar> void_buffer(this, "void_buffer");
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index 8226221ea08..0044610eeb4 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -482,11 +482,24 @@ class MultiDevice : public Device {
void task_add(DeviceTask &task)
{
- list<SubDevice> &task_devices = denoising_devices.empty() ||
- (task.type != DeviceTask::DENOISE &&
- task.type != DeviceTask::DENOISE_BUFFER) ?
- devices :
- denoising_devices;
+ list<SubDevice> task_devices = devices;
+ if (!denoising_devices.empty()) {
+ if (task.type == DeviceTask::DENOISE_BUFFER) {
+ /* Denoising tasks should be redirected to the denoising devices entirely. */
+ task_devices = denoising_devices;
+ }
+ else if (task.type == DeviceTask::RENDER && (task.tile_types & RenderTile::DENOISE)) {
+ const uint tile_types = task.tile_types;
+ /* For normal rendering tasks only redirect the denoising part to the denoising devices.
+ * Do not need to split the task here, since they all run through 'acquire_tile'. */
+ task.tile_types = RenderTile::DENOISE;
+ foreach (SubDevice &sub, denoising_devices) {
+ sub.device->task_add(task);
+ }
+ /* Rendering itself should still be executed on the rendering devices. */
+ task.tile_types = tile_types ^ RenderTile::DENOISE;
+ }
+ }
list<DeviceTask> tasks;
task.split(tasks, task_devices.size());
diff --git a/intern/cycles/device/device_optix.cpp b/intern/cycles/device/device_optix.cpp
index 0121b89e9d8..61a5c74f69e 100644
--- a/intern/cycles/device/device_optix.cpp
+++ b/intern/cycles/device/device_optix.cpp
@@ -569,9 +569,14 @@ class OptiXDevice : public CUDADevice {
if (have_error())
return; // Abort early if there was an error previously
- if (task.type == DeviceTask::RENDER || task.type == DeviceTask::DENOISE) {
+ if (task.type == DeviceTask::RENDER) {
+ if (thread_index != 0) {
+ // Only execute denoising in a single thread (see also 'task_add')
+ task.tile_types &= ~RenderTile::DENOISE;
+ }
+
RenderTile tile;
- while (task.acquire_tile(this, tile)) {
+ while (task.acquire_tile(this, tile, task.tile_types)) {
if (tile.task == RenderTile::PATH_TRACE)
launch_render(task, tile, thread_index);
else if (tile.task == RenderTile::DENOISE)
@@ -1451,7 +1456,7 @@ class OptiXDevice : public CUDADevice {
return;
}
- if (task.type == DeviceTask::DENOISE || task.type == DeviceTask::DENOISE_BUFFER) {
+ if (task.type == DeviceTask::DENOISE_BUFFER) {
// Execute denoising in a single thread (e.g. to avoid race conditions during creation)
task_pool.push(new OptiXDeviceTask(this, task, 0));
return;
diff --git a/intern/cycles/device/device_task.cpp b/intern/cycles/device/device_task.cpp
index 8f15e8c8c1e..36522b874ab 100644
--- a/intern/cycles/device/device_task.cpp
+++ b/intern/cycles/device/device_task.cpp
@@ -68,7 +68,7 @@ int DeviceTask::get_subtask_count(int num, int max_size)
if (type == SHADER) {
num = min(shader_w, num);
}
- else if (type == RENDER || type == DENOISE) {
+ else if (type == RENDER) {
}
else {
num = min(h, num);
@@ -94,7 +94,7 @@ void DeviceTask::split(list<DeviceTask> &tasks, int num, int max_size)
tasks.push_back(task);
}
}
- else if (type == RENDER || type == DENOISE) {
+ else if (type == RENDER) {
for (int i = 0; i < num; i++)
tasks.push_back(*this);
}
diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h
index 0f718528b86..972f6131092 100644
--- a/intern/cycles/device/device_task.h
+++ b/intern/cycles/device/device_task.h
@@ -64,7 +64,7 @@ class DenoiseParams {
class DeviceTask : public Task {
public:
- typedef enum { RENDER, DENOISE, DENOISE_BUFFER, FILM_CONVERT, SHADER } Type;
+ typedef enum { RENDER, FILM_CONVERT, SHADER, DENOISE_BUFFER } Type;
Type type;
int x, y, w, h;
@@ -90,7 +90,7 @@ class DeviceTask : public Task {
void update_progress(RenderTile *rtile, int pixel_samples = -1);
- function<bool(Device *device, RenderTile &)> acquire_tile;
+ function<bool(Device *device, RenderTile &, uint)> acquire_tile;
function<void(long, int)> update_progress_sample;
function<void(RenderTile &)> update_tile_sample;
function<void(RenderTile &)> release_tile;
@@ -98,6 +98,7 @@ class DeviceTask : public Task {
function<void(RenderTile *, Device *)> map_neighbor_tiles;
function<void(RenderTile *, Device *)> unmap_neighbor_tiles;
+ uint tile_types;
DenoiseParams denoising;
bool denoising_from_render;
vector<int> denoising_frames;
diff --git a/intern/cycles/device/opencl/device_opencl_impl.cpp b/intern/cycles/device/opencl/device_opencl_impl.cpp
index 012f6dbe114..68cdfd5238c 100644
--- a/intern/cycles/device/opencl/device_opencl_impl.cpp
+++ b/intern/cycles/device/opencl/device_opencl_impl.cpp
@@ -1308,7 +1308,7 @@ void OpenCLDevice::thread_run(DeviceTask *task)
{
flush_texture_buffers();
- if (task->type == DeviceTask::RENDER || task->type == DeviceTask::DENOISE) {
+ if (task->type == DeviceTask::RENDER) {
RenderTile tile;
DenoisingTask denoising(this, *task);
@@ -1317,7 +1317,7 @@ void OpenCLDevice::thread_run(DeviceTask *task)
kgbuffer.alloc_to_device(1);
/* Keep rendering tiles until done. */
- while (task->acquire_tile(this, tile)) {
+ while (task->acquire_tile(this, tile, task->tile_types)) {
if (tile.task == RenderTile::PATH_TRACE) {
assert(tile.task == RenderTile::PATH_TRACE);
scoped_timer timer(&tile.buffers->render_time);