Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/kernel/closure/alloc.h')
-rw-r--r--intern/cycles/kernel/closure/alloc.h37
1 files changed, 5 insertions, 32 deletions
diff --git a/intern/cycles/kernel/closure/alloc.h b/intern/cycles/kernel/closure/alloc.h
index 933c07a5102..f1af3b12269 100644
--- a/intern/cycles/kernel/closure/alloc.h
+++ b/intern/cycles/kernel/closure/alloc.h
@@ -8,7 +8,7 @@ CCL_NAMESPACE_BEGIN
ccl_device ccl_private ShaderClosure *closure_alloc(ccl_private ShaderData *sd,
int size,
ClosureType type,
- float3 weight)
+ Spectrum weight)
{
kernel_assert(size <= sizeof(ShaderClosure));
@@ -49,49 +49,23 @@ ccl_device ccl_private void *closure_alloc_extra(ccl_private ShaderData *sd, int
ccl_device_inline ccl_private ShaderClosure *bsdf_alloc(ccl_private ShaderData *sd,
int size,
- float3 weight)
+ Spectrum weight)
{
kernel_assert(isfinite_safe(weight));
- const float sample_weight = fabsf(average(weight));
-
- /* Use comparison this way to help dealing with non-finite weight: if the average is not finite
- * we will not allocate new closure. */
- if (sample_weight >= CLOSURE_WEIGHT_CUTOFF) {
- ccl_private ShaderClosure *sc = closure_alloc(sd, size, CLOSURE_NONE_ID, weight);
- if (sc == NULL) {
- return NULL;
- }
-
- sc->sample_weight = sample_weight;
-
- return sc;
- }
-
- return NULL;
-}
-
-#ifdef __OSL__
-ccl_device_inline ShaderClosure *bsdf_alloc_osl(ShaderData *sd,
- int size,
- float3 weight,
- void *data)
-{
- kernel_assert(isfinite_safe(weight));
+ /* No negative weights allowed. */
+ weight = max(weight, zero_float3());
const float sample_weight = fabsf(average(weight));
/* Use comparison this way to help dealing with non-finite weight: if the average is not finite
* we will not allocate new closure. */
if (sample_weight >= CLOSURE_WEIGHT_CUTOFF) {
- ShaderClosure *sc = closure_alloc(sd, size, CLOSURE_NONE_ID, weight);
+ ccl_private ShaderClosure *sc = closure_alloc(sd, size, CLOSURE_NONE_ID, weight);
if (!sc) {
return NULL;
}
- memcpy((void *)sc, data, size);
-
- sc->weight = weight;
sc->sample_weight = sample_weight;
return sc;
@@ -99,6 +73,5 @@ ccl_device_inline ShaderClosure *bsdf_alloc_osl(ShaderData *sd,
return NULL;
}
-#endif
CCL_NAMESPACE_END