Merge branch 'blender2.7'

This commit is contained in:
Brecht Van Lommel
2019-03-12 14:22:53 +01:00
4 changed files with 42 additions and 14 deletions

View File

@@ -374,6 +374,8 @@ public:
/* Get the program file name to compile (*.cl) for the given kernel */
const string get_opencl_program_filename(const string& kernel_name);
string get_build_options(const DeviceRequestedFeatures& requested_features, const string& opencl_program_name);
/* Enable the default features to reduce recompilation events */
void enable_default_features(DeviceRequestedFeatures& features);
void mem_alloc(device_memory& mem);
void mem_copy_to(device_memory& mem);

View File

@@ -73,6 +73,25 @@ const string OpenCLDevice::get_opencl_program_filename(const string& kernel_name
}
}
/* 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;
features.use_camera_motion = false;
features.use_object_motion = false;
}
}
string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_features, const string& opencl_program_name)
{
/* first check for non-split kernel programs */
@@ -84,15 +103,22 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
* displace and background are always requested.
* `__SPLIT_KERNEL__` must not be present in the compile directives for bake */
DeviceRequestedFeatures features(requested_features);
enable_default_features(features);
features.use_denoising = false;
features.use_object_motion = false;
features.use_camera_motion = false;
features.use_hair = true;
features.use_subsurface = true;
features.max_nodes_group = NODE_GROUP_LEVEL_MAX;
features.nodes_features = NODE_FEATURE_ALL;
features.use_integrator_branched = false;
return features.get_build_options();
}
else if (opencl_program_name == "displace") {
/* As displacement does not use any nodes from the Shading group (eg BSDF).
* We disable all features that are related to shading. */
DeviceRequestedFeatures features(requested_features);
enable_default_features(features);
features.use_denoising = false;
features.use_object_motion = false;
features.use_camera_motion = false;
@@ -104,13 +130,17 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
features.nodes_features &= ~NODE_FEATURE_VOLUME;
features.use_denoising = false;
features.use_principled = false;
features.use_integrator_branched = false;
return features.get_build_options();
}
else if (opencl_program_name == "background") {
/* Background uses Background shading
* It is save to disable shadow features, subsurface and volumetric. */
DeviceRequestedFeatures features(requested_features);
enable_default_features(features);
features.use_baking = false;
features.use_object_motion = false;
features.use_camera_motion = false;
features.use_transparent = false;
features.use_shadow_tricks = false;
features.use_denoising = false;
@@ -120,11 +150,13 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
features.nodes_features &= ~NODE_FEATURE_VOLUME;
features.use_subsurface = false;
features.use_volume = false;
features.use_shader_raytrace = false;
features.use_patch_evaluation = false;
features.use_integrator_branched = false;
return features.get_build_options();
}
string build_options = "-D__SPLIT_KERNEL__ ";
DeviceRequestedFeatures nofeatures;
/* Set compute device build option. */
cl_device_type device_type;
OpenCLInfo::get_device_type(this->cdDevice, &device_type, &this->ciErr);
@@ -133,17 +165,16 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
build_options += "-D__COMPUTE_DEVICE_GPU__ ";
}
DeviceRequestedFeatures nofeatures;
enable_default_features(nofeatures);
/* Add program specific optimized compile directives */
if (opencl_program_name == "split_do_volume" && !requested_features.use_volume) {
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 {
DeviceRequestedFeatures features(requested_features);
enable_default_features(features);
/* 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
@@ -155,6 +186,7 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
if (opencl_program_name == "split_bundle") {
features.max_nodes_group = 0;
features.nodes_features = 0;
features.use_shader_raytrace = false;
}
/* No specific settings, just add the regular ones */

View File

@@ -219,9 +219,8 @@ ccl_device_inline float3 primitive_uv(KernelGlobals *kg, ShaderData *sd)
if(desc.offset == ATTR_STD_NOT_FOUND)
return make_float3(0.0f, 0.0f, 0.0f);
float3 uv = primitive_surface_attribute_float3(kg, sd, desc, NULL, NULL);
uv.z = 1.0f;
return uv;
float2 uv = primitive_surface_attribute_float2(kg, sd, desc, NULL, NULL);
return make_float3(uv.x, uv.y, 1.0f);
}
/* Ptex coordinates */

View File

@@ -658,11 +658,6 @@ DeviceRequestedFeatures Session::get_requested_device_features()
scene->shader_manager->get_requested_features(
scene,
&requested_features);
if(!params.background) {
/* Avoid too much re-compilations for viewport render. */
requested_features.max_nodes_group = NODE_GROUP_LEVEL_MAX;
requested_features.nodes_features = NODE_FEATURE_ALL;
}
/* This features are not being tweaked as often as shaders,
* so could be done selective magic for the viewport as well.