OGRE 2.1
Object-Oriented Graphics Rendering Engine
Loading...
Searching...
No Matches
Ogre::DepthBuffer Class Referenceabstract

An abstract class that contains a depth/stencil buffer. More...

#include <OgreDepthBuffer.h>

+ Inheritance diagram for Ogre::DepthBuffer:

Public Types

enum  PoolId {
  POOL_NO_DEPTH = 0 , POOL_MANUAL_USAGE = 0 , POOL_DEFAULT = 1 , POOL_NON_SHAREABLE = 65534 ,
  POOL_INVALID = 65535
}
 

Public Member Functions

 DepthBuffer (uint16 poolId, uint16 bitDepth, uint32 width, uint32 height, uint32 fsaa, const String &fsaaHint, PixelFormat pixelFormat, bool isDepthTexture, bool manual, RenderSystem *renderSystem)
 
virtual ~DepthBuffer ()
 
virtual void _notifyRenderTargetAttached (RenderTarget *renderTarget)
 Called when a RenderTarget is attaches this DepthBuffer.
 
virtual void _notifyRenderTargetDetached (RenderTarget *renderTarget)
 Called when a RenderTarget is detaches from this DepthBuffer.
 
void _setPoolId (uint16 poolId)
 Sets the pool id in which this DepthBuffer lives.
 
bool copyTo (DepthBuffer *destination)
 Copies the contents of the DepthBuffer to the destination.
 
virtual uint16 getBitDepth () const
 
PixelFormat getFormat (void) const
 
virtual uint32 getFsaa () const
 
virtual const StringgetFsaaHint () const
 
virtual uint32 getHeight () const
 
virtual uint16 getPoolId () const
 Gets the pool id in which this DepthBuffer lives.
 
virtual uint32 getWidth () const
 
virtual bool isCompatible (RenderTarget *renderTarget, bool exactFormatMatch) const
 Returns whether the specified RenderTarget is compatible with this DepthBuffer That is, this DepthBuffer can be attached to that RenderTarget.
 
bool isDepthTexture (void) const
 
bool isManual () const
 Manual DepthBuffers are cleared in RenderSystem's destructor.
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete (void *ptr, void *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info
 
voidoperator new (size_t sz, void *ptr)
 placement operator new
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info
 

Static Public Attributes

static PixelFormat DefaultDepthBufferFormat
 

Detailed Description

An abstract class that contains a depth/stencil buffer.

Depth Buffers can be attached to render targets. Note we handle Depth & Stencil together. DepthBuffer sharing is handled automatically for you. However, there are times where you want to specifically control depth buffers to achieve certain effects or increase performance. You can control this by hinting Ogre with POOL IDs. Created depth buffers can live in different pools, or all together in the same one. Usually, a depth buffer can only be attached to a RenderTarget if it's dimensions are bigger and have the same bit depth and same multisample settings. Depth Buffers are created automatically for new RTs when needed, and stored in the pool where the RenderTarget should have drawn from. By default, all RTs have the Id POOL_DEFAULT, which means all depth buffers are stored by default in that pool. By choosing a different Pool Id for a specific RenderTarget, that RT will only retrieve depth buffers from that pool, therefore not conflicting with sharing depth buffers with other RTs (such as shadows maps). Setting an RT to POOL_MANUAL_USAGE means Ogre won't manage the DepthBuffer for you (not recommended) RTs with POOL_NO_DEPTH are very useful when you don't want to create a DepthBuffer for it. You can still manually attach a depth buffer though as internally POOL_NO_DEPTH & POOL_MANUAL_USAGE are handled in the same way.

Behavior is consistent across all render systems, if, and only if, the same RSC flags are set RSC flags that affect this class are: RSC_RTT_SEPARATE_DEPTHBUFFER: The RTT can create a custom depth buffer different from the main depth buffer. This means, an RTT is able to not share it's depth buffer with the main window if it wants to. RSC_RTT_MAIN_DEPTHBUFFER_ATTACHABLE: When RSC_RTT_SEPARATE_DEPTHBUFFER is set, some APIs (ie. OpenGL w/ FBO) don't allow using the main depth buffer for offscreen RTTs. When this flag is set, the depth buffer can be shared between the main window and an RTT. RSC_RTT_DEPTHBUFFER_RESOLUTION_LESSEQUAL: When this flag isn't set, the depth buffer can only be shared across RTTs who have the EXACT same resolution. When it's set, it can be shared with RTTs as long as they have a resolution less or equal than the depth buffer's.

Remarks
Design discussion http://www.ogre3d.org/forums/viewtopic.php?f=4&t=53534&p=365582
Author
Matias N. Goldberg
Version
1.0

Member Enumeration Documentation

◆ PoolId

Enumerator
POOL_NO_DEPTH 
POOL_MANUAL_USAGE 
POOL_DEFAULT 
POOL_NON_SHAREABLE 
POOL_INVALID 

Constructor & Destructor Documentation

◆ DepthBuffer()

Ogre::DepthBuffer::DepthBuffer ( uint16  poolId,
uint16  bitDepth,
uint32  width,
uint32  height,
uint32  fsaa,
const String fsaaHint,
PixelFormat  pixelFormat,
bool  isDepthTexture,
bool  manual,
RenderSystem renderSystem 
)

◆ ~DepthBuffer()

virtual Ogre::DepthBuffer::~DepthBuffer ( )
virtual

Member Function Documentation

◆ _notifyRenderTargetAttached()

virtual void Ogre::DepthBuffer::_notifyRenderTargetAttached ( RenderTarget renderTarget)
virtual

Called when a RenderTarget is attaches this DepthBuffer.

Remarks
This function doesn't actually attach. It merely informs the DepthBuffer which RenderTarget did attach. The real attachment happens in RenderTarget::attachDepthBuffer()
Parameters
renderTargetThe RenderTarget that has just been attached

◆ _notifyRenderTargetDetached()

virtual void Ogre::DepthBuffer::_notifyRenderTargetDetached ( RenderTarget renderTarget)
virtual

Called when a RenderTarget is detaches from this DepthBuffer.

Remarks
Same as DepthBuffer::_notifyRenderTargetAttached()
Parameters
renderTargetThe RenderTarget that has just been detached

◆ _setPoolId()

void Ogre::DepthBuffer::_setPoolId ( uint16  poolId)

Sets the pool id in which this DepthBuffer lives.

Note this will detach any render target from this depth buffer

◆ copyTo()

bool Ogre::DepthBuffer::copyTo ( DepthBuffer destination)

Copies the contents of the DepthBuffer to the destination.

Useful when you want to bind a DepthBuffer for sampling as a texture, but later resume rendering with this depth buffer (binding a DepthBuffer as a texture forces it to be decompressed and disables other optimization algorithms on a lot of Hardware. GCN Tahiti aka AMD Radeon R9 280 is no longer affected by this issue)

Remarks
The function will throw if the depth buffers are incompatible (e.g. different resolution, different format, different MSAA settings)
Parameters
destinationDepthBuffer to copy to.
Returns
False if failed to copy for hardware reasons (DX10 does not allow copying MSAA depth buffer; DX10.1 does)

◆ getBitDepth()

virtual uint16 Ogre::DepthBuffer::getBitDepth ( ) const
virtual

◆ getFormat()

PixelFormat Ogre::DepthBuffer::getFormat ( void  ) const

◆ getFsaa()

virtual uint32 Ogre::DepthBuffer::getFsaa ( ) const
virtual

◆ getFsaaHint()

virtual const String & Ogre::DepthBuffer::getFsaaHint ( ) const
virtual

◆ getHeight()

virtual uint32 Ogre::DepthBuffer::getHeight ( ) const
virtual

◆ getPoolId()

virtual uint16 Ogre::DepthBuffer::getPoolId ( ) const
virtual

Gets the pool id in which this DepthBuffer lives.

◆ getWidth()

virtual uint32 Ogre::DepthBuffer::getWidth ( ) const
virtual

◆ isCompatible()

virtual bool Ogre::DepthBuffer::isCompatible ( RenderTarget renderTarget,
bool  exactFormatMatch 
) const
virtual

Returns whether the specified RenderTarget is compatible with this DepthBuffer That is, this DepthBuffer can be attached to that RenderTarget.

Remarks
Most APIs impose the following restrictions: Width & height must be equal or higher than the render target's They must be of the same bit depth. They need to have the same FSAA setting
Parameters
renderTargetThe render target to test against
exactFormatMatchTrue if looking for the exact format according to the RT's preferred format. False if the RT's preferred format should be ignored.

Reimplemented in Ogre::D3D11DepthBuffer, Ogre::GL3PlusDepthBuffer, Ogre::GLES2DepthBuffer, and Ogre::MetalDepthBuffer.

◆ isDepthTexture()

bool Ogre::DepthBuffer::isDepthTexture ( void  ) const

◆ isManual()

bool Ogre::DepthBuffer::isManual ( ) const

Manual DepthBuffers are cleared in RenderSystem's destructor.

Non-manual ones are released with it's render target (aka, a backbuffer or similar)

◆ operator delete() [1/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void ptr)
inlineinherited

◆ operator delete() [2/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void ptr,
const char ,
int  ,
const char  
)
inlineinherited

◆ operator delete() [3/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void ptr,
void  
)
inlineinherited

◆ operator delete[]() [1/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void ptr)
inlineinherited

◆ operator delete[]() [2/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void ptr,
const char ,
int  ,
const char  
)
inlineinherited

◆ operator new() [1/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

◆ operator new() [2/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char file,
int  line,
const char func 
)
inlineinherited

operator new, with debug line info

◆ operator new() [3/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void ptr 
)
inlineinherited

placement operator new

◆ operator new[]() [1/2]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inlineinherited

◆ operator new[]() [2/2]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char file,
int  line,
const char func 
)
inlineinherited

array operator new, with debug line info

Member Data Documentation

◆ DefaultDepthBufferFormat

PixelFormat Ogre::DepthBuffer::DefaultDepthBufferFormat
static

The documentation for this class was generated from the following file: