Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh_nodes.h
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg, | ||||
| /* intersect ray against child nodes */ | /* intersect ray against child nodes */ | ||||
| float c0lox = (node0.x - P.x) * idir.x; | float c0lox = (node0.x - P.x) * idir.x; | ||||
| float c0hix = (node0.z - P.x) * idir.x; | float c0hix = (node0.z - P.x) * idir.x; | ||||
| float c0loy = (node1.x - P.y) * idir.y; | float c0loy = (node1.x - P.y) * idir.y; | ||||
| float c0hiy = (node1.z - P.y) * idir.y; | float c0hiy = (node1.z - P.y) * idir.y; | ||||
| float c0loz = (node2.x - P.z) * idir.z; | float c0loz = (node2.x - P.z) * idir.z; | ||||
| float c0hiz = (node2.z - P.z) * idir.z; | float c0hiz = (node2.z - P.z) * idir.z; | ||||
| float c0min = max4(min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz), 0.0f); | float c0min = max4(0.0f, min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz)); | ||||
| float c0max = min4(max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz), t); | float c0max = min4(t, max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz)); | ||||
| float c1lox = (node0.y - P.x) * idir.x; | float c1lox = (node0.y - P.x) * idir.x; | ||||
| float c1hix = (node0.w - P.x) * idir.x; | float c1hix = (node0.w - P.x) * idir.x; | ||||
| float c1loy = (node1.y - P.y) * idir.y; | float c1loy = (node1.y - P.y) * idir.y; | ||||
| float c1hiy = (node1.w - P.y) * idir.y; | float c1hiy = (node1.w - P.y) * idir.y; | ||||
| float c1loz = (node2.y - P.z) * idir.z; | float c1loz = (node2.y - P.z) * idir.z; | ||||
| float c1hiz = (node2.w - P.z) * idir.z; | float c1hiz = (node2.w - P.z) * idir.z; | ||||
| float c1min = max4(min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz), 0.0f); | float c1min = max4(0.0f, min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz)); | ||||
| float c1max = min4(max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz), t); | float c1max = min4(t, max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz)); | ||||
| dist[0] = c0min; | dist[0] = c0min; | ||||
| dist[1] = c1min; | dist[1] = c1min; | ||||
| #ifdef __VISIBILITY_FLAG__ | #ifdef __VISIBILITY_FLAG__ | ||||
| /* this visibility test gives a 5% performance hit, how to solve? */ | /* this visibility test gives a 5% performance hit, how to solve? */ | ||||
| return (((c0max >= c0min) && (__float_as_uint(cnodes.x) & visibility))? 1: 0) | | return (((c0max >= c0min) && (__float_as_uint(cnodes.x) & visibility))? 1: 0) | | ||||
| (((c1max >= c1min) && (__float_as_uint(cnodes.y) & visibility))? 2: 0); | (((c1max >= c1min) && (__float_as_uint(cnodes.y) & visibility))? 2: 0); | ||||
| Show All 22 Lines | ccl_device_forceinline int bvh_aligned_node_intersect_robust(KernelGlobals *kg, | ||||
| /* intersect ray against child nodes */ | /* intersect ray against child nodes */ | ||||
| float c0lox = (node0.x - P.x) * idir.x; | float c0lox = (node0.x - P.x) * idir.x; | ||||
| float c0hix = (node0.z - P.x) * idir.x; | float c0hix = (node0.z - P.x) * idir.x; | ||||
| float c0loy = (node1.x - P.y) * idir.y; | float c0loy = (node1.x - P.y) * idir.y; | ||||
| float c0hiy = (node1.z - P.y) * idir.y; | float c0hiy = (node1.z - P.y) * idir.y; | ||||
| float c0loz = (node2.x - P.z) * idir.z; | float c0loz = (node2.x - P.z) * idir.z; | ||||
| float c0hiz = (node2.z - P.z) * idir.z; | float c0hiz = (node2.z - P.z) * idir.z; | ||||
| float c0min = max4(min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz), 0.0f); | float c0min = max4(0.0f, min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz)); | ||||
| float c0max = min4(max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz), t); | float c0max = min4(t, max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz)); | ||||
| float c1lox = (node0.y - P.x) * idir.x; | float c1lox = (node0.y - P.x) * idir.x; | ||||
| float c1hix = (node0.w - P.x) * idir.x; | float c1hix = (node0.w - P.x) * idir.x; | ||||
| float c1loy = (node1.y - P.y) * idir.y; | float c1loy = (node1.y - P.y) * idir.y; | ||||
| float c1hiy = (node1.w - P.y) * idir.y; | float c1hiy = (node1.w - P.y) * idir.y; | ||||
| float c1loz = (node2.y - P.z) * idir.z; | float c1loz = (node2.y - P.z) * idir.z; | ||||
| float c1hiz = (node2.w - P.z) * idir.z; | float c1hiz = (node2.w - P.z) * idir.z; | ||||
| float c1min = max4(min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz), 0.0f); | float c1min = max4(0.0f, min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz)); | ||||
| float c1max = min4(max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz), t); | float c1max = min4(t, max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz)); | ||||
| if(difl != 0.0f) { | if(difl != 0.0f) { | ||||
| float hdiff = 1.0f + difl; | float hdiff = 1.0f + difl; | ||||
| float ldiff = 1.0f - difl; | float ldiff = 1.0f - difl; | ||||
| if(__float_as_int(cnodes.z) & PATH_RAY_CURVE) { | if(__float_as_int(cnodes.z) & PATH_RAY_CURVE) { | ||||
| c0min = max(ldiff * c0min, c0min - extmax); | c0min = max(ldiff * c0min, c0min - extmax); | ||||
| c0max = min(hdiff * c0max, c0max + extmax); | c0max = min(hdiff * c0max, c0max + extmax); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg, | ||||
| ssef tnear_x = min(lower_x, upper_x); | ssef tnear_x = min(lower_x, upper_x); | ||||
| ssef tnear_y = min(lower_y, upper_y); | ssef tnear_y = min(lower_y, upper_y); | ||||
| ssef tnear_z = min(lower_z, upper_z); | ssef tnear_z = min(lower_z, upper_z); | ||||
| ssef tfar_x = max(lower_x, upper_x); | ssef tfar_x = max(lower_x, upper_x); | ||||
| ssef tfar_y = max(lower_y, upper_y); | ssef tfar_y = max(lower_y, upper_y); | ||||
| ssef tfar_z = max(lower_z, upper_z); | ssef tfar_z = max(lower_z, upper_z); | ||||
| const ssef tnear = max4(tnear_x, tnear_y, tnear_z, isect_near); | const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z); | ||||
| const ssef tfar = min4(tfar_x, tfar_y, tfar_z, isect_far); | const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z); | ||||
| sseb vmask = tnear <= tfar; | sseb vmask = tnear <= tfar; | ||||
| dist[0] = tnear.f[0]; | dist[0] = tnear.f[0]; | ||||
| dist[1] = tnear.f[1]; | dist[1] = tnear.f[1]; | ||||
| int mask = (int)movemask(vmask); | int mask = (int)movemask(vmask); | ||||
| # ifdef __VISIBILITY_FLAG__ | # ifdef __VISIBILITY_FLAG__ | ||||
| /* this visibility test gives a 5% performance hit, how to solve? */ | /* this visibility test gives a 5% performance hit, how to solve? */ | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | ccl_device_forceinline int bvh_unaligned_node_intersect_robust(KernelGlobals *kg, | ||||
| ssef tnear_x = min(lower_x, upper_x); | ssef tnear_x = min(lower_x, upper_x); | ||||
| ssef tnear_y = min(lower_y, upper_y); | ssef tnear_y = min(lower_y, upper_y); | ||||
| ssef tnear_z = min(lower_z, upper_z); | ssef tnear_z = min(lower_z, upper_z); | ||||
| ssef tfar_x = max(lower_x, upper_x); | ssef tfar_x = max(lower_x, upper_x); | ||||
| ssef tfar_y = max(lower_y, upper_y); | ssef tfar_y = max(lower_y, upper_y); | ||||
| ssef tfar_z = max(lower_z, upper_z); | ssef tfar_z = max(lower_z, upper_z); | ||||
| const ssef tnear = max4(tnear_x, tnear_y, tnear_z, isect_near); | const ssef tnear = max4(isect_near, tnear_x, tnear_y, tnear_z); | ||||
| const ssef tfar = min4(tfar_x, tfar_y, tfar_z, isect_far); | const ssef tfar = min4(isect_far, tfar_x, tfar_y, tfar_z); | ||||
| sseb vmask; | sseb vmask; | ||||
| if(difl != 0.0f) { | if(difl != 0.0f) { | ||||
| const float round_down = 1.0f - difl; | const float round_down = 1.0f - difl; | ||||
| const float round_up = 1.0f + difl; | const float round_up = 1.0f + difl; | ||||
| vmask = round_down*tnear <= round_up*tfar; | vmask = round_down*tnear <= round_up*tfar; | ||||
| } | } | ||||
| else { | else { | ||||
| vmask = tnear <= tfar; | vmask = tnear <= tfar; | ||||
| ▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines | |||||