NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CudaKDTree.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 #include "gpu/Buffer.hpp"
9 #include "io/Stream.hpp"
10 #include "kdtree/KDTree.hpp"
11 #include "CudaAS.hpp"
13 
14 namespace FW
15 {
20 class CudaKDTree : public CudaAS
21 {
22 public:
24 
29  explicit CudaKDTree (const KDTree& kdtree);
30 
35  CudaKDTree (CudaKDTree& other) { operator=(other); }
36 
41  explicit CudaKDTree (InputStream& in);
42 
46  ~CudaKDTree (void);
47 
52  Buffer& getNodeBuffer (void) { return m_nodes; }
53 
58  Buffer& getTriIndexBuffer (void) { return m_triIndex; }
59 
65  Buffer& getTriWoopBuffer (void) { return m_triWoop; }
66 
71  void serialize (OutputStream& out);
72 
77  const AABB& getBBox (void) const { return m_bbox; }
78 
79 private:
83  struct StackEntry
84  {
85  const KDTreeNode* node;
86  S32 idx;
87 
93  StackEntry(const KDTreeNode* n = NULL, int i = 0) : node(n), idx(i) {}
94 
99  int encodeIdx(void) const { return (node->isLeaf()) ? ~idx : idx; }
100  };
101 
102 private:
103 
108  void createNodeTriIdx (const KDTree& kdtree);
109 
114  void createWoopTri (const KDTree& kdtree);
115 
116  Buffer m_nodes;
117  Buffer m_triIndex;
118  Buffer m_triWoop;
119 
120  AABB m_bbox;
121 };
122 
123 }
Definitions for acceleration structure interface.
#define NULL
Definition: Defs.hpp:39
CudaKDTree(CudaKDTree &other)
Copy constructor. [in] kdtree KDTree to copy.
Definition: CudaKDTree.hpp:35
Buffer & getTriIndexBuffer(void)
Returns triangle index buffer.
Definition: CudaKDTree.hpp:58
Cuda friendly KDTree representation.
Definition: CudaKDTree.hpp:20
K-d tree acceleration structure class.
Definition: KDTree.hpp:41
Buffer & getTriWoopBuffer(void)
Returns buffer of woopified triangles.
Definition: CudaKDTree.hpp:65
CudaKDTree(const KDTree &kdtree)
Constructor. [in] kdtree KDTree to convert.
Definition: CudaKDTree.cpp:8
void serialize(OutputStream &out)
Writes CudaKDTree to a given output stream.
Definition: CudaKDTree.cpp:31
signed int S32
Definition: Defs.hpp:88
~CudaKDTree(void)
Destructor.
Definition: CudaKDTree.cpp:25
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
BVHLayout getLayout(void) const
Returns layout of buffers.
Definition: CudaKDTree.hpp:23
Buffer & getNodeBuffer(void)
Returns node buffer.
Definition: CudaKDTree.hpp:52
const AABB & getBBox(void) const
Returns bounding box of the CudaKDTree's source scene.
Definition: CudaKDTree.hpp:77
K-d tree virtual parent node class.
Definition: KDTreeNode.hpp:51
Interface for acceleration structure.
Definition: CudaAS.hpp:19