6#define _USE_MATH_DEFINES 
   16    x = (x ^ (x >> 1)) & 0x33333333;
 
   17    x = (x ^ (x >> 2)) & 0x0f0f0f0f;
 
   18    x = (x ^ (x >> 4)) & 0x00ff00ff;
 
   19    x = (x ^ (x >> 8)) & 0x0000ffff;
 
 
   26    x = (x ^ (x << 8)) & 0x00ff00ff;
 
   27    x = (x ^ (x << 4)) & 0x0f0f0f0f;
 
   28    x = (x ^ (x << 2)) & 0x33333333;
 
   29    x = (x ^ (x << 1)) & 0x55555555;
 
 
   44template<
typename RenderFn, 
typename Gr
idT>
 
   45inline float renderImage(
bool useCuda, 
const RenderFn renderOp, 
int width, 
int height, 
float* image, 
const GridT* grid)
 
   47    using ClockT = std::chrono::high_resolution_clock;
 
   48    auto t0 = ClockT::now();
 
   51        useCuda, width * height, 512, __FILE__, __LINE__, [renderOp, image, grid] 
__hostdev__(
int start, 
int end) {
 
   52            renderOp(start, end, image, grid);
 
   56    auto t1 = ClockT::now();
 
   57    auto duration = std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count() / 1000.f;
 
 
   61inline void saveImage(
const std::string& filename, 
int width, 
int height, 
const float* image)
 
   63    const auto isLittleEndian = []() -> 
bool {
 
   65        static bool result = 
reinterpret_cast<uint8_t*
>(&x)[0] == 1;
 
   73    std::fstream fs(filename, std::ios::out | std::ios::binary);
 
   75        throw std::runtime_error(
"Unable to open file: " + filename);
 
   83    for (
int i = 0; i < width * height; ++i) {
 
   85        fs.write((
char*)&r, 
sizeof(
float));
 
 
   89template<
typename Vec3T>
 
   95    inline RayGenOp(
float wBBoxDimZ, Vec3T wBBoxCenter)
 
 
  111        const float fov = 45.f;
 
  112        const float u = (float(x) + 0.5f) / w;
 
  113        const float v = (float(y) + 0.5f) / h;
 
  114        const float aspect = w / float(h);
 
  115        const float Px = (2.f * u - 1.f) * tanf(fov / 2 * 3.14159265358979323846f / 180.f) * aspect;
 
  116        const float Py = (2.f * v - 1.f) * tanf(fov / 2 * 3.14159265358979323846f / 180.f);
 
  118        Vec3T       dir(Px, Py, -1.f);
 
 
  141        const int   mask = 1 << 7;
 
  142        const float bg = ((x & mask) ^ (y & mask)) ? 1.0f : 0.5f;
 
  143        outImage[offset] = alpha * value + (1.0f - alpha) * bg;
 
 
A collection of parallel compute primitives.
void computeForEach(bool useCuda, int numItems, int blockSize, const char *file, int line, const FunctorT &op, Args... args)
Definition ComputePrimitives.h:146
void computeSync(bool useCuda, const char *file, int line)
Definition ComputePrimitives.h:125
Implements a light-weight self-contained VDB data-structure in a single file! In other words,...
__hostdev__ void mortonDecode(uint32_t code, uint32_t &x, uint32_t &y)
Definition common.h:33
__hostdev__ void mortonEncode(uint32_t &code, uint32_t x, uint32_t y)
Definition common.h:39
__hostdev__ uint32_t SeparateBy1(uint32_t x)
Definition common.h:23
float renderImage(bool useCuda, const RenderFn renderOp, int width, int height, float *image, const GridT *grid)
Definition common.h:45
__hostdev__ uint32_t CompactBy1(uint32_t x)
Definition common.h:13
void saveImage(const std::string &filename, int width, int height, const float *image)
Definition common.h:61
__hostdev__ void mortonDecode(uint32_t code, uint32_t &x, uint32_t &y)
Definition common.h:33
#define __hostdev__
Definition Util.h:73
__hostdev__ void operator()(float *outImage, int i, int w, int h, float value, float alpha) const
Definition common.h:127
RayGenOp(float wBBoxDimZ, Vec3T wBBoxCenter)
Definition common.h:95
__hostdev__ void operator()(int i, int w, int h, Vec3T &outOrigin, Vec3T &outDir) const
Definition common.h:101
Vec3T mWBBoxCenter
Definition common.h:93
float mWBBoxDimZ
Definition common.h:92