diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-21 18:34:15 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-02-08 16:00:48 +0300 |
commit | 9830eeb44b84cdb12e477cbb067f3b7e56634024 (patch) | |
tree | 4084b797c2323ca85d9ed2f09c967d9ac25e3733 /intern/cycles/kernel/bvh | |
parent | 9c3d202e56f67eb20a0331abbe850620acf90d40 (diff) |
Cycles: Implement record-all transparent shadow function for GPU
The idea is to record all possible transparent intersections when
shooting transparent ray on GPU (similar to what we were doing on
CPU already).
This avoids need of doing whole ray-to-scene intersections queries
for each intersection and speeds up a lot cases like transparent
hair in the cost of extra memory.
This commit is a base ground for now and this feature is kept
disabled for until some further tweaks.
Diffstat (limited to 'intern/cycles/kernel/bvh')
-rw-r--r-- | intern/cycles/kernel/bvh/bvh.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h index 36798982653..2667f236064 100644 --- a/intern/cycles/kernel/bvh/bvh.h +++ b/intern/cycles/kernel/bvh/bvh.h @@ -357,7 +357,7 @@ ccl_device_inline float3 ray_offset(float3 P, float3 Ng) #endif } -#if defined(__SHADOW_RECORD_ALL__) || defined (__VOLUME_RECORD_ALL__) +#if defined(__SHADOW_RECORD_ALL__) || defined(__VOLUME_RECORD_ALL__) /* ToDo: Move to another file? */ ccl_device int intersections_compare(const void *a, const void *b) { @@ -371,7 +371,25 @@ ccl_device int intersections_compare(const void *a, const void *b) else return 0; } + +ccl_device_inline void sort_intersections(Intersection *hits, uint num_hits) +{ +#ifdef __KERNEL_GPU__ + /* Use bubble sort which has more friendly memory pattern on GPU. */ + int i, j; + for(i = 0; i < num_hits; ++i) { + for(j = 0; j < num_hits - 1; ++j) { + if(hits[j].t < hits[j + 1].t) { + Intersection tmp = hits[j]; + hits[j] = hits[j + 1]; + hits[j + 1] = tmp; + } + } + } +#else + qsort(hits, num_hits, sizeof(Intersection), intersections_compare); #endif +} +#endif /* __SHADOW_RECORD_ALL__ | __VOLUME_RECORD_ALL__ */ CCL_NAMESPACE_END - |