diff options
Diffstat (limited to 'intern/cycles/kernel/geom/geom_triangle_intersect.h')
-rw-r--r-- | intern/cycles/kernel/geom/geom_triangle_intersect.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h b/intern/cycles/kernel/geom/geom_triangle_intersect.h index 8d17e1240a5..eb7340583c8 100644 --- a/intern/cycles/kernel/geom/geom_triangle_intersect.h +++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h @@ -59,21 +59,33 @@ void triangle_intersect_precalc(float3 dir, IsectPrecalc *isect_precalc) { /* Calculate dimension where the ray direction is maximal. */ +#ifndef __KERNEL_SSE__ int kz = util_max_axis(make_float3(fabsf(dir.x), fabsf(dir.y), fabsf(dir.z))); int kx = kz + 1; if(kx == 3) kx = 0; int ky = kx + 1; if(ky == 3) ky = 0; +#else + int kx, ky, kz; + /* Avoiding mispredicted branch on direction. */ + kz = util_max_axis(fabs(dir)); + static const char inc_xaxis[] = {1, 2, 0, 55}; + static const char inc_yaxis[] = {2, 0, 1, 55}; + kx = inc_xaxis[kz]; + ky = inc_yaxis[kz]; +#endif + + float dir_kz = IDX(dir, kz); /* Swap kx and ky dimensions to preserve winding direction of triangles. */ - if(IDX(dir, kz) < 0.0f) { + if(dir_kz < 0.0f) { int tmp = kx; kx = ky; ky = tmp; } /* Calculate the shear constants. */ - float inv_dir_z = 1.0f / IDX(dir, kz); + float inv_dir_z = 1.0f / dir_kz; isect_precalc->Sx = IDX(dir, kx) * inv_dir_z; isect_precalc->Sy = IDX(dir, ky) * inv_dir_z; isect_precalc->Sz = inv_dir_z; @@ -108,7 +120,7 @@ ccl_device_inline bool triangle_intersect(KernelGlobals *kg, /* Calculate vertices relative to ray origin. */ const uint tri_vindex = kernel_tex_fetch(__prim_tri_index, triAddr); -#if defined(__KERNEL_AVX2__) +#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) const avxf avxf_P(P.m128, P.m128); const avxf tri_ab = kernel_tex_fetch_avxf(__prim_tri_verts, tri_vindex + 0); @@ -270,7 +282,7 @@ ccl_device_inline void triangle_intersect_subsurface( tri_b = kernel_tex_fetch(__prim_tri_verts, tri_vindex+1), tri_c = kernel_tex_fetch(__prim_tri_verts, tri_vindex+2); -#if defined(__KERNEL_AVX2__) +#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) const avxf avxf_P(P.m128, P.m128); const avxf tri_ab = kernel_tex_fetch_avxf(__prim_tri_verts, tri_vindex + 0); |