NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SAHBVHBuilder.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2009-2010 NVIDIA Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "bvh/SAHBVHBuilder.hpp"
18 #include "base/Sort.hpp"
19 
20 using namespace FW;
21 
22 //------------------------------------------------------------------------
23 
25 : m_bvh (bvh),
26  m_platform (bvh.getPlatform()),
27  m_params (params),
28  m_sortDim (-1)
29 {
30 }
31 
32 //------------------------------------------------------------------------
33 
35 {
36 }
37 
38 //------------------------------------------------------------------------
39 
41 {
42  // Initialize reference stack and determine root bounds.
43 
44  const Vec3i* tris = (const Vec3i*)m_bvh.getScene()->getTriVtxIndexBuffer().getPtr();
45  const Vec3f* verts = (const Vec3f*)m_bvh.getScene()->getVtxPosBuffer().getPtr();
46 
47  NodeSpec rootSpec;
48  rootSpec.numRef = m_bvh.getScene()->getNumTriangles();
49  m_refStack.reset(rootSpec.numRef);
50 
51  // Set the references
52  for (int i = 0; i < rootSpec.numRef; i++)
53  {
54  m_refStack[i].triIdx = i;
55  for (int j = 0; j < 3; j++)
56  m_refStack[i].bounds.grow(verts[tris[i].get(j)]);
57  // Inflate the basic boxes so that box intersections are correct
58  m_refStack[i].bounds.min() -= BVH_EPSILON;
59  m_refStack[i].bounds.max() += BVH_EPSILON;
60  rootSpec.bounds.grow(m_refStack[i].bounds);
61  }
62 
63  // Inflate the basic boxes so that box intersections are correct
64  /*F32 EPSILON = (rootSpec.bounds.max()-rootSpec.bounds.min()).max() * 2e-5f;
65  rootSpec.bounds.min().set(Vec3f(FW_F32_MAX, FW_F32_MAX, FW_F32_MAX));
66  rootSpec.bounds.max().set(Vec3f(-FW_F32_MAX, -FW_F32_MAX, -FW_F32_MAX));
67  for (int i = 0; i < rootSpec.numRef; i++)
68  {
69  m_refStack[i].bounds.grow(m_refStack[i].bounds.min()-EPSILON);
70  m_refStack[i].bounds.grow(m_refStack[i].bounds.max()+EPSILON);
71  rootSpec.bounds.grow(m_refStack[i].bounds);
72  }*/
73 
74  // Initialize rest of the members.
75 
76  m_rightBounds.reset(rootSpec.numRef);
77  m_numDuplicates = 0;
79 
80  // Build recursively.
81 
82  BVHNode* root;
83  //root = buildNode(rootSpec, 0, 0.0f, 1.0f);
84  root = buildNode(rootSpec, 0, rootSpec.numRef-1, 0, 0.0f, 1.0f);
85 
87 
88  // Done.
89 
91  printf("SAHBVHBuilder: progress %.0f%%, duplicates %.0f%%\n",
92  100.0f, (F32)m_numDuplicates / (F32)m_bvh.getScene()->getNumTriangles() * 100.0f);
93  return root;
94 }
95 
96 //------------------------------------------------------------------------
97 
99 /*
100 int SAHBVHBuilder::sortCompare(void* data, int idxA, int idxB)
101 {
102  const SAHBVHBuilder* ptr = (const SAHBVHBuilder*)data;
103  int dim = ptr->m_sortDim;
104  const Reference& ra = ptr->m_refStack[idxA];
105  const Reference& rb = ptr->m_refStack[idxB];
106  F32 ca = ra.bounds.min()[dim] + ra.bounds.max()[dim];
107  F32 cb = rb.bounds.min()[dim] + rb.bounds.max()[dim];
108  return (ca < cb) ? -1 : (ca > cb) ? 1 : (ra.triIdx < rb.triIdx) ? -1 : (ra.triIdx > rb.triIdx) ? 1 : 0;
109 }
110 */
111 
112 bool SAHBVHBuilder::sortCompare(void* data, int idxA, int idxB)
113 {
114  const SAHBVHBuilder* ptr = (const SAHBVHBuilder*)data;
115  int dim = ptr->m_sortDim;
116  const Reference& ra = ptr->m_refStack[idxA];
117  const Reference& rb = ptr->m_refStack[idxB];
118  F32 ca = ra.bounds.min()[dim] + ra.bounds.max()[dim];
119  F32 cb = rb.bounds.min()[dim] + rb.bounds.max()[dim];
120  return (ca < cb) ? false : (ca > cb) ? true : (ra.triIdx < rb.triIdx) ? false : (ra.triIdx > rb.triIdx) ? true : false;
121 }
122 
123 //------------------------------------------------------------------------
124 
125 void SAHBVHBuilder::sortSwap(void* data, int idxA, int idxB)
126 {
127  SAHBVHBuilder* ptr = (SAHBVHBuilder*)data;
128  swap(ptr->m_refStack[idxA], ptr->m_refStack[idxB]);
129 }
130 
131 //------------------------------------------------------------------------
132 
133 BVHNode* SAHBVHBuilder::buildNode(const NodeSpec& spec, int level, F32 progressStart, F32 progressEnd)
134 {
135  // Display progress.
136 
138  {
139  printf("SAHBVHBuilder: progress %.0f%%, duplicates %.0f%%\r",
140  progressStart * 100.0f, (F32)m_numDuplicates / (F32)m_bvh.getScene()->getNumTriangles() * 100.0f);
142  }
143 
144  // Small enough or too deep => create leaf.
145 
146  if (level != 0 && spec.numRef <= m_platform.getMinLeafSize() || level >= MaxDepth) // Make sure we do not make the root a leaf -> GPU traversal will fail
147  return createLeaf(spec);
148 
149  // Find split candidates.
150 
151  F32 area = spec.bounds.area();
152  F32 leafSAH = area * m_platform.getTriangleCost(spec.numRef);
153  F32 nodeSAH = area * m_platform.getNodeCost(2);
154 
156  S32 axis = 0;
157 
158  ObjectSplit object = findObjectSplit(spec, nodeSAH);
159 
160  // Leaf SAH is the lowest => create leaf.
161 
162  F32 minSAH = min(leafSAH, object.sah);
163  if (level != 0 && minSAH == leafSAH && spec.numRef <= m_platform.getMaxLeafSize()) // Make sure we do not make the root a leaf -> GPU traversal will fail
164  return createLeaf(spec);
165 
166  // Perform split.
167 
168  NodeSpec left, right;
169  performObjectSplit(left, right, spec, object);
170  axis = object.sortDim;
171 
172  // Create inner node.
173 
174  m_numDuplicates += left.numRef + right.numRef - spec.numRef;
175  F32 progressMid = lerp(progressStart, progressEnd, (F32)right.numRef / (F32)(left.numRef + right.numRef));
176  BVHNode* rightNode = buildNode(right, level + 1, progressStart, progressMid);
177  BVHNode* leftNode = buildNode(left, level + 1, progressMid, progressEnd);
178 
179  return new InnerNode(spec.bounds, leftNode, rightNode, axis, splitType, false);
180 }
181 
182 //------------------------------------------------------------------------
183 
184 BVHNode* SAHBVHBuilder::buildNode(const NodeSpec& spec, int start, int end, int level, F32 progressStart, F32 progressEnd)
185 {
186  // Display progress.
187 
189  {
190  printf("SAHBVHBuilder: progress %.0f%%, duplicates %.0f%%\r",
191  progressStart * 100.0f, (F32)m_numDuplicates / (F32)m_bvh.getScene()->getNumTriangles() * 100.0f);
193  }
194 
195  // Small enough or too deep => create leaf.
196 
197  if (level != 0 && spec.numRef <= m_platform.getMinLeafSize() || level >= MaxDepth) // Make sure we do not make the root a leaf -> GPU traversal will fail
198  return createLeaf(spec, start, end);
199 
200  // Find split candidates.
201 
202  F32 area = spec.bounds.area();
203  F32 leafSAH = area * m_platform.getTriangleCost(spec.numRef);
204  F32 nodeSAH = area * m_platform.getNodeCost(2);
205 
207  S32 axis = 0;
208 
209  ObjectSplit object = findObjectSplit(start, end, nodeSAH);
210 
211  // Leaf SAH is the lowest => create leaf.
212 
213  F32 minSAH = min(leafSAH, object.sah);
214  if (level != 0 && minSAH == leafSAH && spec.numRef <= m_platform.getMaxLeafSize()) // Make sure we do not make the root a leaf -> GPU traversal will fail
215  return createLeaf(spec, start, end);
216 
217  // Perform split.
218 
219  NodeSpec left, right;
220  performObjectSplit(left, right, spec, start, end, object);
221  axis = object.sortDim;
222 
223  // Create inner node.
224 
225  m_numDuplicates += left.numRef + right.numRef - spec.numRef;
226  F32 progressMid = lerp(progressStart, progressEnd, (F32)right.numRef / (F32)(left.numRef + right.numRef));
227 
228  BVHNode* rightNode = buildNode(right, start+left.numRef, end, level + 1, progressStart, progressMid);
229  BVHNode* leftNode = buildNode(left, start, start+left.numRef-1, level + 1, progressMid, progressEnd);
230 
231  return new InnerNode(spec.bounds, leftNode, rightNode, axis, splitType, false);
232 }
233 
234 //------------------------------------------------------------------------
235 
237 {
238  Array<S32>& tris = m_bvh.getTriIndices();
239  for (int i = 0; i < spec.numRef; i++)
241  return new LeafNode(spec.bounds, tris.getSize() - spec.numRef, tris.getSize());
242 }
243 
244 //------------------------------------------------------------------------
245 
246 BVHNode* SAHBVHBuilder::createLeaf(const NodeSpec& spec, int start, int end)
247 {
248  Array<S32>& tris = m_bvh.getTriIndices();
249  for(int i = end; i >= start; i--)
250  tris.add(m_refStack[i].triIdx);
251 
252  return new LeafNode(spec.bounds, tris.getSize() - spec.numRef, tris.getSize());
253 }
254 
255 //------------------------------------------------------------------------
256 
258 {
259  ObjectSplit split;
260  const Reference* refPtr = m_refStack.getPtr(m_refStack.getSize() - spec.numRef);
261 
262  // Sort along each dimension.
263 
264  for (m_sortDim = 0; m_sortDim < 3; m_sortDim++)
265  {
267 
268  // Sweep right to left and determine bounds.
269 
270  AABB rightBounds;
271  for (int i = spec.numRef - 1; i > 0; i--)
272  {
273  rightBounds.grow(refPtr[i].bounds);
274  m_rightBounds[i - 1] = rightBounds;
275  }
276 
277  // Sweep left to right and select lowest SAH.
278 
279  AABB leftBounds;
280  for (int i = 1; i < spec.numRef; i++)
281  {
282  leftBounds.grow(refPtr[i - 1].bounds);
283  F32 sah = nodeSAH + leftBounds.area() * m_platform.getTriangleCost(i) + m_rightBounds[i - 1].area() * m_platform.getTriangleCost(spec.numRef - i);
284  if (sah < split.sah)
285  {
286  split.sah = sah;
287  split.sortDim = m_sortDim;
288  split.numLeft = i;
289  split.leftBounds = leftBounds;
290  split.rightBounds = m_rightBounds[i - 1];
291  }
292  }
293  }
294 
295  return split;
296 }
297 
298 //------------------------------------------------------------------------
299 
301 {
302  ObjectSplit split;
303  Reference* refPtr = m_refStack.getPtr(start);
304 
305  // Sort along each dimension.
306 
307  for (m_sortDim = 0; m_sortDim < 3; m_sortDim++)
308  {
309  sort(this, start, end+1, sortCompare, sortSwap);
310 
311  // Sweep right to left and determine bounds.
312 
313  AABB rightBounds;
314  for (int i = end-start; i > 0; i--)
315  {
316  rightBounds.grow(refPtr[i].bounds);
317  m_rightBounds[i - 1] = rightBounds;
318  }
319 
320  // Sweep left to right and select lowest SAH.
321 
322  AABB leftBounds;
323  for (int i = 1; i < end-start+1; i++)
324  {
325  leftBounds.grow(refPtr[i - 1].bounds);
326  F32 sah = nodeSAH + leftBounds.area() * m_platform.getTriangleCost(i) + m_rightBounds[i - 1].area() * m_platform.getTriangleCost((end-start+1) - i);
327 
328  if(sah < split.sah)
329  {
330  split.sah = sah;
331  split.sortDim = m_sortDim;
332  split.numLeft = i;
333  split.leftBounds = leftBounds;
334  split.rightBounds = m_rightBounds[i - 1];
335  }
336  }
337  }
338 
339  return split;
340 }
341 
342 //------------------------------------------------------------------------
343 
344 void SAHBVHBuilder::performObjectSplit(NodeSpec& left, NodeSpec& right, const NodeSpec& spec, const ObjectSplit& split)
345 {
346  m_sortDim = split.sortDim;
348 
349  left.numRef = split.numLeft;
350  left.bounds = split.leftBounds;
351  right.numRef = spec.numRef - split.numLeft;
352  right.bounds = split.rightBounds;
353 }
354 
355 //------------------------------------------------------------------------
356 
357 void SAHBVHBuilder::performObjectSplit(NodeSpec& left, NodeSpec& right, const NodeSpec& spec, int start, int end, const ObjectSplit& split)
358 {
359  m_sortDim = split.sortDim;
360  sort(this, start, end+1, sortCompare, sortSwap);
361 
362  left.numRef = split.numLeft;
363  left.bounds = split.leftBounds;
364  right.numRef = spec.numRef - split.numLeft;
365  right.bounds = split.rightBounds;
366 }
367 
368 //------------------------------------------------------------------------
bool enablePrints
Flag whether to enable prints about build progress.
Definition: BVH.hpp:112
Stucture holding the BVH build parameters.
Definition: BVH.hpp:109
Array< Reference > m_refStack
Reference stack.
S32 m_numDuplicates
Number of duplicated references.
Buffer & getTriVtxIndexBuffer(void)
Returns buffer of triangle's vertex indieces.
Definition: Scene.hpp:75
BVH & m_bvh
BVH being built.
AABB leftBounds
AABB of a left child node.
F32 sah
SAH cost of the split.
AABB bounds
Bounding box of the node.
void sort(void *data, int start, int end, SortCompareFunc compareFunc, SortSwapFunc swapFunc, bool multicore=false)
Definition: Sort.cpp:203
Declarations for SAHBVHBuilder.
FW_CUDA_FUNC const Vec3f & max(void) const
Definition: Util.hpp:49
BVH leaf node.
Definition: BVHNode.hpp:275
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 * data
Definition: DLLImports.inl:319
void ** ptr
Definition: DLLImports.cpp:74
BVHNode * buildNode(const NodeSpec &spec, int level, F32 progressStart, F32 progressEnd)
Builds a BVH node. The built node may be an inner node as well as a leaf node.
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
BVH inner node.
Definition: BVHNode.hpp:228
AABB rightBounds
AABB of a right child node.
S32 numRef
Number of the node's references saved in a node stack.
void start(void)
Definition: Timer.hpp:42
ObjectSplit findObjectSplit(const NodeSpec &spec, F32 nodeSAH)
Finds the best object split of the node.
SAHBVHBuilder(BVH &bvh, const BVH::BuildParams &params)
Constructor.
float getTriangleCost(S32 n) const
Calcuates cost of a given number of triangles rounded to the batch size.
Definition: Platform.hpp:95
Array< AABB > m_rightBounds
Bounding boxes of all the possible right children.
const U8 * getPtr(S64 ofs=0)
Definition: Buffer.hpp:106
BVHNode * createLeaf(const NodeSpec &spec)
Builds a leaf node.
FW_CUDA_FUNC const T & get(int idx) const
Definition: Math.hpp:128
static void sortSwap(void *data, int idxA, int idxB)
Sort swap function. Swaps two references placed in the reference stack. For details see framework/bas...
void reset(S size=0)
Definition: Array.hpp:317
virtual ~SAHBVHBuilder(void)
Destructor.
Array< S32 > & getTriIndices(void)
Returns an array of triangle indices to which leaf nodes are pointig. These indices point to scene's ...
Definition: BVH.hpp:180
float F32
Definition: Defs.hpp:89
Scene * getScene(void) const
Timer m_progressTimer
Progress timer.
Structure holding info about a split of the BVH node.
FW_CUDA_FUNC float area(void) const
Definition: Util.hpp:45
S32 m_sortDim
Sort dimension. Used by the sort method.
float getNodeCost(S32 n) const
Calculates cost of a given number of nodes rounded to the batch size.
Definition: Platform.hpp:102
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
Definition: Math.hpp:461
int getNumTriangles(void) const
Definition: Scene.hpp:61
BVH acceleration structure class.
Definition: BVH.hpp:74
const Platform & m_platform
Platform settings.
signed int S32
Definition: Defs.hpp:88
static bool sortCompare(void *data, int idxA, int idxB)
Sort comparator. Sorts references according to their position in descending order. For details see framework/base.Sort.hpp.
SplitType
Available split types.
Definition: BVHNode.hpp:65
T & add(void)
Definition: Array.hpp:384
FW_CUDA_FUNC const Vec3f & min(void) const
Definition: Util.hpp:48
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 dim
Definition: DLLImports.inl:74
S32 triIdx
Index of the triangle.
void performObjectSplit(NodeSpec &left, NodeSpec &right, const NodeSpec &spec, const ObjectSplit &split)
Performs the split operation.
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
const BVH::BuildParams & m_params
Build parameters.
FW_CUDA_FUNC void grow(const Vec3f &pt)
Definition: Util.hpp:41
S32 numLeft
Number of triangles in left child node.
void printf(const char *fmt,...)
Definition: Defs.cpp:225
S32 getMaxLeafSize() const
Definition: Platform.hpp:157
void compact(void)
Definition: Array.hpp:335
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
Definition: DLLImports.inl:333
Structure holding triangle's index together with its bounding box.
FW_CUDA_FUNC void swap(T &a, T &b)
Definition: Defs.hpp:183
AABB bounds
Bounding box of the triangle.
BVH virtual node. Parent class of both a leaf node and an inner node.
Definition: BVHNode.hpp:136
#define BVH_EPSILON
T & removeLast(void)
Definition: Array.hpp:465
S32 sortDim
Dimension in which triangles are sorted.
const T * getPtr(S idx=0) const
Definition: Array.hpp:202
S32 getMinLeafSize() const
Definition: Platform.hpp:152
F32 getElapsed(void)
Definition: Timer.hpp:44
S getSize(void) const
Definition: Array.hpp:188
Structure holding specifications of a BVH's node.
FW_CUDA_FUNC A lerp(const A &a, const A &b, const B &t)
Definition: Math.hpp:115
Class that builds a BVH using SAH.
virtual BVHNode * run(void)
Performs the actual build.