Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/opencl/opencl_split.cpp
| Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | const string OpenCLDevice::get_opencl_program_filename(const string& kernel_name) | ||||
| if (fast_compiled_kernels.find(kernel_name) != std::string::npos) { | if (fast_compiled_kernels.find(kernel_name) != std::string::npos) { | ||||
| return "kernel_split_bundle.cl"; | return "kernel_split_bundle.cl"; | ||||
| } | } | ||||
| else { | else { | ||||
| return "kernel_" + kernel_name + ".cl"; | return "kernel_" + kernel_name + ".cl"; | ||||
| } | } | ||||
| } | } | ||||
| /* Enable features that we always want to compile to reduce recompilation events */ | |||||
| void OpenCLDevice::enable_default_features(DeviceRequestedFeatures& features) | |||||
| { | |||||
| features.use_transparent = true; | |||||
| features.use_shadow_tricks = true; | |||||
| features.use_principled = true; | |||||
| features.use_denoising = true; | |||||
| if (!background) | |||||
| { | |||||
| features.max_nodes_group = NODE_GROUP_LEVEL_MAX; | |||||
| features.nodes_features = NODE_FEATURE_ALL; | |||||
| features.use_hair = true; | |||||
| features.use_subsurface = true; | |||||
| } | |||||
| } | |||||
| string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_features, const string& opencl_program_name) | string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_features, const string& opencl_program_name) | ||||
| { | { | ||||
| /* first check for non-split kernel programs */ | /* first check for non-split kernel programs */ | ||||
| if (opencl_program_name == "base" || opencl_program_name == "denoising") { | if (opencl_program_name == "base" || opencl_program_name == "denoising") { | ||||
| return ""; | return ""; | ||||
| } | } | ||||
| else if (opencl_program_name == "bake") { | else if (opencl_program_name == "bake") { | ||||
| /* Note: get_build_options for bake is only requested when baking is enabled. | /* Note: get_build_options for bake is only requested when baking is enabled. | ||||
| * displace and background are always requested. | * displace and background are always requested. | ||||
| * `__SPLIT_KERNEL__` must not be present in the compile directives for bake */ | * `__SPLIT_KERNEL__` must not be present in the compile directives for bake */ | ||||
| DeviceRequestedFeatures features(requested_features); | DeviceRequestedFeatures features(requested_features); | ||||
| enable_default_features(features); | |||||
| features.use_denoising = false; | features.use_denoising = false; | ||||
| features.use_object_motion = false; | features.use_object_motion = false; | ||||
| features.use_camera_motion = false; | features.use_camera_motion = false; | ||||
| return features.get_build_options(); | return features.get_build_options(); | ||||
| } | } | ||||
| else if (opencl_program_name == "displace") { | else if (opencl_program_name == "displace") { | ||||
| /* As displacement does not use any nodes from the Shading group (eg BSDF). | /* As displacement does not use any nodes from the Shading group (eg BSDF). | ||||
| * We disable all features that are related to shading. */ | * We disable all features that are related to shading. */ | ||||
| Show All 10 Lines | else if (opencl_program_name == "displace") { | ||||
| features.use_denoising = false; | features.use_denoising = false; | ||||
| features.use_principled = false; | features.use_principled = false; | ||||
| return features.get_build_options(); | return features.get_build_options(); | ||||
| } | } | ||||
| else if (opencl_program_name == "background") { | else if (opencl_program_name == "background") { | ||||
| /* Background uses Background shading | /* Background uses Background shading | ||||
| * It is save to disable shadow features, subsurface and volumetric. */ | * It is save to disable shadow features, subsurface and volumetric. */ | ||||
| DeviceRequestedFeatures features(requested_features); | DeviceRequestedFeatures features(requested_features); | ||||
| enable_default_features(features); | |||||
| features.use_baking = false; | features.use_baking = false; | ||||
| features.use_transparent = false; | features.use_transparent = false; | ||||
| features.use_shadow_tricks = false; | features.use_shadow_tricks = false; | ||||
| features.use_denoising = false; | features.use_denoising = false; | ||||
| /* NOTE: currently possible to use surface nodes like `Hair Info`, `Bump` node. | /* NOTE: currently possible to use surface nodes like `Hair Info`, `Bump` node. | ||||
| * Perhaps we should remove them in UI as it does not make any sense when | * Perhaps we should remove them in UI as it does not make any sense when | ||||
| * rendering background. */ | * rendering background. */ | ||||
| features.nodes_features &= ~NODE_FEATURE_VOLUME; | features.nodes_features &= ~NODE_FEATURE_VOLUME; | ||||
| features.use_subsurface = false; | features.use_subsurface = false; | ||||
| features.use_volume = false; | features.use_volume = false; | ||||
| return features.get_build_options(); | return features.get_build_options(); | ||||
| } | } | ||||
| string build_options = "-D__SPLIT_KERNEL__ "; | string build_options = "-D__SPLIT_KERNEL__ "; | ||||
| DeviceRequestedFeatures nofeatures; | |||||
| /* Set compute device build option. */ | /* Set compute device build option. */ | ||||
| cl_device_type device_type; | cl_device_type device_type; | ||||
| OpenCLInfo::get_device_type(this->cdDevice, &device_type, &this->ciErr); | OpenCLInfo::get_device_type(this->cdDevice, &device_type, &this->ciErr); | ||||
| assert(this->ciErr == CL_SUCCESS); | assert(this->ciErr == CL_SUCCESS); | ||||
| if(device_type == CL_DEVICE_TYPE_GPU) { | if(device_type == CL_DEVICE_TYPE_GPU) { | ||||
| build_options += "-D__COMPUTE_DEVICE_GPU__ "; | build_options += "-D__COMPUTE_DEVICE_GPU__ "; | ||||
| } | } | ||||
| DeviceRequestedFeatures nofeatures; | |||||
| enable_default_features(nofeatures); | |||||
| /* Add program specific optimized compile directives */ | /* Add program specific optimized compile directives */ | ||||
| if (opencl_program_name == "split_do_volume" && !requested_features.use_volume) { | if (opencl_program_name == "split_do_volume" && !requested_features.use_volume) { | ||||
| build_options += nofeatures.get_build_options(); | build_options += nofeatures.get_build_options(); | ||||
| } | } | ||||
| else if (opencl_program_name == "split_subsurface_scatter" && !requested_features.use_subsurface) { | |||||
| /* When subsurface is off, the kernel updates indexes and does not need any | |||||
| * Compile directives */ | |||||
| build_options += nofeatures.get_build_options(); | |||||
| } | |||||
| else { | else { | ||||
| DeviceRequestedFeatures features(requested_features); | DeviceRequestedFeatures features(requested_features); | ||||
| enable_default_features(features); | |||||
| /* Always turn off baking at this point. Baking is only usefull when building the bake kernel. | /* Always turn off baking at this point. Baking is only usefull when building the bake kernel. | ||||
| * this also makes sure that the kernels that are build during baking can be reused | * this also makes sure that the kernels that are build during baking can be reused | ||||
| * when not doing any baking. */ | * when not doing any baking. */ | ||||
| features.use_baking = false; | features.use_baking = false; | ||||
| /* Do not vary on shaders when program doesn't do any shading. | /* Do not vary on shaders when program doesn't do any shading. | ||||
| * We have bundled them in a single program. */ | * We have bundled them in a single program. */ | ||||
| ▲ Show 20 Lines • Show All 1,765 Lines • Show Last 20 Lines | |||||