NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OcclusionBVHBuilder.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 "SplitBVHBuilder.hpp"
19 
20 namespace FW
21 {
22 //------------------------------------------------------------------------
23 
25 {
26 protected:
27  enum
28  {
30  };
31 
32  struct NodeSpecOcl : public NodeSpec
33  {
35  //AABB boundsVisible;
36 
37  NodeSpecOcl(void) : NodeSpec(), numVisible(0) {}
38  };
39 
40  struct ObjectSplitOcl : public ObjectSplit
41  {
44  //AABB leftVisibleBounds;
45  //AABB rightVisibleBounds;
46  bool osahTested;
47  bool osahChosen;
48 
49  ObjectSplitOcl(void) : ObjectSplit(), leftVisible(0), rightVisible(0), osahTested(false), osahChosen(false) {}
50  };
51 
52  struct SpatialSplitOcl : public SpatialSplit
53  {
54  //F32 leftArea;
55  //F32 rightArea;
60  bool osahChosen;
61 
62  SpatialSplitOcl(void) : SpatialSplit(), leftNum(0), rightNum(0), leftVisible(0), rightVisible(0), osahChosen(false) {}
63  };
64 
65  struct SpatialBinOcl : public SpatialBin
66  {
69  };
70 
71 public:
72  OcclusionBVHBuilder (BVH& bvh, const BVH::BuildParams& params, const Vec3f& cameraPosition);
73  virtual ~OcclusionBVHBuilder (void);
74 
75  virtual BVHNode* run (void);
76 
77  static bool sortCompare (void* data, int idxA, int idxB);
78 
79 protected:
80  static void sortSwap (void* data, int idxA, int idxB);
81 
82  BVHNode* buildNode (const NodeSpecOcl& spec, int start, int end, int level, F32 progressStart, F32 progressEnd);
83 
84  ObjectSplitOcl findObjectSplit (const NodeSpecOcl& spec, int start, int end, F32 nodeSAH);
85  ObjectSplitOcl findObjectOccludeSplit (const NodeSpecOcl& spec, int start, int end, F32 nodeSAH);
86  void performObjectSplit (NodeSpecOcl& left, NodeSpecOcl& right, const NodeSpecOcl& spec, int start, int end, const ObjectSplitOcl& split);
87 
88  SpatialSplitOcl findSpatialSplit (const NodeSpecOcl& spec, int start, int end, F32 nodeSAH);
89  SpatialSplitOcl findSpatialOccludeSplit (const NodeSpecOcl& spec, int start, int end, F32 nodeSAH);
90  //SpatialSplit findVisibleSplit (const NodeSpecOcl& spec, int start, int end, F32 nodeSAH, int level);
91  void performSpatialOccludeSplit (NodeSpecOcl& left, NodeSpecOcl& right, int& start, int& end, const SpatialSplitOcl& split);
92 
93 private:
94  OcclusionBVHBuilder (const OcclusionBVHBuilder&); // forbidden
95  OcclusionBVHBuilder& operator= (const OcclusionBVHBuilder&); // forbidden
96 
97 protected:
98  //Array<AABB> m_rightVisibleBounds;
100  Vec3f m_cameraPos; // position of the camera
103 };
104 
105 //------------------------------------------------------------------------
106 }
Stucture holding the BVH build parameters.
Definition: BVH.hpp:109
SpatialSplitOcl findSpatialOccludeSplit(const NodeSpecOcl &spec, int start, int end, F32 nodeSAH)
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
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
OcclusionBVHBuilder(BVH &bvh, const BVH::BuildParams &params, const Vec3f &cameraPosition)
SpatialBinOcl m_bins[3][NumSpatialBins]
ObjectSplitOcl findObjectSplit(const NodeSpecOcl &spec, int start, int end, F32 nodeSAH)
Declarations for SplitBVHBuilder.
SpatialSplitOcl findSpatialSplit(const NodeSpecOcl &spec, int start, int end, F32 nodeSAH)
BVHNode * buildNode(const NodeSpecOcl &spec, int start, int end, int level, F32 progressStart, F32 progressEnd)
float F32
Definition: Defs.hpp:89
BVH acceleration structure class.
Definition: BVH.hpp:74
ObjectSplitOcl findObjectOccludeSplit(const NodeSpecOcl &spec, int start, int end, F32 nodeSAH)
static void sortSwap(void *data, int idxA, int idxB)
signed int S32
Definition: Defs.hpp:88
void performObjectSplit(NodeSpecOcl &left, NodeSpecOcl &right, const NodeSpecOcl &spec, int start, int end, const ObjectSplitOcl &split)
static bool sortCompare(void *data, int idxA, int idxB)
virtual BVHNode * run(void)
Number of spatial bins per node in each axis.
Class performing SBVH build.
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
void performSpatialOccludeSplit(NodeSpecOcl &left, NodeSpecOcl &right, int &start, int &end, const SpatialSplitOcl &split)
BVH virtual node. Parent class of both a leaf node and an inner node.
Definition: BVHNode.hpp:136