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:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-02-13 20:24:45 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-02-13 20:24:45 +0300
commit930186d3df9cb55832d625e96a9655491360ba1e (patch)
tree94fc5a95c6f3eadb379fcb0578c0fa8346b5d881 /intern/cycles/kernel/bvh/bvh.h
parent21dbfb7828f5085ec2c94d304ba19a6faa6303cc (diff)
Cycles: Optimize sorting of transparent intersections on CUDA
Diffstat (limited to 'intern/cycles/kernel/bvh/bvh.h')
-rw-r--r--intern/cycles/kernel/bvh/bvh.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h
index dfd70106011..321983c1abc 100644
--- a/intern/cycles/kernel/bvh/bvh.h
+++ b/intern/cycles/kernel/bvh/bvh.h
@@ -378,16 +378,19 @@ 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) {
+ bool swapped;
+ do {
+ swapped = false;
+ for(int j = 0; j < num_hits - 1; ++j) {
if(hits[j].t > hits[j + 1].t) {
struct Intersection tmp = hits[j];
hits[j] = hits[j + 1];
hits[j + 1] = tmp;
+ swapped = true;
}
}
- }
+ --num_hits;
+ } while(swapped);
#else
qsort(hits, num_hits, sizeof(Intersection), intersections_compare);
#endif