Inherited by MaskedOcclusionCullingPrivate.
Classes | |
struct | OcclusionCullingStatistics |
struct | ScissorRect |
struct | TriList |
struct | VertexLayout |
Public Member Functions | |
virtual void | SetResolution (unsigned int width, unsigned int height)=0 |
Sets the resolution of the hierarchical depth buffer. This function will re-allocate the current depth buffer (if present). The contents of the buffer is undefined until ClearBuffer() is called. | |
virtual void | GetResolution (unsigned int &width, unsigned int &height) const =0 |
Gets the resolution of the hierarchical depth buffer. | |
virtual void | ComputeBinWidthHeight (unsigned int nBinsW, unsigned int nBinsH, unsigned int &outBinWidth, unsigned int &outBinHeight)=0 |
Returns the tile size for the current implementation. | |
virtual void | SetNearClipPlane (float nearDist)=0 |
Sets the distance for the near clipping plane. Default is nearDist = 0. | |
virtual float | GetNearClipPlane () const =0 |
Gets the distance for the near clipping plane. | |
virtual void | ClearBuffer ()=0 |
Clears the hierarchical depth buffer. | |
virtual void | MergeBuffer (MaskedOcclusionCulling *BufferB)=0 |
Merge a second hierarchical depth buffer into the main buffer. | |
virtual CullingResult | RenderTriangles (const float *inVtx, const unsigned int *inTris, int nTris, const float *modelToClipMatrix=nullptr, BackfaceWinding bfWinding=BACKFACE_CW, ClipPlanes clipPlaneMask=CLIP_PLANE_ALL, const VertexLayout &vtxLayout=VertexLayout(16, 4, 12))=0 |
Renders a mesh of occluder triangles and updates the hierarchical z buffer with conservative depth values. | |
virtual CullingResult | TestRect (float xmin, float ymin, float xmax, float ymax, float wmin) const =0 |
Occlusion query for a rectangle with a given depth. The rectangle is given in normalized device coordinates where (x,y) coordinates between [-1,1] map to the visible screen area. The query uses a GREATER_EQUAL (reversed) depth test meaning that depth values equal to the contents of the depth buffer are counted as visible. | |
virtual CullingResult | TestTriangles (const float *inVtx, const unsigned int *inTris, int nTris, const float *modelToClipMatrix=nullptr, BackfaceWinding bfWinding=BACKFACE_CW, ClipPlanes clipPlaneMask=CLIP_PLANE_ALL, const VertexLayout &vtxLayout=VertexLayout(16, 4, 12))=0 |
This function is similar to RenderTriangles(), but performs an occlusion query instead and does not update the hierarchical z buffer. The query uses a GREATER_EQUAL (reversed) depth test meaning that depth values equal to the contents of the depth buffer are counted as visible. | |
virtual void | BinTriangles (const float *inVtx, const unsigned int *inTris, int nTris, TriList *triLists, unsigned int nBinsW, unsigned int nBinsH, const float *modelToClipMatrix=nullptr, BackfaceWinding bfWinding=BACKFACE_CW, ClipPlanes clipPlaneMask=CLIP_PLANE_ALL, const VertexLayout &vtxLayout=VertexLayout(16, 4, 12))=0 |
Perform input assembly, clipping , projection, triangle setup, and write triangles to the screen space bins they overlap. This function can be used to distribute work for threading (See the CullingThreadpool class for an example) | |
virtual void | RenderTrilist (const TriList &triList, const ScissorRect *scissor)=0 |
Renders all occluder triangles in a trilist. This function can be used in combination with BinTriangles() to create a threded (binning) rasterizer. The bins can be processed independently by different threads without risking writing to overlapping memory regions. | |
virtual void | ComputePixelDepthBuffer (float *depthData, bool flipY)=0 |
Creates a per-pixel depth buffer from the hierarchical z buffer representation. Intended for visualizing the hierarchical depth buffer for debugging. The buffer is written in scanline order, from the top to bottom (D3D) or bottom to top (OGL) of the surface. See the USE_D3D define. | |
virtual OcclusionCullingStatistics | GetStatistics ()=0 |
Fetch occlusion culling statistics, returns zeroes if ENABLE_STATS define is not defined. The statistics can be used for profiling or debugging. | |
virtual Implementation | GetImplementation ()=0 |
Returns the implementation (CPU instruction set) version of this object. | |
void | GetAllocFreeCallback (pfnAlignedAlloc &allocCallback, pfnAlignedFree &freeCallback) |
Get used memory alloc/free callbacks. | |
Static Public Member Functions | |
static MaskedOcclusionCulling * | Create (Implementation RequestedSIMD=AVX512) |
Creates a new object with default state, no z buffer attached/allocated. | |
static MaskedOcclusionCulling * | Create (Implementation RequestedSIMD, pfnAlignedAlloc alignedAlloc, pfnAlignedFree alignedFree) |
Creates a new object with default state, no z buffer attached/allocated. | |
static void | Destroy (MaskedOcclusionCulling *moc) |
Destroys an object and frees the z buffer memory. Note that you cannot use the delete operator, and should rather use this function to free up memory. | |
static void | TransformVertices (const float *mtx, const float *inVtx, float *xfVtx, unsigned int nVtx, const VertexLayout &vtxLayout=VertexLayout(12, 4, 8)) |
Utility function for transforming vertices and outputting them to an (x,y,z,w) format suitable for the occluder rasterization and occludee testing functions. | |
Protected Attributes | |
pfnAlignedAlloc | mAlignedAllocCallback |
pfnAlignedFree | mAlignedFreeCallback |
OcclusionCullingStatistics | mStats |
|
pure virtual |
Perform input assembly, clipping , projection, triangle setup, and write triangles to the screen space bins they overlap. This function can be used to distribute work for threading (See the CullingThreadpool class for an example)
inVtx | Pointer to an array of input vertices, should point to the x component of the first vertex. The input vertices are given as (x,y,w) coordinates in clip space. The memory layout can be changed using vtxLayout. |
inTris | Pointer to an array of vertex indices. Each triangle is created from three indices consecutively fetched from the array. |
nTris | The number of triangles to render (inTris must contain atleast 3*nTris entries) |
triLists | Pointer to an array of TriList objects with one TriList object per bin. If a triangle overlaps a bin, it will be written to the corresponding trilist. Note that this method appends the triangles to the current list, to start writing from the beginning of the list, set triList.mTriIdx = 0 |
nBinsW | Number of vertical bins, the screen is divided into nBinsW x nBinsH rectangular bins. |
nBinsH | Number of horizontal bins, the screen is divided into nBinsW x nBinsH rectangular bins. |
modelToClipMatrix | all vertices will be transformed by this matrix before performing projection. If nullptr is passed the transform step will be skipped |
clipPlaneMask | A mask indicating which clip planes should be considered by the triangle clipper. Can be used as an optimization if your application can determine (for example during culling) that a group of triangles does not intersect a certain frustum plane. However, setting an incorrect mask may cause out of bounds memory accesses. |
vtxLayout | A struct specifying the vertex layout (see struct for detailed description). For best performance, it is advisable to store position data as compactly in memory as possible. |
bfWinding | Sets triangle winding order to consider backfacing, must be one one of (BACKFACE_NONE, BACKFACE_CW and BACKFACE_CCW). Back-facing triangles are culled and will not be binned / rasterized. You may use BACKFACE_NONE to disable culling for double sided geometry |
Implemented in MaskedOcclusionCullingPrivate, and MaskedOcclusionCullingPrivate.
|
pure virtual |
Clears the hierarchical depth buffer.
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Returns the tile size for the current implementation.
nBinsW | Number of vertical bins, the screen is divided into nBinsW x nBinsH rectangular bins. |
nBinsH | Number of horizontal bins, the screen is divided into nBinsW x nBinsH rectangular bins. |
outBinWidth | Output: The width of the single bin in pixels (except for the rightmost bin width, which is extended to resolution width) |
outBinHeight | Output: The height of the single bin in pixels (except for the bottommost bin height, which is extended to resolution height) |
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Creates a per-pixel depth buffer from the hierarchical z buffer representation. Intended for visualizing the hierarchical depth buffer for debugging. The buffer is written in scanline order, from the top to bottom (D3D) or bottom to top (OGL) of the surface. See the USE_D3D define.
depthData | Pointer to memory where the per-pixel depth data is written. Must hold storage for atleast width*height elements as set by setResolution. |
Implemented in MaskedOcclusionCullingPrivate.
|
static |
Creates a new object with default state, no z buffer attached/allocated.
alignedAlloc | Pointer to a callback function used when allocating memory |
alignedFree | Pointer to a callback function used when freeing memory |
|
pure virtual |
Returns the implementation (CPU instruction set) version of this object.
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Gets the distance for the near clipping plane.
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Gets the resolution of the hierarchical depth buffer.
witdh | Output: The width of the buffer in pixels |
height | Output: The height of the buffer in pixels |
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Fetch occlusion culling statistics, returns zeroes if ENABLE_STATS define is not defined. The statistics can be used for profiling or debugging.
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Merge a second hierarchical depth buffer into the main buffer.
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Renders a mesh of occluder triangles and updates the hierarchical z buffer with conservative depth values.
This function is optimized for vertex layouts with stride 16 and y and w offsets of 4 and 12 bytes, respectively.
inVtx | Pointer to an array of input vertices, should point to the x component of the first vertex. The input vertices are given as (x,y,w) coordinates in clip space. The memory layout can be changed using vtxLayout. |
inTris | Pointer to an array of vertex indices. Each triangle is created from three indices consecutively fetched from the array. |
nTris | The number of triangles to render (inTris must contain atleast 3*nTris entries) |
modelToClipMatrix | all vertices will be transformed by this matrix before performing projection. If nullptr is passed the transform step will be skipped |
bfWinding | Sets triangle winding order to consider backfacing, must be one one of (BACKFACE_NONE, BACKFACE_CW and BACKFACE_CCW). Back-facing triangles are culled and will not be rasterized. You may use BACKFACE_NONE to disable culling for double sided geometry |
clipPlaneMask | A mask indicating which clip planes should be considered by the triangle clipper. Can be used as an optimization if your application can determine (for example during culling) that a group of triangles does not intersect a certain frustum plane. However, setting an incorrect mask may cause out of bounds memory accesses. |
vtxLayout | A struct specifying the vertex layout (see struct for detailed description). For best performance, it is advisable to store position data as compactly in memory as possible. |
Implemented in MaskedOcclusionCullingPrivate, and MaskedOcclusionCullingPrivate.
|
pure virtual |
Renders all occluder triangles in a trilist. This function can be used in combination with BinTriangles() to create a threded (binning) rasterizer. The bins can be processed independently by different threads without risking writing to overlapping memory regions.
triLists | A triangle list, filled using the BinTriangles() function that is to be rendered. |
scissor | A scissor box limiting the rendering region to the bin. The size of each bin must be a multiple of 32x8 pixels due to implementation constraints. For a render target with (width, height) resolution and (nBinsW, nBinsH) bins, the size of a bin is: binWidth = (width / nBinsW) - (width / nBinsW) % 32; binHeight = (height / nBinsH) - (height / nBinsH) % 8; The last row and column of tiles have a different size: lastColBinWidth = width - (nBinsW-1)*binWidth; lastRowBinHeight = height - (nBinsH-1)*binHeight; |
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Sets the distance for the near clipping plane. Default is nearDist = 0.
nearDist | The distance to the near clipping plane, given as clip space w |
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Sets the resolution of the hierarchical depth buffer. This function will re-allocate the current depth buffer (if present). The contents of the buffer is undefined until ClearBuffer() is called.
witdh | The width of the buffer in pixels, must be a multiple of 8 |
height | The height of the buffer in pixels, must be a multiple of 4 |
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
Occlusion query for a rectangle with a given depth. The rectangle is given in normalized device coordinates where (x,y) coordinates between [-1,1] map to the visible screen area. The query uses a GREATER_EQUAL (reversed) depth test meaning that depth values equal to the contents of the depth buffer are counted as visible.
xmin | NDC coordinate of the left side of the rectangle. |
ymin | NDC coordinate of the bottom side of the rectangle. |
xmax | NDC coordinate of the right side of the rectangle. |
ymax | NDC coordinate of the top side of the rectangle. |
ymax | NDC coordinate of the top side of the rectangle. |
wmin | Clip space W coordinate for the rectangle. |
Implemented in MaskedOcclusionCullingPrivate.
|
pure virtual |
This function is similar to RenderTriangles(), but performs an occlusion query instead and does not update the hierarchical z buffer. The query uses a GREATER_EQUAL (reversed) depth test meaning that depth values equal to the contents of the depth buffer are counted as visible.
This function is optimized for vertex layouts with stride 16 and y and w offsets of 4 and 12 bytes, respectively.
inVtx | Pointer to an array of input vertices, should point to the x component of the first vertex. The input vertices are given as (x,y,w) coordinates in clip space. The memory layout can be changed using vtxLayout. |
inTris | Pointer to an array of triangle indices. Each triangle is created from three indices consecutively fetched from the array. |
nTris | The number of triangles to render (inTris must contain atleast 3*nTris entries) |
modelToClipMatrix | all vertices will be transformed by this matrix before performing projection. If nullptr is passed the transform step will be skipped |
bfWinding | Sets triangle winding order to consider backfacing, must be one one of (BACKFACE_NONE, BACKFACE_CW and BACKFACE_CCW). Back-facing triangles are culled and will not be occlusion tested. You may use BACKFACE_NONE to disable culling for double sided geometry |
clipPlaneMask | A mask indicating which clip planes should be considered by the triangle clipper. Can be used as an optimization if your application can determine (for example during culling) that a group of triangles does not intersect a certain frustum plane. However, setting an incorrect mask may cause out of bounds memory accesses. |
vtxLayout | A struct specifying the vertex layout (see struct for detailed description). For best performance, it is advisable to store position data as compactly in memory as possible. |
Implemented in MaskedOcclusionCullingPrivate.
|
static |
Utility function for transforming vertices and outputting them to an (x,y,z,w) format suitable for the occluder rasterization and occludee testing functions.
mtx | Pointer to matrix data. The matrix should column major for post multiplication (OGL) and row major for pre-multiplication (DX). This is consistent with OpenGL / DirectX behavior. |
inVtx | Pointer to an array of input vertices. The input vertices are given as (x,y,z) coordinates. The memory layout can be changed using vtxLayout. |
xfVtx | Pointer to an array to store transformed vertices. The transformed vertices are always stored as array of structs (AoS) (x,y,z,w) packed in memory. |
nVtx | Number of vertices to transform. |
vtxLayout | A struct specifying the vertex layout (see struct for detailed description). For best performance, it is advisable to store position data as compactly in memory as possible. Note that for this function, the w-component is assumed to be 1.0. |