26 m_platform (bvh.getPlatform()),
52 for (
int i = 0; i < rootSpec.
numRef; i++)
55 for (
int j = 0; j < 3; j++)
91 printf(
"SAHBVHBuilder: progress %.0f%%, duplicates %.0f%%\n",
120 return (ca < cb) ?
false : (ca > cb) ?
true : (ra.
triIdx < rb.
triIdx) ?
false : (ra.
triIdx > rb.
triIdx) ?
true :
false;
139 printf(
"SAHBVHBuilder: progress %.0f%%, duplicates %.0f%%\r",
162 F32 minSAH =
min(leafSAH,
object.sah);
170 axis =
object.sortDim;
176 BVHNode* rightNode =
buildNode(right, level + 1, progressStart, progressMid);
179 return new InnerNode(spec.
bounds, leftNode, rightNode, axis, splitType,
false);
190 printf(
"SAHBVHBuilder: progress %.0f%%, duplicates %.0f%%\r",
213 F32 minSAH =
min(leafSAH,
object.sah);
221 axis =
object.sortDim;
231 return new InnerNode(spec.
bounds, leftNode, rightNode, axis, splitType,
false);
239 for (
int i = 0; i < spec.
numRef; i++)
249 for(
int i = end; i >= start; i--)
271 for (
int i = spec.
numRef - 1; i > 0; i--)
273 rightBounds.
grow(refPtr[i].bounds);
280 for (
int i = 1; i < spec.
numRef; i++)
282 leftBounds.
grow(refPtr[i - 1].bounds);
314 for (
int i = end-start; i > 0; i--)
316 rightBounds.
grow(refPtr[i].bounds);
323 for (
int i = 1; i < end-start+1; i++)
325 leftBounds.
grow(refPtr[i - 1].bounds);
bool enablePrints
Flag whether to enable prints about build progress.
Stucture holding the BVH build parameters.
Array< Reference > m_refStack
Reference stack.
S32 m_numDuplicates
Number of duplicated references.
Buffer & getTriVtxIndexBuffer(void)
Returns buffer of triangle's vertex indieces.
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)
Declarations for SAHBVHBuilder.
FW_CUDA_FUNC const Vec3f & max(void) const
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
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.
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
AABB rightBounds
AABB of a right child node.
S32 numRef
Number of the node's references saved in a node stack.
ObjectSplit findObjectSplit(const NodeSpec &spec, F32 nodeSAH)
Finds the best object split of the node.
SAHBVHBuilder(BVH &bvh, const BVH::BuildParams ¶ms)
Constructor.
Array< AABB > m_rightBounds
Bounding boxes of all the possible right children.
const U8 * getPtr(S64 ofs=0)
BVHNode * createLeaf(const NodeSpec &spec)
Builds a leaf node.
FW_CUDA_FUNC const T & get(int idx) const
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...
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 ...
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
S32 m_sortDim
Sort dimension. Used by the sort method.
FW_CUDA_FUNC T min(const VectorBase< T, L, S > &v)
int getNumTriangles(void) const
BVH acceleration structure class.
const Platform & m_platform
Platform settings.
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.
FW_CUDA_FUNC const Vec3f & min(void) const
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
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
const BVH::BuildParams & m_params
Build parameters.
FW_CUDA_FUNC void grow(const Vec3f &pt)
S32 numLeft
Number of triangles in left child node.
void printf(const char *fmt,...)
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
Structure holding triangle's index together with its bounding box.
FW_CUDA_FUNC void swap(T &a, T &b)
AABB bounds
Bounding box of the triangle.
BVH virtual node. Parent class of both a leaf node and an inner node.
S32 sortDim
Dimension in which triangles are sorted.
const T * getPtr(S idx=0) const
Structure holding specifications of a BVH's node.
FW_CUDA_FUNC A lerp(const A &a, const A &b, const B &t)
Class that builds a BVH using SAH.
virtual BVHNode * run(void)
Performs the actual build.