[Bf-blender-cvs] [042e4daa72b] blender-v2.82-release: Cycles: Crash fix for random walk SSS with Embree.
Stefan Werner
noreply at git.blender.org
Tue Jan 14 15:00:11 CET 2020
Commit: 042e4daa72b7b69925a173d3937f04d35a189baf
Author: Stefan Werner
Date: Tue Oct 15 15:06:04 2019 +0200
Branches: blender-v2.82-release
https://developer.blender.org/rB042e4daa72b7b69925a173d3937f04d35a189baf
Cycles: Crash fix for random walk SSS with Embree.
===================================================================
M intern/cycles/bvh/bvh_embree.cpp
===================================================================
diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp
index d12a0c137ea..42d2e66017c 100644
--- a/intern/cycles/bvh/bvh_embree.cpp
+++ b/intern/cycles/bvh/bvh_embree.cpp
@@ -168,26 +168,32 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args)
}
}
- ++ctx->ss_isect->num_hits;
- int hit_idx;
+ int hit_idx = 0;
- if (ctx->ss_isect->num_hits <= ctx->max_hits) {
- hit_idx = ctx->ss_isect->num_hits - 1;
- }
- else {
- /* reservoir sampling: if we are at the maximum number of
- * hits, randomly replace element or skip it */
- hit_idx = lcg_step_uint(ctx->lcg_state) % ctx->ss_isect->num_hits;
+ if (ctx->lcg_state) {
- if (hit_idx >= ctx->max_hits) {
- /* This tells Embree to continue tracing. */
- *args->valid = 0;
- break;
+ ++ctx->ss_isect->num_hits;
+ if (ctx->ss_isect->num_hits <= ctx->max_hits) {
+ hit_idx = ctx->ss_isect->num_hits - 1;
+ }
+ else {
+ /* reservoir sampling: if we are at the maximum number of
+ * hits, randomly replace element or skip it */
+ hit_idx = lcg_step_uint(ctx->lcg_state) % ctx->ss_isect->num_hits;
+
+ if (hit_idx >= ctx->max_hits) {
+ /* This tells Embree to continue tracing. */
+ *args->valid = 0;
+ break;
+ }
}
}
- /* record intersection */
- kernel_embree_convert_local_hit(
- kg, ray, hit, &ctx->ss_isect->hits[hit_idx], ctx->sss_object_id);
+ else {
+ ctx->ss_isect->num_hits = 1;
+ }
+ /* record intersection */
+ kernel_embree_convert_local_hit(
+ kg, ray, hit, &ctx->ss_isect->hits[hit_idx], ctx->sss_object_id);
ctx->ss_isect->Ng[hit_idx].x = hit->Ng_x;
ctx->ss_isect->Ng[hit_idx].y = hit->Ng_y;
ctx->ss_isect->Ng[hit_idx].z = hit->Ng_z;
More information about the Bf-blender-cvs
mailing list