-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommon.h
94 lines (74 loc) · 2.79 KB
/
common.h
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
// ======================================================================== //
// Copyright 2022-2022 Stefan Zellmann //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ======================================================================== //
#pragma once
#include <owl/owl.h>
#include <owl/common/math/AffineSpace.h>
#include <owl/common/math/box.h>
#include <owl/common/math/random.h>
#include <cuda_runtime.h>
using namespace owl;
using namespace owl::common;
typedef owl::interval<float> range1f;
#define RADIANCE_RAY_TYPE 0
#define SAMPLING_RAY_TYPE 1
#define CLIP_PLANES_MAX 1
#define LIGHTS_MAX 4
#define EXA_STITCH_SAMPLER 0
#define AMR_CELL_SAMPLER 1
#define EXA_BRICK_SAMPLER 2
#define EXA_BRICK_SAMPLER_ABR_BVH 0
#define EXA_BRICK_SAMPLER_EXT_BVH 1
#define PATH_TRACING_INTEGRATOR 0
#define DIRECT_LIGHT_INTEGRATOR 1
#define RAY_MARCHING_INTEGRATOR 2
#define SHADE_MODE_DEFAULT 0
#define SHADE_MODE_GRIDLETS 1
#define SHADE_MODE_TEASER 2
#define EXABRICK_ABR_TRAVERSAL 0
#define MC_DDA_TRAVERSAL 1
#define MC_BVH_TRAVERSAL 2
#define EXABRICK_KDTREE_TRAVERSAL 3
#define EXABRICK_BVH_TRAVERSAL 4
#define EXABRICK_EXT_BVH_TRAVERSAL 5
namespace exa {
typedef int SamplingMode;
typedef int TraversalMode;
inline __both__
float lerp(const float val1, const float val2, const float x)
{
return (1.f-x)*val1+x*val2;
}
inline void printGPUMemory(std::string str)
{
size_t free, total;
cudaMemGetInfo(&free, &total);
size_t used = total-free;
std::cout << str << ": " << prettyNumber(used) << '\n';
}
#ifdef __CUDA_ARCH__
#define DEBUGGING 1
#define DBG_X (owl::getLaunchDims().x/2)
#define DBG_Y (owl::getLaunchDims().y/2)
__device__ inline bool debug()
{
#if DEBUGGING
return (owl::getLaunchIndex().x == DBG_X && owl::getLaunchIndex().y == DBG_Y);
#else
return false;
#endif
}
#endif
} // ::exa