diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-01-02 12:58:01 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-01-02 12:58:01 +0300 |
commit | 4f2583ee1300157a2f08532509ab3a53ef3a7b47 (patch) | |
tree | 47a106525015bf3c6e09bd584e4933f9d9dd36b1 /intern/cycles/kernel | |
parent | da66a2c871aee49338cb27747c67a2cb267b7b39 (diff) |
Fix T43027: OpenCL kernel compilation broken after QBVH
OpenCL apparently does not support templates, so the idea of generic
function for swapping is a bit of a failure. Now it is either inlined
into the code (in triangle intersection) or has specific implementation
for QBVH.
This is probably even better, because we can't create QBVH-specific
function in util_math anyway.
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/geom/geom_qbvh.h | 28 | ||||
-rw-r--r-- | intern/cycles/kernel/geom/geom_triangle_intersect.h | 4 |
2 files changed, 22 insertions, 10 deletions
diff --git a/intern/cycles/kernel/geom/geom_qbvh.h b/intern/cycles/kernel/geom/geom_qbvh.h index 7a354379bed..37deaac0800 100644 --- a/intern/cycles/kernel/geom/geom_qbvh.h +++ b/intern/cycles/kernel/geom/geom_qbvh.h @@ -19,14 +19,24 @@ struct QBVHStackItem { float dist; }; -/* TOOD(sergey): Investigate if using instrinsics helps here. */ +/* TOOD(sergey): Investigate if using instrinsics helps for both + * stack item swap and float comparison. + */ +ccl_device_inline void qbvh_item_swap(QBVHStackItem *__restrict a, + QBVHStackItem *__restrict b) +{ + QBVHStackItem tmp = *a; + *a = *b; + *b = tmp; +} + ccl_device_inline void qbvh_stack_sort(QBVHStackItem *__restrict s1, QBVHStackItem *__restrict s2, QBVHStackItem *__restrict s3) { - if(s2->dist < s1->dist) { util_swap(s2, s1); } - if(s3->dist < s2->dist) { util_swap(s3, s2); } - if(s2->dist < s1->dist) { util_swap(s2, s1); } + if(s2->dist < s1->dist) { qbvh_item_swap(s2, s1); } + if(s3->dist < s2->dist) { qbvh_item_swap(s3, s2); } + if(s2->dist < s1->dist) { qbvh_item_swap(s2, s1); } } ccl_device_inline void qbvh_stack_sort(QBVHStackItem *__restrict s1, @@ -34,11 +44,11 @@ ccl_device_inline void qbvh_stack_sort(QBVHStackItem *__restrict s1, QBVHStackItem *__restrict s3, QBVHStackItem *__restrict s4) { - if(s2->dist < s1->dist) { util_swap(s2, s1); } - if(s4->dist < s3->dist) { util_swap(s4, s3); } - if(s3->dist < s1->dist) { util_swap(s3, s1); } - if(s4->dist < s2->dist) { util_swap(s4, s2); } - if(s3->dist < s2->dist) { util_swap(s3, s2); } + if(s2->dist < s1->dist) { qbvh_item_swap(s2, s1); } + if(s4->dist < s3->dist) { qbvh_item_swap(s4, s3); } + if(s3->dist < s1->dist) { qbvh_item_swap(s3, s1); } + if(s4->dist < s2->dist) { qbvh_item_swap(s4, s2); } + if(s3->dist < s2->dist) { qbvh_item_swap(s3, s2); } } ccl_device_inline int qbvh_node_intersect(KernelGlobals *__restrict kg, diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h b/intern/cycles/kernel/geom/geom_triangle_intersect.h index 5090d553c41..cbb9d27aaf4 100644 --- a/intern/cycles/kernel/geom/geom_triangle_intersect.h +++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h @@ -67,7 +67,9 @@ void triangle_intersect_precalc(float3 dir, /* Swap kx and ky dimensions to preserve winding direction of triangles. */ if(IDX(dir, kz) < 0.0f) { - util_swap(&kx, &ky); + float tmp = kx; + kx = ky; + kx = tmp; } /* Calculate the shear constants. */ |