Files
ospray/modules/cpu/common/Data.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

105 lines
3.5 KiB
Plaintext

// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#ifdef OSPRAY_TARGET_DPCPP
#include "common/OSPCommon.ih"
#include "rkcommon/math/LinearSpace.h"
#include "rkcommon/math/box.h"
using namespace rkcommon;
using namespace rkcommon::math;
#else
#include "rkcommon/math/LinearSpace.ih"
#include "rkcommon/math/box.ih"
#endif
OSPRAY_BEGIN_ISPC_NAMESPACE
struct Data1D
{
uint8 *addr;
int64 byteStride;
uint32 numItems;
bool huge; // 64bit address calculation necessary
};
inline void Data1D_Constructor(Data1D *uniform self)
{
self->addr = NULL;
self->byteStride = 0;
self->numItems = 0;
self->huge = false;
}
// ok to pass-by-value, will be inlined and optimized
inline uniform bool valid(const uniform Data1D data)
{
return data.addr != NULL;
}
// special 64-bit safe code:
#define BITS 20
// ok to pass-by-value, will be inlined and optimized
#ifdef OSPRAY_TARGET_DPCPP
// DPC++ execution in a thread is scalar
#define __define_get(T) \
inline uniform T get_##T(const uniform Data1D data, const uniform int index) \
{ \
return *((const T *)(data.addr + data.byteStride * index)); \
}
#else
#define __define_get(T) \
inline T get_##T(const uniform Data1D data, const varying int index) \
{ \
if (data.huge) { \
T v; \
const int index_lo = index & ((1 << BITS) - 1); \
const int index_hi = index - index_lo; \
const int scaledIndexLo = index_lo * data.byteStride; \
foreach_unique (hi in index_hi) { \
/* uniform offset for upper bits */ \
const uniform uint64 scaledIndexHi = (uint64)(hi)*data.byteStride; \
/* properly shifted base address (shifted by 64-bits) */ \
const uint8 *uniform base_hi = data.addr + scaledIndexHi; \
v = *((const T *)(base_hi + scaledIndexLo)); \
} \
return v; \
} else \
return *((const T *)(data.addr + data.byteStride * index)); \
} \
inline uniform T get_##T(const uniform Data1D data, const uniform int index) \
{ \
return *((const T *)(data.addr + data.byteStride * index)); \
}
#endif
__define_get(int32);
__define_get(vec2i);
__define_get(vec3i);
__define_get(vec4i);
__define_get(uint8);
__define_get(uint32);
__define_get(vec2ui);
__define_get(vec3ui);
__define_get(vec4ui);
__define_get(float);
__define_get(vec2f);
__define_get(vec3f);
__define_get(vec4f);
__define_get(box1f);
__define_get(box2f);
__define_get(box3f);
__define_get(box4f);
__define_get(linear3f);
#undef __define_get
#undef BITS
OSPRAY_END_ISPC_NAMESPACE