2016-09-14 23:47:54 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2011-2013 Blender Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef WITH_OPENCL
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "device/opencl/opencl.h"
|
2016-09-14 23:47:54 +02:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "render/buffers.h"
|
2016-09-14 23:47:54 +02:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "kernel/kernel_types.h"
|
|
|
|
#include "kernel/split/kernel_split_data_types.h"
|
2016-09-14 23:47:54 +02:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "device/device_split_kernel.h"
|
2017-02-22 08:10:02 -05:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "util/util_logging.h"
|
|
|
|
#include "util/util_md5.h"
|
|
|
|
#include "util/util_path.h"
|
|
|
|
#include "util/util_time.h"
|
2016-09-14 23:47:54 +02:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
class OpenCLSplitKernel;
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
static string get_build_options(OpenCLDeviceBase *device, const DeviceRequestedFeatures& requested_features)
|
|
|
|
{
|
|
|
|
string build_options = "-D__SPLIT_KERNEL__ ";
|
|
|
|
build_options += requested_features.get_build_options();
|
|
|
|
|
|
|
|
/* Set compute device build option. */
|
|
|
|
cl_device_type device_type;
|
2017-03-20 18:59:46 +01:00
|
|
|
OpenCLInfo::get_device_type(device->cdDevice, &device_type, &device->ciErr);
|
2017-02-22 08:10:02 -05:00
|
|
|
assert(device->ciErr == CL_SUCCESS);
|
|
|
|
if(device_type == CL_DEVICE_TYPE_GPU) {
|
|
|
|
build_options += " -D__COMPUTE_DEVICE_GPU__";
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
return build_options;
|
|
|
|
}
|
2016-09-14 23:47:54 +02:00
|
|
|
|
|
|
|
/* OpenCLDeviceSplitKernel's declaration/definition. */
|
|
|
|
class OpenCLDeviceSplitKernel : public OpenCLDeviceBase
|
|
|
|
{
|
|
|
|
public:
|
2017-02-22 08:10:02 -05:00
|
|
|
DeviceSplitKernel *split_kernel;
|
2016-09-14 23:47:54 +02:00
|
|
|
OpenCLProgram program_data_init;
|
2017-03-04 06:29:01 -05:00
|
|
|
OpenCLProgram program_state_buffer_size;
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
OpenCLDeviceSplitKernel(DeviceInfo& info, Stats &stats, bool background_);
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
~OpenCLDeviceSplitKernel()
|
|
|
|
{
|
|
|
|
task_pool.stop();
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
/* Release kernels */
|
|
|
|
program_data_init.release();
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
delete split_kernel;
|
|
|
|
}
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-05-05 13:31:21 +02:00
|
|
|
virtual bool show_samples() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
virtual bool load_kernels(const DeviceRequestedFeatures& requested_features,
|
|
|
|
vector<OpenCLDeviceBase::OpenCLProgram*> &programs)
|
2016-09-14 23:47:54 +02:00
|
|
|
{
|
2017-03-08 17:56:06 +01:00
|
|
|
bool single_program = OpenCLInfo::use_single_program();
|
2017-02-22 08:10:02 -05:00
|
|
|
program_data_init = OpenCLDeviceBase::OpenCLProgram(this,
|
2017-03-08 17:56:06 +01:00
|
|
|
single_program ? "split" : "split_data_init",
|
|
|
|
single_program ? "kernel_split.cl" : "kernel_data_init.cl",
|
2017-02-22 08:10:02 -05:00
|
|
|
get_build_options(this, requested_features));
|
2017-03-08 17:56:06 +01:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
program_data_init.add_kernel(ustring("path_trace_data_init"));
|
|
|
|
programs.push_back(&program_data_init);
|
|
|
|
|
2017-03-04 06:29:01 -05:00
|
|
|
program_state_buffer_size = OpenCLDeviceBase::OpenCLProgram(this,
|
2017-03-08 17:56:06 +01:00
|
|
|
single_program ? "split" : "split_state_buffer_size",
|
|
|
|
single_program ? "kernel_split.cl" : "kernel_state_buffer_size.cl",
|
2017-03-04 06:29:01 -05:00
|
|
|
get_build_options(this, requested_features));
|
|
|
|
program_state_buffer_size.add_kernel(ustring("path_trace_state_buffer_size"));
|
|
|
|
programs.push_back(&program_state_buffer_size);
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
return split_kernel->load_kernels(requested_features);
|
|
|
|
}
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
void thread_run(DeviceTask *task)
|
|
|
|
{
|
|
|
|
if(task->type == DeviceTask::FILM_CONVERT) {
|
|
|
|
film_convert(*task, task->buffer, task->rgba_byte, task->rgba_half);
|
|
|
|
}
|
|
|
|
else if(task->type == DeviceTask::SHADER) {
|
|
|
|
shader(*task);
|
|
|
|
}
|
|
|
|
else if(task->type == DeviceTask::PATH_TRACE) {
|
|
|
|
RenderTile tile;
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
/* Copy dummy KernelGlobals related to OpenCL from kernel_globals.h to
|
|
|
|
* fetch its size.
|
|
|
|
*/
|
|
|
|
typedef struct KernelGlobals {
|
|
|
|
ccl_constant KernelData *data;
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
|
|
|
ccl_global type *name;
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "kernel/kernel_textures.h"
|
2017-02-22 08:10:02 -05:00
|
|
|
#undef KERNEL_TEX
|
|
|
|
SplitData split_data;
|
|
|
|
SplitParams split_param_data;
|
|
|
|
} KernelGlobals;
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
/* Allocate buffer for kernel globals */
|
|
|
|
device_memory kgbuffer;
|
|
|
|
kgbuffer.resize(sizeof(KernelGlobals));
|
2016-12-13 20:45:09 -05:00
|
|
|
mem_alloc("kernel_globals", kgbuffer, MEM_READ_WRITE);
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
/* Keep rendering tiles until done. */
|
|
|
|
while(task->acquire_tile(this, tile)) {
|
|
|
|
split_kernel->path_trace(task,
|
2017-03-07 05:21:36 -05:00
|
|
|
tile,
|
|
|
|
kgbuffer,
|
|
|
|
*const_mem_map["__data"]);
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
/* Complete kernel execution before release tile. */
|
|
|
|
/* This helps in multi-device render;
|
|
|
|
* The device that reaches the critical-section function
|
|
|
|
* release_tile waits (stalling other devices from entering
|
|
|
|
* release_tile) for all kernels to complete. If device1 (a
|
|
|
|
* slow-render device) reaches release_tile first then it would
|
|
|
|
* stall device2 (a fast-render device) from proceeding to render
|
|
|
|
* next tile.
|
|
|
|
*/
|
|
|
|
clFinish(cqCommandQueue);
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
task->release_tile(tile);
|
|
|
|
}
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
mem_free(kgbuffer);
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
protected:
|
|
|
|
/* ** Those guys are for workign around some compiler-specific bugs ** */
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
string build_options_for_base_program(
|
|
|
|
const DeviceRequestedFeatures& requested_features)
|
2016-09-14 23:47:54 +02:00
|
|
|
{
|
2017-02-22 08:10:02 -05:00
|
|
|
return requested_features.get_build_options();
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
friend class OpenCLSplitKernel;
|
|
|
|
friend class OpenCLSplitKernelFunction;
|
|
|
|
};
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
class OpenCLSplitKernelFunction : public SplitKernelFunction {
|
|
|
|
public:
|
|
|
|
OpenCLDeviceSplitKernel* device;
|
|
|
|
OpenCLDeviceBase::OpenCLProgram program;
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
OpenCLSplitKernelFunction(OpenCLDeviceSplitKernel* device) : device(device) {}
|
|
|
|
~OpenCLSplitKernelFunction() { program.release(); }
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
virtual bool enqueue(const KernelDimensions& dim, device_memory& kg, device_memory& data)
|
2016-09-14 23:47:54 +02:00
|
|
|
{
|
2017-02-22 08:10:02 -05:00
|
|
|
device->kernel_set_args(program(), 0, kg, data);
|
|
|
|
|
|
|
|
device->ciErr = clEnqueueNDRangeKernel(device->cqCommandQueue,
|
|
|
|
program(),
|
|
|
|
2,
|
|
|
|
NULL,
|
|
|
|
dim.global_size,
|
|
|
|
dim.local_size,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
device->opencl_assert_err(device->ciErr, "clEnqueueNDRangeKernel");
|
|
|
|
|
|
|
|
if(device->ciErr != CL_SUCCESS) {
|
|
|
|
string message = string_printf("OpenCL error: %s in clEnqueueNDRangeKernel()",
|
|
|
|
clewErrorString(device->ciErr));
|
|
|
|
device->opencl_error(message);
|
|
|
|
return false;
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
class OpenCLSplitKernel : public DeviceSplitKernel {
|
|
|
|
OpenCLDeviceSplitKernel *device;
|
|
|
|
public:
|
|
|
|
explicit OpenCLSplitKernel(OpenCLDeviceSplitKernel *device) : DeviceSplitKernel(device), device(device) {
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
virtual SplitKernelFunction* get_split_kernel_function(string kernel_name,
|
|
|
|
const DeviceRequestedFeatures& requested_features)
|
2016-09-14 23:47:54 +02:00
|
|
|
{
|
2017-02-22 08:10:02 -05:00
|
|
|
OpenCLSplitKernelFunction* kernel = new OpenCLSplitKernelFunction(device);
|
|
|
|
|
2017-03-08 17:56:06 +01:00
|
|
|
bool single_program = OpenCLInfo::use_single_program();
|
|
|
|
kernel->program =
|
|
|
|
OpenCLDeviceBase::OpenCLProgram(device,
|
|
|
|
single_program ? "split" : "split_" + kernel_name,
|
|
|
|
single_program ? "kernel_split.cl" : "kernel_" + kernel_name + ".cl",
|
|
|
|
get_build_options(device, requested_features));
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
kernel->program.add_kernel(ustring("path_trace_" + kernel_name));
|
|
|
|
kernel->program.load();
|
|
|
|
|
|
|
|
if(!kernel->program.is_loaded()) {
|
|
|
|
delete kernel;
|
|
|
|
return NULL;
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
2017-02-22 08:10:02 -05:00
|
|
|
|
|
|
|
return kernel;
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
|
|
|
|
2017-03-11 05:23:11 -05:00
|
|
|
virtual uint64_t state_buffer_size(device_memory& kg, device_memory& data, size_t num_threads)
|
2017-03-04 06:29:01 -05:00
|
|
|
{
|
2017-03-11 05:23:11 -05:00
|
|
|
device_vector<uint64_t> size_buffer;
|
2017-03-04 06:29:01 -05:00
|
|
|
size_buffer.resize(1);
|
|
|
|
device->mem_alloc(NULL, size_buffer, MEM_READ_WRITE);
|
|
|
|
|
|
|
|
uint threads = num_threads;
|
|
|
|
device->kernel_set_args(device->program_state_buffer_size(), 0, kg, data, threads, size_buffer);
|
|
|
|
|
|
|
|
size_t global_size = 64;
|
|
|
|
device->ciErr = clEnqueueNDRangeKernel(device->cqCommandQueue,
|
|
|
|
device->program_state_buffer_size(),
|
|
|
|
1,
|
|
|
|
NULL,
|
|
|
|
&global_size,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
device->opencl_assert_err(device->ciErr, "clEnqueueNDRangeKernel");
|
|
|
|
|
2017-03-11 05:23:11 -05:00
|
|
|
device->mem_copy_from(size_buffer, 0, 1, 1, sizeof(uint64_t));
|
2017-03-04 06:29:01 -05:00
|
|
|
device->mem_free(size_buffer);
|
|
|
|
|
|
|
|
if(device->ciErr != CL_SUCCESS) {
|
|
|
|
string message = string_printf("OpenCL error: %s in clEnqueueNDRangeKernel()",
|
|
|
|
clewErrorString(device->ciErr));
|
|
|
|
device->opencl_error(message);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *size_buffer.get_data();
|
|
|
|
}
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
virtual bool enqueue_split_kernel_data_init(const KernelDimensions& dim,
|
|
|
|
RenderTile& rtile,
|
|
|
|
int num_global_elements,
|
|
|
|
device_memory& kernel_globals,
|
|
|
|
device_memory& kernel_data,
|
|
|
|
device_memory& split_data,
|
|
|
|
device_memory& ray_state,
|
|
|
|
device_memory& queue_index,
|
|
|
|
device_memory& use_queues_flag,
|
|
|
|
device_memory& work_pool_wgs
|
|
|
|
)
|
2016-09-14 23:47:54 +02:00
|
|
|
{
|
2017-02-22 08:10:02 -05:00
|
|
|
cl_int dQueue_size = dim.global_size[0] * dim.global_size[1];
|
2016-09-14 23:47:54 +02:00
|
|
|
|
|
|
|
/* Set the range of samples to be processed for every ray in
|
|
|
|
* path-regeneration logic.
|
|
|
|
*/
|
|
|
|
cl_int start_sample = rtile.start_sample;
|
|
|
|
cl_int end_sample = rtile.start_sample + rtile.num_samples;
|
|
|
|
|
|
|
|
cl_uint start_arg_index =
|
2017-02-22 08:10:02 -05:00
|
|
|
device->kernel_set_args(device->program_data_init(),
|
2016-09-14 23:47:54 +02:00
|
|
|
0,
|
2017-02-22 08:10:02 -05:00
|
|
|
kernel_globals,
|
|
|
|
kernel_data,
|
2017-03-07 05:21:36 -05:00
|
|
|
split_data,
|
2017-02-22 08:10:02 -05:00
|
|
|
num_global_elements,
|
2017-03-07 05:21:36 -05:00
|
|
|
ray_state,
|
2017-02-22 08:10:02 -05:00
|
|
|
rtile.rng_state);
|
2016-09-14 23:47:54 +02:00
|
|
|
|
|
|
|
/* TODO(sergey): Avoid map lookup here. */
|
|
|
|
#define KERNEL_TEX(type, ttype, name) \
|
2017-02-22 08:10:02 -05:00
|
|
|
device->set_kernel_arg_mem(device->program_data_init(), &start_arg_index, #name);
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "kernel/kernel_textures.h"
|
2016-09-14 23:47:54 +02:00
|
|
|
#undef KERNEL_TEX
|
|
|
|
|
|
|
|
start_arg_index +=
|
2017-02-22 08:10:02 -05:00
|
|
|
device->kernel_set_args(device->program_data_init(),
|
2016-09-14 23:47:54 +02:00
|
|
|
start_arg_index,
|
|
|
|
start_sample,
|
2017-02-22 08:10:02 -05:00
|
|
|
end_sample,
|
|
|
|
rtile.x,
|
|
|
|
rtile.y,
|
|
|
|
rtile.w,
|
|
|
|
rtile.h,
|
|
|
|
rtile.offset,
|
|
|
|
rtile.stride,
|
|
|
|
queue_index,
|
2016-09-14 23:47:54 +02:00
|
|
|
dQueue_size,
|
|
|
|
use_queues_flag,
|
|
|
|
work_pool_wgs,
|
2017-02-22 08:10:02 -05:00
|
|
|
rtile.num_samples,
|
2017-03-07 05:21:36 -05:00
|
|
|
rtile.buffer);
|
2016-09-14 23:47:54 +02:00
|
|
|
|
|
|
|
/* Enqueue ckPathTraceKernel_data_init kernel. */
|
2017-02-22 08:10:02 -05:00
|
|
|
device->ciErr = clEnqueueNDRangeKernel(device->cqCommandQueue,
|
|
|
|
device->program_data_init(),
|
|
|
|
2,
|
|
|
|
NULL,
|
|
|
|
dim.global_size,
|
|
|
|
dim.local_size,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
device->opencl_assert_err(device->ciErr, "clEnqueueNDRangeKernel");
|
|
|
|
|
|
|
|
if(device->ciErr != CL_SUCCESS) {
|
|
|
|
string message = string_printf("OpenCL error: %s in clEnqueueNDRangeKernel()",
|
|
|
|
clewErrorString(device->ciErr));
|
|
|
|
device->opencl_error(message);
|
2016-09-14 23:47:54 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
return true;
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
virtual int2 split_kernel_local_size()
|
2016-09-14 23:47:54 +02:00
|
|
|
{
|
2017-02-22 08:10:02 -05:00
|
|
|
return make_int2(64, 1);
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
|
|
|
|
2017-04-07 18:28:16 +02:00
|
|
|
virtual int2 split_kernel_global_size(device_memory& kg, device_memory& data, DeviceTask * /*task*/)
|
2016-09-14 23:47:54 +02:00
|
|
|
{
|
2017-03-20 18:59:46 +01:00
|
|
|
cl_device_type type = OpenCLInfo::get_device_type(device->cdDevice);
|
2017-03-16 02:57:45 -04:00
|
|
|
/* Use small global size on CPU devices as it seems to be much faster. */
|
|
|
|
if(type == CL_DEVICE_TYPE_CPU) {
|
|
|
|
VLOG(1) << "Global size: (64, 64).";
|
|
|
|
return make_int2(64, 64);
|
|
|
|
}
|
|
|
|
|
2017-03-11 05:23:11 -05:00
|
|
|
cl_ulong max_buffer_size;
|
|
|
|
clGetDeviceInfo(device->cdDevice, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_buffer_size, NULL);
|
2017-03-16 02:57:45 -04:00
|
|
|
VLOG(1) << "Maximum device allocation size: "
|
2017-02-20 13:02:11 +01:00
|
|
|
<< string_human_readable_number(max_buffer_size) << " bytes. ("
|
|
|
|
<< string_human_readable_size(max_buffer_size) << ").";
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-03-04 06:29:01 -05:00
|
|
|
size_t num_elements = max_elements_for_max_buffer_size(kg, data, max_buffer_size / 2);
|
2017-02-22 08:10:02 -05:00
|
|
|
int2 global_size = make_int2(round_down((int)sqrt(num_elements), 64), (int)sqrt(num_elements));
|
2017-02-20 13:02:11 +01:00
|
|
|
VLOG(1) << "Global size: " << global_size << ".";
|
2017-02-22 08:10:02 -05:00
|
|
|
return global_size;
|
2016-09-14 23:47:54 +02:00
|
|
|
}
|
2017-02-22 08:10:02 -05:00
|
|
|
};
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
OpenCLDeviceSplitKernel::OpenCLDeviceSplitKernel(DeviceInfo& info, Stats &stats, bool background_)
|
|
|
|
: OpenCLDeviceBase(info, stats, background_)
|
|
|
|
{
|
|
|
|
split_kernel = new OpenCLSplitKernel(this);
|
2016-09-14 23:47:54 +02:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
background = background_;
|
|
|
|
}
|
2016-09-14 23:47:54 +02:00
|
|
|
|
|
|
|
Device *opencl_create_split_device(DeviceInfo& info, Stats& stats, bool background)
|
|
|
|
{
|
|
|
|
return new OpenCLDeviceSplitKernel(info, stats, background);
|
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* WITH_OPENCL */
|