[Bf-blender-cvs] [aa844ad676d] master: Cycles: Don't allocate Extra if BSDF allocation failed
Sergey Sharybin
noreply at git.blender.org
Wed Sep 12 12:29:10 CEST 2018
Commit: aa844ad676d2e9d4f72f773fde64712c8a794e5e
Author: Sergey Sharybin
Date: Wed Sep 12 12:21:04 2018 +0200
Branches: master
https://developer.blender.org/rBaa844ad676d2e9d4f72f773fde64712c8a794e5e
Cycles: Don't allocate Extra if BSDF allocation failed
Failed as in did not allocate due to possibly weight cutoff.
Tryign to allocated Extra storage for closure in such situation
will consfuse Cycles and cause crashes later one due to obscure
values in ShaderData.
===================================================================
M intern/cycles/kernel/svm/svm_closure.h
===================================================================
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index df879de1950..64bf8244999 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -258,7 +258,9 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
float3 spec_weight = weight * specular_weight;
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), spec_weight);
- MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
+ MicrofacetExtra *extra = (bsdf != NULL)
+ ? (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra))
+ : NULL;
if (bsdf && extra) {
bsdf->N = N;
@@ -308,7 +310,9 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
#endif
{
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), glass_weight*fresnel);
- MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
+ MicrofacetExtra *extra = (bsdf != NULL)
+ ? (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra))
+ : NULL;
if (bsdf && extra) {
bsdf->N = N;
@@ -355,7 +359,9 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
}
else { /* use multi-scatter GGX */
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), glass_weight);
- MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
+ MicrofacetExtra *extra = (bsdf != NULL)
+ ? (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra))
+ : NULL;
if(bsdf && extra) {
bsdf->N = N;
@@ -385,7 +391,9 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
#endif
if(clearcoat > CLOSURE_WEIGHT_CUTOFF) {
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), weight);
- MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
+ MicrofacetExtra *extra = (bsdf != NULL)
+ ? (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra))
+ : NULL;
if(bsdf && extra) {
bsdf->N = clearcoat_normal;
More information about the Bf-blender-cvs
mailing list