Cleanup: Follow Blender style and use more const
Also make some style decisions more consistent: for example, the way how stop/continue search return value is commented. Prefer lower vertical space for those.
This commit is contained in:
committed by
Sergey Sharybin
parent
bf9c95f164
commit
72542f3bb4
@@ -30,11 +30,11 @@ ccl_device_intersect bool scene_intersect(KernelGlobals kg,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (kernel_data.device_bvh == 0)
|
||||
if (kernel_data.device_bvh == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
hiprtRay ray_hip;
|
||||
|
||||
SET_HIPRT_RAY(ray_hip, ray)
|
||||
|
||||
RayPayload payload;
|
||||
@@ -56,14 +56,16 @@ ccl_device_intersect bool scene_intersect(KernelGlobals kg,
|
||||
GET_TRAVERSAL_CLOSEST_HIT(table_closest_intersect, 0, ray->time)
|
||||
hit = traversal.getNextHit();
|
||||
}
|
||||
|
||||
if (hit.hasHit()) {
|
||||
set_intersect_point(kg, hit, isect);
|
||||
if (isect->type > 1) { // should be applied only for curves
|
||||
if (isect->type > 1) { /* Should be applied only for curves. */
|
||||
isect->type = payload.prim_type;
|
||||
isect->prim = hit.primID;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -157,7 +159,7 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals kg,
|
||||
|
||||
return hit.hasHit();
|
||||
}
|
||||
#endif //__BVH_LOCAL__
|
||||
#endif /*__BVH_LOCAL__ */
|
||||
|
||||
#ifdef __SHADOW_RECORD_ALL__
|
||||
ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
|
||||
@@ -176,8 +178,8 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
|
||||
}
|
||||
|
||||
hiprtRay ray_hip;
|
||||
|
||||
SET_HIPRT_RAY(ray_hip, ray)
|
||||
|
||||
ShadowPayload payload;
|
||||
payload.kg = kg;
|
||||
payload.self = ray->self;
|
||||
@@ -189,11 +191,15 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
|
||||
payload.num_hits = 0;
|
||||
payload.r_num_recorded_hits = num_recorded_hits;
|
||||
payload.r_throughput = throughput;
|
||||
|
||||
GET_TRAVERSAL_STACK()
|
||||
GET_TRAVERSAL_ANY_HIT(table_shadow_intersect, 1, ray->time)
|
||||
hiprtHit hit = traversal.getNextHit();
|
||||
|
||||
const hiprtHit hit = traversal.getNextHit();
|
||||
|
||||
num_recorded_hits = payload.r_num_recorded_hits;
|
||||
throughput = payload.r_throughput;
|
||||
|
||||
return hit.hasHit();
|
||||
}
|
||||
#endif /* __SHADOW_RECORD_ALL__ */
|
||||
@@ -229,18 +235,17 @@ ccl_device_intersect bool scene_intersect_volume(KernelGlobals kg,
|
||||
GET_TRAVERSAL_STACK()
|
||||
|
||||
GET_TRAVERSAL_CLOSEST_HIT(table_volume_intersect, 3, ray->time)
|
||||
hiprtHit hit = traversal.getNextHit();
|
||||
// return hit.hasHit();
|
||||
const hiprtHit hit = traversal.getNextHit();
|
||||
if (hit.hasHit()) {
|
||||
set_intersect_point(kg, hit, isect);
|
||||
if (isect->type > 1) { // should be applied only for curves
|
||||
if (isect->type > 1) { /* Should be applied only for curves. */
|
||||
isect->type = payload.prim_type;
|
||||
isect->prim = hit.primID;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif /* __VOLUME__ */
|
||||
|
||||
|
||||
@@ -72,12 +72,12 @@ struct LocalPayload {
|
||||
RAY_TIME);
|
||||
|
||||
ccl_device_inline void set_intersect_point(KernelGlobals kg,
|
||||
hiprtHit &hit,
|
||||
const hiprtHit &hit,
|
||||
ccl_private Intersection *isect)
|
||||
{
|
||||
int prim_offset = 0;
|
||||
int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
const int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
const int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
|
||||
isect->type = kernel_data_fetch(objects, object_id).primitive_type;
|
||||
|
||||
isect->t = hit.t;
|
||||
@@ -87,74 +87,73 @@ ccl_device_inline void set_intersect_point(KernelGlobals kg,
|
||||
isect->v = hit.uv.y;
|
||||
}
|
||||
|
||||
// custom intersection functions
|
||||
/* --------------------------------------------------------------------
|
||||
* Custom intersection functions.
|
||||
*/
|
||||
|
||||
ccl_device_inline bool curve_custom_intersect(const hiprtRay &ray,
|
||||
RayPayload *payload,
|
||||
hiprtHit &hit)
|
||||
|
||||
{
|
||||
Intersection isect;
|
||||
|
||||
// could also cast shadow payload to get the elements needed to do the intersection
|
||||
// no need to write a separate function for shadow intersection
|
||||
/* Could also cast shadow payload to get the elements needed to do the intersection no need to
|
||||
* write a separate function for shadow intersection. */
|
||||
|
||||
KernelGlobals kg = payload->kg;
|
||||
|
||||
int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
// data_offset.x: where the data (prim id, type )for the geometry of the current object begins
|
||||
// the prim_id that is in hiprtHit hit is local to the particular geometry so we add the above
|
||||
// ofstream
|
||||
// to map prim id in hiprtHit to the one compatible to what next stage expects
|
||||
const int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
|
||||
// data_offset.y: the offset that has to be added to a local primitive to get the global
|
||||
// primitive id = kernel_data_fetch(object_prim_offset, object_id);
|
||||
/* data_offset.x: where the data (prim id, type )for the geometry of the current object begins
|
||||
* the prim_id that is in hiprtHit hit is local to the particular geometry so we add the above
|
||||
* ofstream to map prim id in hiprtHit to the one compatible to what next stage expects
|
||||
* data_offset.y: the offset that has to be added to a local primitive to get the global
|
||||
* primitive id = kernel_data_fetch(object_prim_offset, object_id); */
|
||||
const int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
|
||||
int prim_offset = data_offset.y;
|
||||
const int prim_offset = data_offset.y;
|
||||
|
||||
int curve_index = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).x;
|
||||
int key_value = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).y;
|
||||
const int curve_index = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).x;
|
||||
const int key_value = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).y;
|
||||
|
||||
# ifdef __SHADOW_LINKING__
|
||||
if (intersection_skip_shadow_link(nullptr, payload->self, object_id)) {
|
||||
/* Ignore hit - continue traversal */
|
||||
return false;
|
||||
return false; /* Ignore hit - continue traversal. */
|
||||
}
|
||||
# endif
|
||||
|
||||
if (intersection_skip_self_shadow(payload->self, object_id, curve_index + prim_offset))
|
||||
if (intersection_skip_self_shadow(payload->self, object_id, curve_index + prim_offset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float ray_time = payload->ray_time;
|
||||
const float ray_time = payload->ray_time;
|
||||
|
||||
if ((key_value & PRIMITIVE_MOTION) && kernel_data.bvh.use_bvh_steps) {
|
||||
|
||||
int time_offset = kernel_data_fetch(prim_time_offset, object_id);
|
||||
float2 prims_time = kernel_data_fetch(prims_time, hit.primID + time_offset);
|
||||
|
||||
const int time_offset = kernel_data_fetch(prim_time_offset, object_id);
|
||||
const float2 prims_time = kernel_data_fetch(prims_time, hit.primID + time_offset);
|
||||
if (ray_time < prims_time.x || ray_time > prims_time.y) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool b_hit = curve_intersect(kg,
|
||||
&isect,
|
||||
ray.origin,
|
||||
ray.direction,
|
||||
ray.minT,
|
||||
ray.maxT,
|
||||
object_id,
|
||||
curve_index + prim_offset,
|
||||
ray_time,
|
||||
key_value);
|
||||
Intersection isect;
|
||||
const bool b_hit = curve_intersect(kg,
|
||||
&isect,
|
||||
ray.origin,
|
||||
ray.direction,
|
||||
ray.minT,
|
||||
ray.maxT,
|
||||
object_id,
|
||||
curve_index + prim_offset,
|
||||
ray_time,
|
||||
key_value);
|
||||
if (b_hit) {
|
||||
hit.uv.x = isect.u;
|
||||
hit.uv.y = isect.v;
|
||||
hit.t = isect.t;
|
||||
hit.primID = isect.prim;
|
||||
payload->prim_type = isect.type; // packed_curve_type;
|
||||
payload->prim_type = isect.type; /* packed_curve_type */
|
||||
}
|
||||
|
||||
return b_hit;
|
||||
}
|
||||
|
||||
@@ -163,29 +162,29 @@ ccl_device_inline bool motion_triangle_custom_intersect(const hiprtRay &ray,
|
||||
hiprtHit &hit)
|
||||
{
|
||||
KernelGlobals kg = payload->kg;
|
||||
int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
const int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
const int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
const int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
|
||||
int prim_id_local = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).x;
|
||||
int prim_id_global = prim_id_local + prim_offset;
|
||||
const int prim_id_local = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).x;
|
||||
const int prim_id_global = prim_id_local + prim_offset;
|
||||
|
||||
if (intersection_skip_self_shadow(payload->self, object_id, prim_id_global))
|
||||
if (intersection_skip_self_shadow(payload->self, object_id, prim_id_global)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Intersection isect;
|
||||
|
||||
bool b_hit = motion_triangle_intersect(kg,
|
||||
&isect,
|
||||
ray.origin,
|
||||
ray.direction,
|
||||
ray.minT,
|
||||
ray.maxT,
|
||||
payload->ray_time,
|
||||
payload->visibility,
|
||||
object_id,
|
||||
prim_id_global,
|
||||
hit.instanceID);
|
||||
const bool b_hit = motion_triangle_intersect(kg,
|
||||
&isect,
|
||||
ray.origin,
|
||||
ray.direction,
|
||||
ray.minT,
|
||||
ray.maxT,
|
||||
payload->ray_time,
|
||||
payload->visibility,
|
||||
object_id,
|
||||
prim_id_global,
|
||||
hit.instanceID);
|
||||
|
||||
if (b_hit) {
|
||||
hit.uv.x = isect.u;
|
||||
@@ -194,6 +193,7 @@ ccl_device_inline bool motion_triangle_custom_intersect(const hiprtRay &ray,
|
||||
hit.primID = isect.prim;
|
||||
payload->prim_type = isect.type;
|
||||
}
|
||||
|
||||
return b_hit;
|
||||
}
|
||||
|
||||
@@ -203,21 +203,20 @@ ccl_device_inline bool motion_triangle_custom_local_intersect(const hiprtRay &ra
|
||||
{
|
||||
# ifdef __OBJECT_MOTION__
|
||||
KernelGlobals kg = payload->kg;
|
||||
int object_id = payload->local_object;
|
||||
|
||||
int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
const int object_id = payload->local_object;
|
||||
const int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
const int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
|
||||
int prim_id_local = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).x;
|
||||
int prim_id_global = prim_id_local + prim_offset;
|
||||
const int prim_id_local = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).x;
|
||||
const int prim_id_global = prim_id_local + prim_offset;
|
||||
|
||||
if (intersection_skip_self_local(payload->self, prim_id_global))
|
||||
if (intersection_skip_self_local(payload->self, prim_id_global)) {
|
||||
return false;
|
||||
|
||||
LocalIntersection *local_isect = payload->local_isect;
|
||||
}
|
||||
|
||||
return motion_triangle_intersect_local(kg,
|
||||
local_isect,
|
||||
payload->local_isect,
|
||||
ray.origin,
|
||||
ray.direction,
|
||||
payload->ray_time,
|
||||
@@ -240,34 +239,36 @@ ccl_device_inline bool motion_triangle_custom_volume_intersect(const hiprtRay &r
|
||||
{
|
||||
# ifdef __OBJECT_MOTION__
|
||||
KernelGlobals kg = payload->kg;
|
||||
int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
int object_flag = kernel_data_fetch(object_flag, object_id);
|
||||
|
||||
if (!(object_flag & SD_OBJECT_HAS_VOLUME))
|
||||
const int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
const int object_flag = kernel_data_fetch(object_flag, object_id);
|
||||
|
||||
if (!(object_flag & SD_OBJECT_HAS_VOLUME)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
const int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
const int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
|
||||
int prim_id_local = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).x;
|
||||
int prim_id_global = prim_id_local + prim_offset;
|
||||
const int prim_id_local = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x).x;
|
||||
const int prim_id_global = prim_id_local + prim_offset;
|
||||
|
||||
if (intersection_skip_self_shadow(payload->self, object_id, prim_id_global))
|
||||
if (intersection_skip_self_shadow(payload->self, object_id, prim_id_global)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Intersection isect;
|
||||
|
||||
bool b_hit = motion_triangle_intersect(kg,
|
||||
&isect,
|
||||
ray.origin,
|
||||
ray.direction,
|
||||
ray.minT,
|
||||
ray.maxT,
|
||||
payload->ray_time,
|
||||
payload->visibility,
|
||||
object_id,
|
||||
prim_id_global,
|
||||
prim_id_local);
|
||||
const bool b_hit = motion_triangle_intersect(kg,
|
||||
&isect,
|
||||
ray.origin,
|
||||
ray.direction,
|
||||
ray.minT,
|
||||
ray.maxT,
|
||||
payload->ray_time,
|
||||
payload->visibility,
|
||||
object_id,
|
||||
prim_id_global,
|
||||
prim_id_local);
|
||||
|
||||
if (b_hit) {
|
||||
hit.uv.x = isect.u;
|
||||
@@ -276,6 +277,7 @@ ccl_device_inline bool motion_triangle_custom_volume_intersect(const hiprtRay &r
|
||||
hit.primID = isect.prim;
|
||||
payload->prim_type = isect.type;
|
||||
}
|
||||
|
||||
return b_hit;
|
||||
# else
|
||||
return false;
|
||||
@@ -288,51 +290,48 @@ ccl_device_inline bool point_custom_intersect(const hiprtRay &ray,
|
||||
{
|
||||
# if defined(__POINTCLOUD__)
|
||||
KernelGlobals kg = payload->kg;
|
||||
int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
|
||||
int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
const int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
const int2 data_offset = kernel_data_fetch(custom_prim_info_offset, object_id);
|
||||
const int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
|
||||
int2 prim_info = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x);
|
||||
int prim_id_local = prim_info.x;
|
||||
int prim_id_global = prim_id_local + prim_offset;
|
||||
const int2 prim_info = kernel_data_fetch(custom_prim_info, hit.primID + data_offset.x);
|
||||
const int prim_id_local = prim_info.x;
|
||||
const int prim_id_global = prim_id_local + prim_offset;
|
||||
|
||||
int type = prim_info.y;
|
||||
const int type = prim_info.y;
|
||||
|
||||
# ifdef __SHADOW_LINKING__
|
||||
if (intersection_skip_shadow_link(nullptr, payload->self, object_id)) {
|
||||
/* Ignore hit - continue traversal */
|
||||
return false;
|
||||
return false; /* Ignore hit - continue traversal */
|
||||
}
|
||||
# endif
|
||||
|
||||
if (intersection_skip_self_shadow(payload->self, object_id, prim_id_global))
|
||||
if (intersection_skip_self_shadow(payload->self, object_id, prim_id_global)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float ray_time = payload->ray_time;
|
||||
const float ray_time = payload->ray_time;
|
||||
|
||||
if ((type & PRIMITIVE_MOTION_POINT) && kernel_data.bvh.use_bvh_steps) {
|
||||
|
||||
int time_offset = kernel_data_fetch(prim_time_offset, object_id);
|
||||
float2 prims_time = kernel_data_fetch(prims_time, hit.primID + time_offset);
|
||||
|
||||
const int time_offset = kernel_data_fetch(prim_time_offset, object_id);
|
||||
const float2 prims_time = kernel_data_fetch(prims_time, hit.primID + time_offset);
|
||||
if (ray_time < prims_time.x || ray_time > prims_time.y) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Intersection isect;
|
||||
|
||||
bool b_hit = point_intersect(kg,
|
||||
&isect,
|
||||
ray.origin,
|
||||
ray.direction,
|
||||
ray.minT,
|
||||
ray.maxT,
|
||||
object_id,
|
||||
prim_id_global,
|
||||
ray_time,
|
||||
type);
|
||||
const bool b_hit = point_intersect(kg,
|
||||
&isect,
|
||||
ray.origin,
|
||||
ray.direction,
|
||||
ray.minT,
|
||||
ray.maxT,
|
||||
object_id,
|
||||
prim_id_global,
|
||||
ray_time,
|
||||
type);
|
||||
|
||||
if (b_hit) {
|
||||
hit.uv.x = isect.u;
|
||||
@@ -341,32 +340,33 @@ ccl_device_inline bool point_custom_intersect(const hiprtRay &ray,
|
||||
hit.primID = isect.prim;
|
||||
payload->prim_type = isect.type;
|
||||
}
|
||||
|
||||
return b_hit;
|
||||
# else
|
||||
return false;
|
||||
# endif
|
||||
}
|
||||
|
||||
// intersection filters
|
||||
/* --------------------------------------------------------------------
|
||||
* Intersection filters.
|
||||
*/
|
||||
|
||||
ccl_device_inline bool closest_intersection_filter(const hiprtRay &ray,
|
||||
RayPayload *payload,
|
||||
const hiprtHit &hit)
|
||||
{
|
||||
int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
int prim = hit.primID + prim_offset;
|
||||
const int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
const int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
const int prim = hit.primID + prim_offset;
|
||||
|
||||
# ifdef __SHADOW_LINKING__
|
||||
if (intersection_skip_shadow_link(nullptr, payload->self, object_id)) {
|
||||
/* Ignore hit - continue traversal */
|
||||
return true;
|
||||
return true; /* Ignore hit - continue traversal. */
|
||||
}
|
||||
# endif
|
||||
|
||||
if (intersection_skip_self_shadow(payload->self, object_id, prim)) {
|
||||
/* Ignore hit - continue traversal */
|
||||
return true;
|
||||
return true; /* Ignore hit - continue traversal. */
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -377,63 +377,56 @@ ccl_device_inline bool shadow_intersection_filter(const hiprtRay &ray,
|
||||
const hiprtHit &hit)
|
||||
|
||||
{
|
||||
uint num_hits = payload->num_hits;
|
||||
uint num_recorded_hits = *(payload->r_num_recorded_hits);
|
||||
uint max_hits = payload->max_hits;
|
||||
int state = payload->in_state;
|
||||
KernelGlobals kg = payload->kg;
|
||||
RaySelfPrimitives self = payload->self;
|
||||
|
||||
int object = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
int prim_offset = kernel_data_fetch(object_prim_offset, object);
|
||||
int prim = hit.primID + prim_offset;
|
||||
const uint num_hits = payload->num_hits;
|
||||
const uint max_hits = payload->max_hits;
|
||||
const int state = payload->in_state;
|
||||
const RaySelfPrimitives self = payload->self;
|
||||
|
||||
float ray_tmax = hit.t;
|
||||
const int object = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
const int prim_offset = kernel_data_fetch(object_prim_offset, object);
|
||||
const int prim = hit.primID + prim_offset;
|
||||
|
||||
const float ray_tmax = hit.t;
|
||||
|
||||
# ifdef __SHADOW_LINKING__
|
||||
if (intersection_skip_shadow_link(nullptr, self, object)) {
|
||||
/* Ignore hit - continue traversal */
|
||||
return true;
|
||||
return true; /* Ignore hit - continue traversal */
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef __VISIBILITY_FLAG__
|
||||
|
||||
if ((kernel_data_fetch(objects, object).visibility & payload->visibility) == 0) {
|
||||
return true; // no hit - continue traversal
|
||||
return true; /* No hit - continue traversal. */
|
||||
}
|
||||
# endif
|
||||
|
||||
if (intersection_skip_self_shadow(self, object, prim)) {
|
||||
return true; // no hit -continue traversal
|
||||
return true; /* No hit -continue traversal. */
|
||||
}
|
||||
|
||||
if (intersection_skip_shadow_already_recoded(kg, state, object, prim, num_hits)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
float u = hit.uv.x;
|
||||
float v = hit.uv.y;
|
||||
int type = kernel_data_fetch(objects, object).primitive_type;
|
||||
const float u = hit.uv.x;
|
||||
const float v = hit.uv.y;
|
||||
const int type = kernel_data_fetch(objects, object).primitive_type;
|
||||
|
||||
# ifndef __TRANSPARENT_SHADOWS__
|
||||
|
||||
return false;
|
||||
|
||||
# else
|
||||
|
||||
if (num_hits >= max_hits ||
|
||||
!(intersection_get_shader_flags(nullptr, prim, type) & SD_HAS_TRANSPARENT_SHADOW))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint record_index = num_recorded_hits;
|
||||
uint record_index = *payload->r_num_recorded_hits;
|
||||
|
||||
num_hits += 1;
|
||||
num_recorded_hits += 1;
|
||||
payload->num_hits = num_hits;
|
||||
*(payload->r_num_recorded_hits) = num_recorded_hits;
|
||||
payload->num_hits = num_hits + 1;
|
||||
*(payload->r_num_recorded_hits) += 1;
|
||||
|
||||
const uint max_record_hits = min(max_hits, INTEGRATOR_SHADOW_ISECT_SIZE);
|
||||
if (record_index >= max_record_hits) {
|
||||
@@ -449,7 +442,6 @@ ccl_device_inline bool shadow_intersection_filter(const hiprtRay &ray,
|
||||
}
|
||||
|
||||
if (ray_tmax >= max_recorded_t) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -462,8 +454,8 @@ ccl_device_inline bool shadow_intersection_filter(const hiprtRay &ray,
|
||||
INTEGRATOR_STATE_ARRAY_WRITE(state, shadow_isect, record_index, prim) = prim;
|
||||
INTEGRATOR_STATE_ARRAY_WRITE(state, shadow_isect, record_index, object) = object;
|
||||
INTEGRATOR_STATE_ARRAY_WRITE(state, shadow_isect, record_index, type) = type;
|
||||
return true;
|
||||
|
||||
return true;
|
||||
# endif /* __TRANSPARENT_SHADOWS__ */
|
||||
}
|
||||
|
||||
@@ -472,56 +464,51 @@ ccl_device_inline bool shadow_intersection_filter_curves(const hiprtRay &ray,
|
||||
const hiprtHit &hit)
|
||||
|
||||
{
|
||||
uint num_hits = payload->num_hits;
|
||||
uint num_recorded_hits = *(payload->r_num_recorded_hits);
|
||||
uint max_hits = payload->max_hits;
|
||||
KernelGlobals kg = payload->kg;
|
||||
RaySelfPrimitives self = payload->self;
|
||||
|
||||
int object = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
int prim = hit.primID;
|
||||
const uint num_hits = payload->num_hits;
|
||||
const uint num_recorded_hits = *(payload->r_num_recorded_hits);
|
||||
const uint max_hits = payload->max_hits;
|
||||
const RaySelfPrimitives self = payload->self;
|
||||
|
||||
float ray_tmax = hit.t;
|
||||
const int object = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
const int prim = hit.primID;
|
||||
|
||||
const float ray_tmax = hit.t;
|
||||
|
||||
# ifdef __SHADOW_LINKING__
|
||||
/* It doesn't seem like this is necessary. */
|
||||
if (intersection_skip_shadow_link(nullptr, self, object)) {
|
||||
/* Ignore hit - continue traversal */
|
||||
return true;
|
||||
return true; /* Ignore hit - continue traversal. */
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef __VISIBILITY_FLAG__
|
||||
|
||||
if ((kernel_data_fetch(objects, object).visibility & payload->visibility) == 0) {
|
||||
return true; // no hit - continue traversal
|
||||
return true; /* No hit - continue traversal. */
|
||||
}
|
||||
# endif
|
||||
|
||||
if (intersection_skip_self_shadow(self, object, prim)) {
|
||||
return true; // no hit -continue traversal
|
||||
return true; /* No hit -continue traversal. */
|
||||
}
|
||||
|
||||
if (intersection_skip_shadow_already_recoded(kg, payload->in_state, object, prim, num_hits)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
float u = hit.uv.x;
|
||||
float v = hit.uv.y;
|
||||
const float u = hit.uv.x;
|
||||
const float v = hit.uv.y;
|
||||
|
||||
if (u == 0.0f || u == 1.0f) {
|
||||
// continue traversal
|
||||
return true;
|
||||
return true; /* Continue traversal. */
|
||||
}
|
||||
|
||||
int type = payload->prim_type;
|
||||
const int type = payload->prim_type;
|
||||
|
||||
# ifndef __TRANSPARENT_SHADOWS__
|
||||
|
||||
return false;
|
||||
|
||||
# else
|
||||
|
||||
if (num_hits >= max_hits ||
|
||||
!(intersection_get_shader_flags(nullptr, prim, type) & SD_HAS_TRANSPARENT_SHADOW))
|
||||
{
|
||||
@@ -538,7 +525,6 @@ ccl_device_inline bool shadow_intersection_filter_curves(const hiprtRay &ray,
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
# endif /* __TRANSPARENT_SHADOWS__ */
|
||||
}
|
||||
|
||||
@@ -548,6 +534,7 @@ ccl_device_inline bool local_intersection_filter(const hiprtRay &ray,
|
||||
{
|
||||
# ifdef __BVH_LOCAL__
|
||||
KernelGlobals kg = payload->kg;
|
||||
|
||||
const int object_id = payload->local_object;
|
||||
const uint max_hits = payload->max_hits;
|
||||
|
||||
@@ -567,18 +554,18 @@ ccl_device_inline bool local_intersection_filter(const hiprtRay &ray,
|
||||
const int prim = hit.primID + prim_offset;
|
||||
# ifndef __RAY_OFFSET__
|
||||
if (intersection_skip_self_local(payload->self, prim)) {
|
||||
return true; // continue search
|
||||
return true; /* Continue search. */
|
||||
}
|
||||
# endif
|
||||
|
||||
if (max_hits == 0) {
|
||||
return false; // stop search
|
||||
return false; /* Stop search. */
|
||||
}
|
||||
|
||||
const int hit_index = local_intersect_get_record_index(
|
||||
payload->local_isect, hit.t, payload->lcg_state, max_hits);
|
||||
if (hit_index == -1) {
|
||||
return true; // continue search
|
||||
return true; /* Continue search. */
|
||||
}
|
||||
|
||||
Intersection *isect = &payload->local_isect->hits[hit_index];
|
||||
@@ -601,10 +588,10 @@ ccl_device_inline bool volume_intersection_filter(const hiprtRay &ray,
|
||||
RayPayload *payload,
|
||||
const hiprtHit &hit)
|
||||
{
|
||||
int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
int prim = hit.primID + prim_offset;
|
||||
int object_flag = kernel_data_fetch(object_flag, object_id);
|
||||
const int object_id = kernel_data_fetch(user_instance_id, hit.instanceID);
|
||||
const int prim_offset = kernel_data_fetch(object_prim_offset, object_id);
|
||||
const int prim = hit.primID + prim_offset;
|
||||
const int object_flag = kernel_data_fetch(object_flag, object_id);
|
||||
|
||||
if (intersection_skip_self(payload->self, object_id, prim))
|
||||
return true;
|
||||
@@ -614,14 +601,14 @@ ccl_device_inline bool volume_intersection_filter(const hiprtRay &ray,
|
||||
return false;
|
||||
}
|
||||
|
||||
HIPRT_DEVICE bool intersectFunc(const uint geomType,
|
||||
const uint rayType,
|
||||
HIPRT_DEVICE bool intersectFunc(const uint geom_type,
|
||||
const uint ray_type,
|
||||
const hiprtFuncTableHeader &tableHeader,
|
||||
const hiprtRay &ray,
|
||||
void *payload,
|
||||
hiprtHit &hit)
|
||||
{
|
||||
const uint index = tableHeader.numGeomTypes * rayType + geomType;
|
||||
const uint index = tableHeader.numGeomTypes * ray_type + geom_type;
|
||||
switch (index) {
|
||||
case Curve_Intersect_Function:
|
||||
case Curve_Intersect_Shadow:
|
||||
@@ -642,14 +629,14 @@ HIPRT_DEVICE bool intersectFunc(const uint geomType,
|
||||
return false;
|
||||
}
|
||||
|
||||
HIPRT_DEVICE bool filterFunc(const uint geomType,
|
||||
const uint rayType,
|
||||
HIPRT_DEVICE bool filterFunc(const uint geom_type,
|
||||
const uint ray_type,
|
||||
const hiprtFuncTableHeader &tableHeader,
|
||||
const hiprtRay &ray,
|
||||
void *payload,
|
||||
const hiprtHit &hit)
|
||||
{
|
||||
const uint index = tableHeader.numGeomTypes * rayType + geomType;
|
||||
const uint index = tableHeader.numGeomTypes * ray_type + geom_type;
|
||||
switch (index) {
|
||||
case Triangle_Filter_Closest:
|
||||
return closest_intersection_filter(ray, (RayPayload *)payload, hit);
|
||||
@@ -668,7 +655,6 @@ HIPRT_DEVICE bool filterFunc(const uint geomType,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user