1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "../common/ray.h"
#include "../common/context.h"
#include "filter_sycl.h"
namespace embree
{
template<typename Ray>
struct Intersect1Epilog1_HWIF;
template<>
struct Intersect1Epilog1_HWIF<RayHit>
{
RayHit& ray;
sycl::private_ptr<RayQueryContext> context;
const unsigned int geomID;
const unsigned int primID;
const bool filter;
__forceinline Intersect1Epilog1_HWIF(RayHit& ray,
sycl::private_ptr<RayQueryContext> context,
const unsigned int geomID,
const unsigned int primID,
const bool filter)
: ray(ray), context(context), geomID(geomID), primID(primID), filter(filter) {}
template<typename Hit_i>
__forceinline bool operator() (Hit_i& hit_i) const
{
hit_i.finalize();
Scene* scene MAYBE_UNUSED = context->scene;
Geometry* geometry MAYBE_UNUSED = scene->get(geomID);
/* ray mask test */
#if defined(EMBREE_RAY_MASK)
if ((geometry->mask & ray.mask) == 0)
return false;
#endif
/* call intersection filter function */
#if defined(EMBREE_FILTER_FUNCTION)
if (filter && (unlikely(context->hasContextFilter() || geometry->hasIntersectionFilter())))
{
Hit h(context->user,geomID,primID,Vec2f(hit_i.u,hit_i.v),hit_i.Ng);
float old_t = ray.tfar;
ray.tfar = hit_i.t;
bool found = runIntersectionFilter1SYCL(geometry,ray,context,h);
if (!found) {
ray.tfar = old_t;
return false;
}
}
#endif
ray.tfar = hit_i.t;
ray.u = hit_i.u;
ray.v = hit_i.v;
ray.Ng.x = hit_i.Ng.x;
ray.Ng.y = hit_i.Ng.y;
ray.Ng.z = hit_i.Ng.z;
ray.geomID = geomID;
ray.primID = primID;
instance_id_stack::copy_UU(context->user, context->user->instID, ray.instID);
#if defined(EMBREE_GEOMETRY_INSTANCE_ARRAY)
instance_id_stack::copy_UU(context->user, context->user->instPrimID, ray.instPrimID);
#endif
return true;
}
template<typename Hit_i>
__forceinline bool operator() (bool, Hit_i& hit_i) const
{
hit_i.finalize();
Scene* scene MAYBE_UNUSED = context->scene;
Geometry* geometry MAYBE_UNUSED = scene->get(geomID);
/* ray mask test */
#if defined(EMBREE_RAY_MASK)
if ((geometry->mask & ray.mask) == 0)
return false;
#endif
const Vec3fa Ng = hit_i.Ng();
const Vec2f uv = hit_i.uv();
/* call intersection filter function */
#if defined(EMBREE_FILTER_FUNCTION)
if (filter && (unlikely(context->hasContextFilter() || geometry->hasIntersectionFilter())))
{
Hit h(context->user,geomID,primID,uv,Ng);
float old_t = ray.tfar;
ray.tfar = hit_i.t();
bool found = runIntersectionFilter1SYCL(geometry,ray,context,h);
if (!found) {
ray.tfar = old_t;
return false;
}
}
#endif
ray.tfar = hit_i.t();
ray.u = uv.x;
ray.v = uv.y;
ray.Ng.x = Ng.x;
ray.Ng.y = Ng.y;
ray.Ng.z = Ng.z;
ray.geomID = geomID;
ray.primID = primID;
instance_id_stack::copy_UU(context->user, context->user->instID, ray.instID);
#if defined(EMBREE_GEOMETRY_INSTANCE_ARRAY)
instance_id_stack::copy_UU(context->user, context->user->instPrimID, ray.instPrimID);
#endif
return true;
}
};
template<>
struct Intersect1Epilog1_HWIF<Ray>
{
Ray& ray;
sycl::private_ptr<RayQueryContext> context;
const unsigned int geomID;
const unsigned int primID;
const bool filter;
__forceinline Intersect1Epilog1_HWIF(Ray& ray,
sycl::private_ptr<RayQueryContext> context,
const unsigned int geomID,
const unsigned int primID,
const bool filter)
: ray(ray), context(context), geomID(geomID), primID(primID), filter(filter) {}
template<typename Hit_i>
__forceinline bool operator() (Hit_i& hit_i) const
{
hit_i.finalize();
Scene* scene MAYBE_UNUSED = context->scene;
Geometry* geometry MAYBE_UNUSED = scene->get(geomID);
/* ray mask test */
#if defined(EMBREE_RAY_MASK)
if ((geometry->mask & ray.mask) == 0)
return false;
#endif
/* call intersection filter function */
#if defined(EMBREE_FILTER_FUNCTION)
if (filter && (unlikely(context->hasContextFilter() || geometry->hasOcclusionFilter())))
{
Hit h(context->user,geomID,primID,Vec2f(hit_i.u,hit_i.v),hit_i.Ng);
float old_t = ray.tfar;
ray.tfar = hit_i.t;
bool found = runIntersectionFilter1SYCL(geometry,ray,context,h);
if (!found) {
ray.tfar = old_t;
return false;
}
}
#endif
ray.tfar = neg_inf;
return true;
}
template<typename Hit_i>
__forceinline bool operator() (bool, Hit_i& hit_i) const
{
hit_i.finalize();
Scene* scene MAYBE_UNUSED = context->scene;
Geometry* geometry MAYBE_UNUSED = scene->get(geomID);
/* ray mask test */
#if defined(EMBREE_RAY_MASK)
if ((geometry->mask & ray.mask) == 0)
return false;
#endif
/* call intersection filter function */
#if defined(EMBREE_FILTER_FUNCTION)
if (filter && (unlikely(context->hasContextFilter() || geometry->hasOcclusionFilter())))
{
const Vec3fa Ng = hit_i.Ng();
const Vec2f uv = hit_i.uv();
Hit h(context->user,geomID,primID,uv,Ng);
float old_t = ray.tfar;
ray.tfar = hit_i.t();
bool found = runIntersectionFilter1SYCL(geometry,ray,context,h);
if (!found) {
ray.tfar = old_t;
return false;
}
}
#endif
ray.tfar = neg_inf;
return true;
}
};
}
|