NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
BVH.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2011, NVIDIA Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA Corporation nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "bvh/BVH.hpp"
29 #include "bvh/SplitBVHBuilder.hpp"
30 #include "bvh/SAHBVHBuilder.hpp"
33 
34 using namespace FW;
35 
36 BVH::BVH(Scene* scene, const Platform& platform, const BuildParams& params, Environment* env) : AccelerationStructure(scene, platform)
37 {
38  m_env = env;
39 
40  string bvhBuilder;
41  m_env->GetStringValue("BVHBuilder", bvhBuilder);
42 
43  if (params.enablePrints)
44  printf("BVH builder: %d tris, %d vertices\n", scene->getNumTriangles(), scene->getNumVertices());
45 
46  if (bvhBuilder == "SplitBVH")
47  {
48  m_root = SplitBVHBuilder(*this, params).run();
49  }
50  else if (bvhBuilder == "SAHBVH")
51  {
52  m_root = SAHBVHBuilder(*this, params).run();
53  }
54  else if (bvhBuilder == "OcclusionBVH")
55  {
56  m_root = OcclusionBVHBuilder(*this, params, FW::Vec3f(0.0f, 0.0f, 0.0f)).run();
57  }
58 
59  if (params.enablePrints)
60  printf("BVH: Scene bounds: (%.1f,%.1f,%.1f) - (%.1f,%.1f,%.1f)\n", m_root->m_bounds.min().x, m_root->m_bounds.min().y, m_root->m_bounds.min().z,
61  m_root->m_bounds.max().x, m_root->m_bounds.max().y, m_root->m_bounds.max().z);
62 
63  float sah = 0.f;
64  m_root->computeSubtreeProbabilities(m_platform, 1.f, sah);
65  if (params.enablePrints)
66  printf("top-down sah: %.2f\n", sah);
67 
68  if(params.stats)
69  {
70  params.stats->SAHCost = sah;
71  params.stats->branchingFactor = 2;
76  }
77 }
78 
79 static S32 currentTreelet;
80 static Set<S32> uniqueTreelets;
81 
82 void BVH::trace(RayBuffer& rays, RayStats* stats) const
83 {
84  for(S32 i=0;i<rays.getSize();i++)
85  {
86  Ray ray = rays.getRayForSlot(i); // takes a local copy
87  RayResult& result = rays.getMutableResultForSlot(i);
88 
89  result.clear();
90 
91  currentTreelet = -2;
92  uniqueTreelets.clear();
93 
94  if(stats)
95  {
96  stats->platform = m_platform;
97  stats->numRays++;
98  }
99 
100  traceRecursive(m_root, ray,result,rays.getNeedClosestHit(), stats);
101  }
102 }
103 
104 void BVH::traceRecursive(BVHNode* node, Ray& ray, RayResult& result,bool needClosestHit, RayStats* stats) const
105 {
106  if(currentTreelet != node->m_treelet)
107  {
108  if(stats)
109  {
110 // if(!uniqueTreelets.contains(node->m_treelet)) // count unique treelets (comment this line to count all)
111  stats->numTreelets++;
112  }
113  currentTreelet = node->m_treelet;
114  }
115 
116  if(node->isLeaf())
117  {
118  const LeafNode* leaf = reinterpret_cast<const LeafNode*>(node);
119  const Vec3i* triVtxIndex = (const Vec3i*)m_scene->getTriVtxIndexBuffer().getPtr();
120  const Vec3f* vtxPos = (const Vec3f*)m_scene->getVtxPosBuffer().getPtr();
121 
122  if(stats)
124 
125  for(int i=leaf->m_lo; i<leaf->m_hi; i++)
126  {
127  S32 index = m_triIndices[i];
128  const Vec3i& ind = triVtxIndex[index];
129  const Vec3f& v0 = vtxPos[ind.x];
130  const Vec3f& v1 = vtxPos[ind.y];
131  const Vec3f& v2 = vtxPos[ind.z];
132  Vec3f bary = Intersect::RayTriangle(v0,v1,v2, ray);
133  float t = bary[2];
134 
135  if(t>ray.tmin && t<ray.tmax)
136  {
137  ray.tmax = t;
138  result.t = t;
139  result.id = index;
140 
141  if(!needClosestHit)
142  return;
143  }
144  }
145  }
146  else
147  {
148  if(stats)
150 
151  const int TMIN = 0;
152  const int TMAX = 1;
153  const InnerNode* inner = reinterpret_cast<const InnerNode*>(node);
154  BVHNode* child0 = inner->m_children[0];
155  BVHNode* child1 = inner->m_children[1];
156  Vec2f tspan0 = Intersect::RayBox(child0->m_bounds, ray);
157  Vec2f tspan1 = Intersect::RayBox(child1->m_bounds, ray);
158  bool intersect0 = (tspan0[TMIN]<=tspan0[TMAX]) && (tspan0[TMAX]>=ray.tmin) && (tspan0[TMIN]<=ray.tmax);
159  bool intersect1 = (tspan1[TMIN]<=tspan1[TMAX]) && (tspan1[TMAX]>=ray.tmin) && (tspan1[TMIN]<=ray.tmax);
160 
161  if(intersect0 && intersect1)
162  if(tspan0[TMIN] > tspan1[TMIN])
163  {
164  swap(tspan0,tspan1);
165  swap(child0,child1);
166  }
167 
168  if(intersect0)
169  traceRecursive(child0,ray,result,needClosestHit,stats);
170 
171  if(result.hit() && !needClosestHit)
172  return;
173 
174 // if(tspan1[TMIN] <= ray.tmax) // this test helps only about 1-2%
175  if(intersect1)
176  traceRecursive(child1,ray,result,needClosestHit,stats);
177  }
178 }
bool enablePrints
Flag whether to enable prints about build progress.
Definition: BVH.hpp:112
Stucture holding the BVH build parameters.
Definition: BVH.hpp:109
BVHNode * run(void)
Performs the actual build.
S32 getSize() const
Gets size of the buffer (number of rays).
Definition: RayBuffer.hpp:52
S32 m_lo
Lower index to the BVH's triangle index array.
Definition: BVHNode.hpp:314
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1
Definition: DLLImports.inl:353
Buffer & getTriVtxIndexBuffer(void)
Returns buffer of triangle's vertex indieces.
Definition: Scene.hpp:75
bool GetStringValue(const char *name, char *value, const bool isFatal=false) const
S32 branchingFactor
Number of children nodes per one parent node.
Definition: BVH.hpp:99
Declarations for SAHBVHBuilder.
FW_CUDA_FUNC const Vec3f & max(void) const
Definition: Util.hpp:49
Definition: Hash.hpp:37
BVH leaf node.
Definition: BVHNode.hpp:275
Stats * stats
Statistics. If NULL, no statistics are gathered.
Definition: BVH.hpp:111
Buffer & getVtxPosBuffer(void)
Returns vertex position buffer.
Definition: Scene.hpp:103
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat GLfloat z GLuint GLint GLenum GLboolean GLsizei const GLvoid pointer GLuint GLuint const GLchar name GLenum GLsizei GLenum GLsizei GLsizei height GLenum GLuint renderbuffer GLenum GLenum GLint * params
Definition: DLLImports.inl:373
float t
Definition: Util.hpp:84
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2
Definition: DLLImports.inl:355
BVH inner node.
Definition: BVHNode.hpp:228
S32 numLeafNodes
Total number of leaf nodes.
Definition: BVH.hpp:101
FW_CUDA_FUNC bool hit(void) const
Definition: Util.hpp:80
S32 numTreelets
Total number of traversal steps.
Definition: BVH.hpp:65
S32 numTriangleTests
Total number of ray-triangle tests.
Definition: BVH.hpp:63
S32 numRays
Total number of rays.
Definition: BVH.hpp:62
S32 numChildNodes
Total number of children nodes.
Definition: BVH.hpp:102
Vec2f RayBox(const AABB &box, const Ray &ray)
Definition: Util.cpp:34
S32 numInnerNodes
Total number of inner nodes.
Definition: BVH.hpp:100
Definition: Util.hpp:62
Structure holding ray statistics. Also provides print to the console. These statistics are used in a ...
Definition: BVH.hpp:45
const Ray & getRayForSlot(S32 slot) const
Gets a ray assigned to a given slot.
Definition: RayBuffer.hpp:89
const U8 * getPtr(S64 ofs=0)
Definition: Buffer.hpp:106
bool getNeedClosestHit() const
Returns whether the closest hit is needed.
Definition: RayBuffer.hpp:150
S32 roundToTriangleBatchSize(S32 n) const
Rounds given value up to the nearest triangle batch size multiple.
Definition: Platform.hpp:132
Declarations for SplitBVHBuilder.
Declarations for the BVH acceleration structure.
int getNumVertices(void) const
Definition: Scene.hpp:66
Vec3f RayTriangle(const Vec3f &v0, const Vec3f &v1, const Vec3f &v2, const Ray &ray)
Definition: Util.cpp:50
void computeSubtreeProbabilities(const Platform &p, float parentProbability, float &sah)
Calculates node's subtree probabilities and also sah price.
Definition: BVHNode.cpp:68
Ray buffer class. Stores rays.
Definition: RayBuffer.hpp:38
int getNumTriangles(void) const
Definition: Scene.hpp:61
float tmax
Definition: Util.hpp:70
signed int S32
Definition: Defs.hpp:88
FW_CUDA_FUNC void clear(void)
Definition: Util.hpp:81
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat v0
Definition: DLLImports.inl:353
S32 numTris
Total number of triangles.
Definition: BVH.hpp:103
virtual bool isLeaf() const =0
FW_CUDA_FUNC const Vec3f & min(void) const
Definition: Util.hpp:48
float tmin
Definition: Util.hpp:68
virtual BVHNode * run(void)
S32 numNodeTests
Total number of ray-node tests.
Definition: BVH.hpp:64
int m_treelet
For queuing tests (qmachine uses this).
Definition: BVHNode.hpp:178
AABB m_bounds
Bounding box of the node.
Definition: BVHNode.hpp:172
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint index
Definition: DLLImports.inl:363
Class holding 3d scene.
Definition: Scene.hpp:44
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction f
Definition: DLLImports.inl:88
Class performing SBVH build.
void printf(const char *fmt,...)
Definition: Defs.cpp:225
virtual S32 getNumChildNodes() const =0
int getSubtreeSize(BVH_STAT stat=BVH_STAT_NODE_COUNT) const
Calculates various information about the node's subtree.
Definition: BVHNode.cpp:36
Class holding various SAH and batch processing parameters.
Definition: Platform.hpp:46
FW_CUDA_FUNC void swap(T &a, T &b)
Definition: Defs.hpp:183
BVH virtual node. Parent class of both a leaf node and an inner node.
Definition: BVHNode.hpp:136
S32 getNumTriangles() const
Definition: BVHNode.hpp:313
F32 SAHCost
Total sah cost of the BVH.
Definition: BVH.hpp:98
RayResult & getMutableResultForSlot(S32 slot)
Gets a mutable ray assigned to a given slot.
Definition: RayBuffer.hpp:110
void trace(RayBuffer &rays, RayStats *stats=NULL) const
CPU traversal.
Definition: BVH.cpp:82
Class that builds a BVH using SAH.
BVHNode * m_children[2]
Child nodes.
Definition: BVHNode.hpp:268
Platform platform
Platform settings of the BVH. Set by whoever sets the stats.
Definition: BVH.hpp:66
BVH(Scene *scene, const Platform &platform, const BuildParams &params, Environment *env)
Constructor.
Definition: BVH.cpp:36
virtual BVHNode * run(void)
Performs the actual build.
S32 roundToNodeBatchSize(S32 n) const
Rounds given value up to the nearest node batch size multiple.
Definition: Platform.hpp:139