Cycles: Support building with latest OSL-1.7dev
So now the following OSL versions are supported (at least for compilation): - 1.5 with closure alignment patch applied - 1.6.8 release - 1.7 development version from latest git
This commit is contained in:
@@ -77,7 +77,7 @@ public:
|
||||
ClosureParam *closure_background_params()
|
||||
{
|
||||
static ClosureParam params[] = {
|
||||
CLOSURE_STRING_KEYPARAM("label"),
|
||||
CLOSURE_STRING_KEYPARAM(GenericBackgroundClosure, label, "label"),
|
||||
CLOSURE_FINISH_PARAM(GenericBackgroundClosure)
|
||||
};
|
||||
return params;
|
||||
@@ -98,7 +98,7 @@ CCLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure)
|
||||
ClosureParam *closure_ambient_occlusion_params()
|
||||
{
|
||||
static ClosureParam params[] = {
|
||||
CLOSURE_STRING_KEYPARAM("label"),
|
||||
CLOSURE_STRING_KEYPARAM(AmbientOcclusionClosure, label, "label"),
|
||||
CLOSURE_FINISH_PARAM(AmbientOcclusionClosure)
|
||||
};
|
||||
return params;
|
||||
|
@@ -93,7 +93,7 @@ ClosureParam *closure_bsdf_diffuse_ramp_params()
|
||||
static ClosureParam params[] = {
|
||||
CLOSURE_FLOAT3_PARAM(DiffuseRampClosure, sc.N),
|
||||
CLOSURE_COLOR_ARRAY_PARAM(DiffuseRampClosure, colors, 8),
|
||||
CLOSURE_STRING_KEYPARAM("label"),
|
||||
CLOSURE_STRING_KEYPARAM(DiffuseRampClosure, label, "label"),
|
||||
CLOSURE_FINISH_PARAM(DiffuseRampClosure)
|
||||
};
|
||||
return params;
|
||||
|
@@ -93,7 +93,7 @@ ClosureParam *closure_bsdf_phong_ramp_params()
|
||||
CLOSURE_FLOAT3_PARAM(PhongRampClosure, sc.N),
|
||||
CLOSURE_FLOAT_PARAM(PhongRampClosure, sc.data0),
|
||||
CLOSURE_COLOR_ARRAY_PARAM(PhongRampClosure, colors, 8),
|
||||
CLOSURE_STRING_KEYPARAM("label"),
|
||||
CLOSURE_STRING_KEYPARAM(PhongRampClosure, label, "label"),
|
||||
CLOSURE_FINISH_PARAM(PhongRampClosure)
|
||||
};
|
||||
return params;
|
||||
|
@@ -77,7 +77,7 @@ public:
|
||||
ClosureParam *closure_emission_params()
|
||||
{
|
||||
static ClosureParam params[] = {
|
||||
CLOSURE_STRING_KEYPARAM("label"),
|
||||
CLOSURE_STRING_KEYPARAM(GenericEmissiveClosure, label, "label"),
|
||||
CLOSURE_FINISH_PARAM(GenericEmissiveClosure)
|
||||
};
|
||||
return params;
|
||||
|
@@ -69,7 +69,7 @@ ClosureParam *closure_bssrdf_cubic_params()
|
||||
CLOSURE_FLOAT3_PARAM(CubicBSSRDFClosure, radius),
|
||||
CLOSURE_FLOAT_PARAM(CubicBSSRDFClosure, sc.data1),
|
||||
CLOSURE_FLOAT_PARAM(CubicBSSRDFClosure, sc.T.x),
|
||||
CLOSURE_STRING_KEYPARAM("label"),
|
||||
CLOSURE_STRING_KEYPARAM(CubicBSSRDFClosure, label, "label"),
|
||||
CLOSURE_FINISH_PARAM(CubicBSSRDFClosure)
|
||||
};
|
||||
return params;
|
||||
@@ -97,7 +97,7 @@ ClosureParam *closure_bssrdf_gaussian_params()
|
||||
CLOSURE_FLOAT3_PARAM(GaussianBSSRDFClosure, sc.N),
|
||||
CLOSURE_FLOAT3_PARAM(GaussianBSSRDFClosure, radius),
|
||||
CLOSURE_FLOAT_PARAM(GaussianBSSRDFClosure, sc.data1),
|
||||
CLOSURE_STRING_KEYPARAM("label"),
|
||||
CLOSURE_STRING_KEYPARAM(GaussianBSSRDFClosure, label, "label"),
|
||||
CLOSURE_FINISH_PARAM(GaussianBSSRDFClosure)
|
||||
};
|
||||
return params;
|
||||
|
@@ -78,6 +78,11 @@ void name(RendererServices *, int id, void *data) \
|
||||
#define TO_COLOR3(v) OSL::Color3(v.x, v.y, v.z)
|
||||
#define TO_FLOAT3(v) make_float3(v[0], v[1], v[2])
|
||||
|
||||
#if OSL_LIBRARY_VERSION_CODE < 10700
|
||||
# undef CLOSURE_STRING_KEYPARAM
|
||||
# define CLOSURE_STRING_KEYPARAM(st, fld, key) { TypeDesc::TypeString, 0, key, 0 }
|
||||
#endif
|
||||
|
||||
/* Closure */
|
||||
|
||||
class CClosurePrimitive {
|
||||
@@ -97,6 +102,10 @@ public:
|
||||
virtual void setup() {}
|
||||
|
||||
Category category;
|
||||
|
||||
#if OSL_LIBRARY_VERSION_CODE >= 10700
|
||||
OSL::ustring label;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* BSDF */
|
||||
@@ -175,7 +184,7 @@ static ClosureParam *bsdf_##lower##_params() \
|
||||
/* parameters */
|
||||
|
||||
#define BSDF_CLOSURE_CLASS_END(Upper, lower) \
|
||||
CLOSURE_STRING_KEYPARAM("label"), \
|
||||
CLOSURE_STRING_KEYPARAM(Upper##Closure, label, "label"), \
|
||||
CLOSURE_FINISH_PARAM(Upper##Closure) \
|
||||
}; \
|
||||
return params; \
|
||||
@@ -223,7 +232,7 @@ static ClosureParam *volume_##lower##_params() \
|
||||
/* parameters */
|
||||
|
||||
#define VOLUME_CLOSURE_CLASS_END(Upper, lower) \
|
||||
CLOSURE_STRING_KEYPARAM("label"), \
|
||||
CLOSURE_STRING_KEYPARAM(Upper##Closure, label, "label"), \
|
||||
CLOSURE_FINISH_PARAM(Upper##Closure) \
|
||||
}; \
|
||||
return params; \
|
||||
|
@@ -146,7 +146,23 @@ static void flatten_surface_closure_tree(ShaderData *sd, int path_flag,
|
||||
/* OSL gives us a closure tree, we flatten it into arrays per
|
||||
* closure type, for evaluation, sampling, etc later on. */
|
||||
|
||||
if(closure->type == OSL::ClosureColor::COMPONENT) {
|
||||
#if OSL_LIBRARY_VERSION_CODE < 10700
|
||||
switch(closure->type) {
|
||||
#else
|
||||
switch(closure->id) {
|
||||
#endif
|
||||
case OSL::ClosureColor::MUL: {
|
||||
OSL::ClosureMul *mul = (OSL::ClosureMul *)closure;
|
||||
flatten_surface_closure_tree(sd, path_flag, mul->closure, TO_FLOAT3(mul->weight) * weight);
|
||||
break;
|
||||
}
|
||||
case OSL::ClosureColor::ADD: {
|
||||
OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure;
|
||||
flatten_surface_closure_tree(sd, path_flag, add->closureA, weight);
|
||||
flatten_surface_closure_tree(sd, path_flag, add->closureB, weight);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
OSL::ClosureComponent *comp = (OSL::ClosureComponent *)closure;
|
||||
CClosurePrimitive *prim = (CClosurePrimitive *)comp->data();
|
||||
|
||||
@@ -160,7 +176,7 @@ static void flatten_surface_closure_tree(ShaderData *sd, int path_flag,
|
||||
|
||||
prim->setup();
|
||||
|
||||
switch (prim->category) {
|
||||
switch(prim->category) {
|
||||
case CClosurePrimitive::BSDF: {
|
||||
CBSDFClosure *bsdf = (CBSDFClosure *)prim;
|
||||
int scattering = bsdf->scattering();
|
||||
@@ -170,7 +186,8 @@ static void flatten_surface_closure_tree(ShaderData *sd, int path_flag,
|
||||
KernelGlobals *kg = sd->osl_globals;
|
||||
|
||||
if((!kernel_data.integrator.caustics_reflective && (scattering & LABEL_REFLECT)) ||
|
||||
(!kernel_data.integrator.caustics_refractive && (scattering & LABEL_TRANSMIT))) {
|
||||
(!kernel_data.integrator.caustics_refractive && (scattering & LABEL_TRANSMIT)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -295,15 +312,8 @@ static void flatten_surface_closure_tree(ShaderData *sd, int path_flag,
|
||||
break; /* not relevant */
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if(closure->type == OSL::ClosureColor::MUL) {
|
||||
OSL::ClosureMul *mul = (OSL::ClosureMul *)closure;
|
||||
flatten_surface_closure_tree(sd, path_flag, mul->closure, TO_FLOAT3(mul->weight) * weight);
|
||||
}
|
||||
else if(closure->type == OSL::ClosureColor::ADD) {
|
||||
OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure;
|
||||
flatten_surface_closure_tree(sd, path_flag, add->closureA, weight);
|
||||
flatten_surface_closure_tree(sd, path_flag, add->closureB, weight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +345,23 @@ static float3 flatten_background_closure_tree(const OSL::ClosureColor *closure)
|
||||
* is only one supported closure type at the moment, which has no evaluation
|
||||
* functions, so we just sum the weights */
|
||||
|
||||
if(closure->type == OSL::ClosureColor::COMPONENT) {
|
||||
#if OSL_LIBRARY_VERSION_CODE < 10700
|
||||
switch(closure->type) {
|
||||
#else
|
||||
switch(closure->id) {
|
||||
#endif
|
||||
case OSL::ClosureColor::MUL: {
|
||||
OSL::ClosureMul *mul = (OSL::ClosureMul *)closure;
|
||||
|
||||
return TO_FLOAT3(mul->weight) * flatten_background_closure_tree(mul->closure);
|
||||
}
|
||||
case OSL::ClosureColor::ADD: {
|
||||
OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure;
|
||||
|
||||
return flatten_background_closure_tree(add->closureA) +
|
||||
flatten_background_closure_tree(add->closureB);
|
||||
}
|
||||
default: {
|
||||
OSL::ClosureComponent *comp = (OSL::ClosureComponent *)closure;
|
||||
CClosurePrimitive *prim = (CClosurePrimitive *)comp->data();
|
||||
|
||||
@@ -346,16 +372,6 @@ static float3 flatten_background_closure_tree(const OSL::ClosureColor *closure)
|
||||
return make_float3(1.0f, 1.0f, 1.0f);
|
||||
#endif
|
||||
}
|
||||
else if(closure->type == OSL::ClosureColor::MUL) {
|
||||
OSL::ClosureMul *mul = (OSL::ClosureMul *)closure;
|
||||
|
||||
return TO_FLOAT3(mul->weight) * flatten_background_closure_tree(mul->closure);
|
||||
}
|
||||
else if(closure->type == OSL::ClosureColor::ADD) {
|
||||
OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure;
|
||||
|
||||
return flatten_background_closure_tree(add->closureA) +
|
||||
flatten_background_closure_tree(add->closureB);
|
||||
}
|
||||
|
||||
return make_float3(0.0f, 0.0f, 0.0f);
|
||||
@@ -390,7 +406,23 @@ static void flatten_volume_closure_tree(ShaderData *sd,
|
||||
/* OSL gives us a closure tree, we flatten it into arrays per
|
||||
* closure type, for evaluation, sampling, etc later on. */
|
||||
|
||||
if(closure->type == OSL::ClosureColor::COMPONENT) {
|
||||
#if OSL_LIBRARY_VERSION_CODE < 10700
|
||||
switch(closure->type) {
|
||||
#else
|
||||
switch(closure->id) {
|
||||
#endif
|
||||
case OSL::ClosureColor::MUL: {
|
||||
OSL::ClosureMul *mul = (OSL::ClosureMul *)closure;
|
||||
flatten_volume_closure_tree(sd, mul->closure, TO_FLOAT3(mul->weight) * weight);
|
||||
break;
|
||||
}
|
||||
case OSL::ClosureColor::ADD: {
|
||||
OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure;
|
||||
flatten_volume_closure_tree(sd, add->closureA, weight);
|
||||
flatten_volume_closure_tree(sd, add->closureB, weight);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
OSL::ClosureComponent *comp = (OSL::ClosureComponent *)closure;
|
||||
CClosurePrimitive *prim = (CClosurePrimitive *)comp->data();
|
||||
|
||||
@@ -404,7 +436,7 @@ static void flatten_volume_closure_tree(ShaderData *sd,
|
||||
|
||||
prim->setup();
|
||||
|
||||
switch (prim->category) {
|
||||
switch(prim->category) {
|
||||
case CClosurePrimitive::Volume: {
|
||||
CVolumeClosure *volume = (CVolumeClosure *)prim;
|
||||
/* sample weight */
|
||||
@@ -451,14 +483,6 @@ static void flatten_volume_closure_tree(ShaderData *sd,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(closure->type == OSL::ClosureColor::MUL) {
|
||||
OSL::ClosureMul *mul = (OSL::ClosureMul *)closure;
|
||||
flatten_volume_closure_tree(sd, mul->closure, TO_FLOAT3(mul->weight) * weight);
|
||||
}
|
||||
else if(closure->type == OSL::ClosureColor::ADD) {
|
||||
OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure;
|
||||
flatten_volume_closure_tree(sd, add->closureA, weight);
|
||||
flatten_volume_closure_tree(sd, add->closureB, weight);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user