diff options
Diffstat (limited to 'intern/cycles/device/opencl/opencl.h')
-rw-r--r-- | intern/cycles/device/opencl/opencl.h | 78 |
1 files changed, 53 insertions, 25 deletions
diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h index 766b9e4bf1a..1c5f6d375ec 100644 --- a/intern/cycles/device/opencl/opencl.h +++ b/intern/cycles/device/opencl/opencl.h @@ -18,6 +18,7 @@ #include "device/device.h" #include "device/device_denoising.h" +#include "device/device_split_kernel.h" #include "util/util_map.h" #include "util/util_param.h" @@ -84,8 +85,6 @@ public: static cl_device_type device_type(); static bool use_debug(); static bool kernel_use_advanced_shading(const string& platform_name); - static bool kernel_use_split(const string& platform_name, - const cl_device_type device_type); static bool device_supported(const string& platform_name, const cl_device_id device_id); static bool platform_version_check(cl_platform_id platform, @@ -259,7 +258,7 @@ public: } \ } (void) 0 -class OpenCLDeviceBase : public Device +class OpenCLDevice : public Device { public: DedicatedTaskPool task_pool; @@ -273,7 +272,7 @@ public: class OpenCLProgram { public: OpenCLProgram() : loaded(false), program(NULL), device(NULL) {} - OpenCLProgram(OpenCLDeviceBase *device, + OpenCLProgram(OpenCLDevice *device, const string& program_name, const string& kernel_name, const string& kernel_build_options, @@ -311,7 +310,7 @@ public: bool loaded; cl_program program; - OpenCLDeviceBase *device; + OpenCLDevice *device; /* Used for the OpenCLCache key. */ string program_name; @@ -325,6 +324,32 @@ public: map<ustring, cl_kernel> kernels; }; + DeviceSplitKernel *split_kernel; + + OpenCLProgram program_data_init; + OpenCLProgram program_state_buffer_size; + + OpenCLProgram program_split; + + OpenCLProgram program_path_init; + OpenCLProgram program_scene_intersect; + OpenCLProgram program_lamp_emission; + OpenCLProgram program_do_volume; + OpenCLProgram program_queue_enqueue; + OpenCLProgram program_indirect_background; + OpenCLProgram program_shader_setup; + OpenCLProgram program_shader_sort; + OpenCLProgram program_shader_eval; + OpenCLProgram program_holdout_emission_blurring_pathtermination_ao; + OpenCLProgram program_subsurface_scatter; + OpenCLProgram program_direct_lighting; + OpenCLProgram program_shadow_blocked_ao; + OpenCLProgram program_shadow_blocked_dl; + OpenCLProgram program_enqueue_inactive; + OpenCLProgram program_next_iteration_setup; + OpenCLProgram program_indirect_subsurface; + OpenCLProgram program_buffer_update; + OpenCLProgram base_program; OpenCLProgram bake_program; OpenCLProgram displace_program; @@ -346,8 +371,8 @@ public: void opencl_error(const string& message); void opencl_assert_err(cl_int err, const char* where); - OpenCLDeviceBase(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background_); - ~OpenCLDeviceBase(); + OpenCLDevice(DeviceInfo& info, Stats &stats, Profiler &profiler, bool background_); + ~OpenCLDevice(); static void CL_CALLBACK context_notify_callback(const char *err_info, const void * /*private_info*/, size_t /*cb*/, void *user_data); @@ -355,17 +380,14 @@ public: bool opencl_version_check(); string device_md5_hash(string kernel_custom_build_options = ""); - virtual bool load_kernels(const DeviceRequestedFeatures& requested_features); - - /* Has to be implemented by the real device classes. - * The base device will then load all these programs. */ - virtual bool add_kernel_programs(const DeviceRequestedFeatures& requested_features, - vector<OpenCLProgram*> &programs) = 0; + bool load_kernels(const DeviceRequestedFeatures& requested_features); /* Get the name of the opencl program for the given kernel */ - virtual const string get_opencl_program_name(bool single_program, const string& kernel_name) = 0; + const string get_opencl_program_name(bool single_program, const string& kernel_name); /* Get the program file name to compile (*.cl) for the given kernel */ - virtual const string get_opencl_program_filename(bool single_program, const string& kernel_name) = 0; + const string get_opencl_program_filename(bool single_program, const string& kernel_name); + string get_build_options(const DeviceRequestedFeatures& requested_features); + string get_build_options_for_bake(const DeviceRequestedFeatures& requested_features); void mem_alloc(device_memory& mem); void mem_copy_to(device_memory& mem); @@ -393,10 +415,10 @@ public: class OpenCLDeviceTask : public DeviceTask { public: - OpenCLDeviceTask(OpenCLDeviceBase *device, DeviceTask& task) + OpenCLDeviceTask(OpenCLDevice *device, DeviceTask& task) : DeviceTask(task) { - run = function_bind(&OpenCLDeviceBase::thread_run, + run = function_bind(&OpenCLDevice::thread_run, device, this); } @@ -422,9 +444,16 @@ public: task_pool.cancel(); } - virtual void thread_run(DeviceTask * /*task*/) = 0; + void thread_run(DeviceTask *task); + + virtual BVHLayoutMask get_bvh_layout_mask() const { + return BVH_LAYOUT_BVH2; + } + + virtual bool show_samples() const { + return true; + } - virtual bool is_split_kernel() = 0; protected: string kernel_build_options(const string *debug_src = NULL); @@ -566,18 +595,15 @@ protected: /* ** Those guys are for workign around some compiler-specific bugs ** */ - virtual cl_program load_cached_kernel( + cl_program load_cached_kernel( ustring key, thread_scoped_lock& cache_locker); - virtual void store_cached_kernel( + void store_cached_kernel( cl_program program, ustring key, thread_scoped_lock& cache_locker); - virtual string build_options_for_bake_program( - const DeviceRequestedFeatures& /*requested_features*/); - private: MemoryManager memory_manager; friend class MemoryManager; @@ -592,9 +618,11 @@ private: protected: void flush_texture_buffers(); + + friend class OpenCLSplitKernel; + friend class OpenCLSplitKernelFunction; }; -Device *opencl_create_mega_device(DeviceInfo& info, Stats& stats, Profiler &profiler, bool background); Device *opencl_create_split_device(DeviceInfo& info, Stats& stats, Profiler &profiler, bool background); CCL_NAMESPACE_END |