NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HLBVHBuilder.hpp
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 #pragma once
18 #include "cuda/CudaBVH.hpp"
19 #include "base/Timer.hpp"
20 
21 namespace FW
22 {
23 
25 {
26  bool hlbvh;
30 };
31 
32 //------------------------------------------------------------------------
33 
34 class HLBVHBuilder : public CudaBVH
35 {
36 public:
37  HLBVHBuilder (Scene* scene, const Platform& platform, HLBVHParams params);
38  virtual ~HLBVHBuilder (void);
39 
40  float getCPUTime () { return m_cpuTime; }
41  float getGPUTime () { return m_gpuTime; }
42  void getStats (U32& nodes, U32& leaves, U32& nodeTop);
43  void getSizes (F32& task, F32& split, F32& ads, F32& tri, F32& triIdx);
44 
45 private:
46  HLBVHBuilder (const HLBVHBuilder&); // forbidden
47  HLBVHBuilder& operator= (const HLBVHBuilder&); // forbidden
48 
49  Scene* m_scene;
50  Platform m_platform;
51  BVHNode* m_root;
52  float m_cpuTime;
53  float m_gpuTime;
54  U32 m_leafs;
55  U32 m_nodes;
56 
57  F32 m_sizeTask;
58  F32 m_sizeSplit;
59  F32 m_sizeADS;
60  F32 m_sizeTri;
61  F32 m_sizeTriIdx;
62 
63  S32 cluster_cnt;
64  //Buffer clusters;
65  Buffer cluster_bb;
66  Buffer cluster_bin_id;
67  Buffer cluster_split_id;
68 
69  F32 cudaTotalTime;
70  CudaModule* module;
71  S32 triCnt;
72  Array<U32> lvlNodes;
73 
74 protected:
75  void build();
76  void buildLBVH();
77  void buildHLBVH();
78 
79  void calcMortonAndSort(Buffer &triMorton, Buffer &triIdx);
80  void createClustersC(Buffer &triMorton, S32 d, Buffer &clusters);
81  void calcAABB(U32 nodeWritten);
82 
83  void buildTopLevel(Buffer *ooq, U32 &nodeWritten, U32 &nodeCreated, Buffer &clusters);
84  void buildBottomLevel(Buffer *q_in, Buffer *q_out, U32 &nodeWritten, U32 &nodeCreated, U32 bOfs, U32 n_bits);
85 
86  F32 calcSAHGPU();
88  S32 calcLeafs(S32 n);
89  void initMemory(Buffer& q_in, Buffer& q_out, int leafSize = 1);
90 
93 };
94 
95 //------------------------------------------------------------------------
96 }
HLBVHBuilder(Scene *scene, const Platform &platform, HLBVHParams params)
void createClustersC(Buffer &triMorton, S32 d, Buffer &clusters)
void getSizes(F32 &task, F32 &split, F32 &ads, F32 &tri, F32 &triIdx)
Cuda BVH class.
Definition: CudaBVH.hpp:93
void buildTopLevel(Buffer *ooq, U32 &nodeWritten, U32 &nodeCreated, Buffer &clusters)
void initMemory(Buffer &q_in, Buffer &q_out, int leafSize=1)
HLBVHParams m_params
virtual ~HLBVHBuilder(void)
void buildBottomLevel(Buffer *q_in, Buffer *q_out, U32 &nodeWritten, U32 &nodeCreated, U32 bOfs, U32 n_bits)
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
S32 calcLeafs(S32 n)
F32 calcSAHCPU(S32 n)
void getStats(U32 &nodes, U32 &leaves, U32 &nodeTop)
float F32
Definition: Defs.hpp:89
void calcMortonAndSort(Buffer &triMorton, Buffer &triIdx)
Declarations for the Cuda version of the BVH.
signed int S32
Definition: Defs.hpp:88
unsigned int U32
Definition: Defs.hpp:85
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 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 n
Definition: DLLImports.inl:325
Class holding various SAH and batch processing parameters.
Definition: Platform.hpp:46
BVH virtual node. Parent class of both a leaf node and an inner node.
Definition: BVHNode.hpp:136
void calcAABB(U32 nodeWritten)