Files
ospray/modules/cpu/common/Instance.ih
T
Will Usher 078c589aaa Start running OSPRay as DPC++ on the GPU
Use an enum + switch statements to avoid issues/limitations with
function ptrs.

Renable volumes with OpenVKL when running on CPU w/ enable volumes

Put both CPU and GPU modules behind CMake flags

workaround odd bug with AO renderer and intervals

Add spheres geometry and port to use Embree sphere point

Push math constants for RNG to USM instead of in global constant

WA for `Material_dispatch_getTransparency` hang, working path tracer

Re-enable subdivision surfaces for CPU-only

Port Texture2D to use switch statement dispatch

Migrate all materials to switch dispatch

Add option for large grf, does improve performance

Workaround for TextureParam get3f bug

Update headers and APIs for L0 interop header updates/deprecations
2023-01-11 13:07:49 +01:00

113 lines
3.2 KiB
Plaintext

// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
// ospray stuff
#include "../geometry/GeometricModel.ih"
#include "DifferentialGeometry.ih"
#include "MotionTransform.ih"
#include "Ray.ih"
// c++ shared
#include "GroupShared.h"
#include "InstanceShared.h"
OSPRAY_BEGIN_ISPC_NAMESPACE
struct Renderer;
inline uniform AffineSpace3f Instance_getTransform(
const Instance *uniform self, const uniform float time)
{
// TODO: rtcGetGeometryTransform is missing the SYCL_EXTERNAL attribute
// Is there a different function we should call?
return self->xfm;
// return getInterpolatedTransform(self->geom, time);
}
#ifndef OSPRAY_TARGET_DPCPP
inline AffineSpace3f Instance_getTransform(
const Instance *uniform self, const float time)
{
return getInterpolatedTransform(self->geom, time);
}
#endif
inline void Instance_postIntersect(const Instance *uniform self,
const Renderer *uniform renderer,
varying DifferentialGeometry &dg,
const varying Ray &ray,
uniform int64 flags,
const uniform bool clip = false)
{
GeometricModel **uniform models =
clip ? self->group->clipModels : self->group->geometricModels;
#ifdef OSPRAY_TARGET_DPCPP
{
// DPC++ execution in a thread is scalar
const uint32 geomID = ray.geomID;
#else
foreach_unique (geomID in ray.geomID) {
#endif
GeometricModel_postIntersect(*(models + geomID), renderer, dg, ray, flags);
}
dg.instID =
(self->userID == RTC_INVALID_GEOMETRY_ID) ? ray.instID : self->userID;
uniform AffineSpace3f uxfm = self->xfm;
uniform AffineSpace3f rcp_uxfm = self->rcp_xfm;
#if 0
if ((flags & DG_MOTIONBLUR) == DG_MOTIONBLUR && self->motionBlur) {
uniform float utime;
uniform int cnt = 0;
#ifdef OSPRAY_TARGET_DPCPP
{
// DPC++ execution in a thread is scalar
const float t = ray.time;
#else
foreach_unique (t in ray.time) {
#endif
utime = t;
cnt++;
}
if (cnt > 1) { // varying xfm
const AffineSpace3f xfm = Instance_getTransform(self, ray.time);
const AffineSpace3f rcp_xfm = rcp(xfm);
dg.lP = xfmPoint(rcp_xfm, dg.P);
dg.Ns = xfmVector(transposed(rcp_xfm.l), dg.Ns);
dg.Ng = xfmVector(transposed(rcp_xfm.l), dg.Ng);
// scale dg.epsilon by max (epsilon is scalar and thus assumed to be
// isotropic anyway and hence cannot better handle non-uniform scaling)
dg.epsilon *= max(abs(xfm.l.vx.x), max(abs(xfm.l.vy.y), abs(xfm.l.vz.z)));
if (flags & DG_TANGENTS) {
dg.dPds = xfmVector(xfm, dg.dPds);
dg.dPdt = xfmVector(xfm, dg.dPdt);
}
return;
} else { // uniform xfm
uxfm = Instance_getTransform(self, utime);
rcp_uxfm = rcp(uxfm);
}
}
#endif
dg.lP = xfmPoint(rcp_uxfm, dg.P);
dg.Ns = xfmVector(transposed(rcp_uxfm.l), dg.Ns);
dg.Ng = xfmVector(transposed(rcp_uxfm.l), dg.Ng);
// scale dg.epsilon by max (epsilon is scalar and thus assumed to be
// isotropic anyway and hence cannot better handle non-uniform scaling)
dg.epsilon *= max(abs(uxfm.l.vx.x), max(abs(uxfm.l.vy.y), abs(uxfm.l.vz.z)));
if (flags & DG_TANGENTS) {
dg.dPds = xfmVector(uxfm, dg.dPds);
dg.dPdt = xfmVector(uxfm, dg.dPdt);
}
}
OSPRAY_END_ISPC_NAMESPACE