Cycles microdisplacement: Allow kernels to be built without patch evaluation
Kernels can now be built without patch evaluation when not needed by the scene (Catmull-Clark subdivision not in use), giving a performance boost for some devices.
This commit is contained in:
@@ -56,8 +56,14 @@ std::ostream& operator <<(std::ostream &os,
|
||||
<< string_from_bool(requested_features.use_camera_motion) << std::endl;
|
||||
os << "Use Baking: "
|
||||
<< string_from_bool(requested_features.use_baking) << std::endl;
|
||||
os << "Use Subsurface: "
|
||||
<< string_from_bool(requested_features.use_subsurface) << std::endl;
|
||||
os << "Use Volume: "
|
||||
<< string_from_bool(requested_features.use_volume) << std::endl;
|
||||
os << "Use Branched Integrator: "
|
||||
<< string_from_bool(requested_features.use_integrator_branched) << std::endl;
|
||||
os << "Use Patch Evaluation: "
|
||||
<< string_from_bool(requested_features.use_patch_evaluation) << std::endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@@ -109,6 +109,9 @@ public:
|
||||
/* Use branched integrator. */
|
||||
bool use_integrator_branched;
|
||||
|
||||
/* Use OpenSubdiv patch evaluation */
|
||||
bool use_patch_evaluation;
|
||||
|
||||
DeviceRequestedFeatures()
|
||||
{
|
||||
/* TODO(sergey): Find more meaningful defaults. */
|
||||
@@ -123,6 +126,7 @@ public:
|
||||
use_subsurface = false;
|
||||
use_volume = false;
|
||||
use_integrator_branched = false;
|
||||
use_patch_evaluation = false;
|
||||
}
|
||||
|
||||
bool modified(const DeviceRequestedFeatures& requested_features)
|
||||
@@ -137,7 +141,8 @@ public:
|
||||
use_baking == requested_features.use_baking &&
|
||||
use_subsurface == requested_features.use_subsurface &&
|
||||
use_volume == requested_features.use_volume &&
|
||||
use_integrator_branched == requested_features.use_integrator_branched);
|
||||
use_integrator_branched == requested_features.use_integrator_branched &&
|
||||
use_patch_evaluation == requested_features.use_patch_evaluation);
|
||||
}
|
||||
|
||||
/* Convert the requested features structure to a build options,
|
||||
@@ -175,6 +180,9 @@ public:
|
||||
if(!use_integrator_branched) {
|
||||
build_options += " -D__NO_BRANCHED_PATH__";
|
||||
}
|
||||
if(!use_patch_evaluation) {
|
||||
build_options += " -D__NO_PATCH_EVAL__";
|
||||
}
|
||||
return build_options;
|
||||
}
|
||||
};
|
||||
|
@@ -17,7 +17,9 @@
|
||||
|
||||
#include "geom_attribute.h"
|
||||
#include "geom_object.h"
|
||||
#include "geom_patch.h"
|
||||
#ifdef __PATCH_EVAL__
|
||||
# include "geom_patch.h"
|
||||
#endif
|
||||
#include "geom_triangle.h"
|
||||
#include "geom_subd_triangle.h"
|
||||
#include "geom_triangle_intersect.h"
|
||||
|
@@ -101,6 +101,7 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals *kg, const
|
||||
{
|
||||
int patch = subd_triangle_patch(kg, sd);
|
||||
|
||||
#ifdef __PATCH_EVAL__
|
||||
if(desc.flags & ATTR_SUBDIVIDED) {
|
||||
float2 uv[3];
|
||||
subd_triangle_patch_uv(kg, sd, uv);
|
||||
@@ -144,7 +145,9 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals *kg, const
|
||||
|
||||
return a;
|
||||
}
|
||||
else if(desc.element == ATTR_ELEMENT_FACE) {
|
||||
else
|
||||
#endif /* __PATCH_EVAL__ */
|
||||
if(desc.element == ATTR_ELEMENT_FACE) {
|
||||
if(dx) *dx = 0.0f;
|
||||
if(dy) *dy = 0.0f;
|
||||
|
||||
@@ -217,6 +220,7 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con
|
||||
{
|
||||
int patch = subd_triangle_patch(kg, sd);
|
||||
|
||||
#ifdef __PATCH_EVAL__
|
||||
if(desc.flags & ATTR_SUBDIVIDED) {
|
||||
float2 uv[3];
|
||||
subd_triangle_patch_uv(kg, sd, uv);
|
||||
@@ -266,7 +270,9 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con
|
||||
|
||||
return a;
|
||||
}
|
||||
else if(desc.element == ATTR_ELEMENT_FACE) {
|
||||
else
|
||||
#endif /* __PATCH_EVAL__ */
|
||||
if(desc.element == ATTR_ELEMENT_FACE) {
|
||||
if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f);
|
||||
if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
|
@@ -148,6 +148,7 @@ CCL_NAMESPACE_BEGIN
|
||||
#define __CAMERA_CLIPPING__
|
||||
#define __INTERSECTION_REFINE__
|
||||
#define __CLAMP_SAMPLE__
|
||||
#define __PATCH_EVAL__
|
||||
|
||||
#ifdef __KERNEL_SHADING__
|
||||
# define __SVM__
|
||||
@@ -197,6 +198,9 @@ CCL_NAMESPACE_BEGIN
|
||||
#ifdef __NO_BRANCHED_PATH__
|
||||
# undef __BRANCHED_PATH__
|
||||
#endif
|
||||
#ifdef __NO_PATCH_EVAL__
|
||||
# undef __PATCH_EVAL__
|
||||
#endif
|
||||
|
||||
/* Random Numbers */
|
||||
|
||||
|
@@ -635,6 +635,11 @@ DeviceRequestedFeatures Session::get_requested_device_features()
|
||||
}
|
||||
requested_features.use_object_motion |= object->use_motion | mesh->use_motion_blur;
|
||||
requested_features.use_camera_motion |= mesh->use_motion_blur;
|
||||
#ifdef WITH_OPENSUBDIV
|
||||
if(mesh->subdivision_type != Mesh::SUBDIVISION_NONE) {
|
||||
requested_features.use_patch_evaluation = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
BakeManager *bake_manager = scene->bake_manager;
|
||||
|
Reference in New Issue
Block a user