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

A compositor workspace is the main interface to render into an RT, be it a RenderWindow or an RTT (Render Texture Target). More...

#include <OgreCompositorWorkspace.h>

+ Inheritance diagram for Ogre::CompositorWorkspace:

Public Member Functions

 CompositorWorkspace (IdType id, const CompositorWorkspaceDef *definition, const CompositorChannelVec &externalRenderTargets, SceneManager *sceneManager, Camera *defaultCam, RenderSystem *renderSys, bool bEnabled, uint8 executionMask, uint8 viewportModifierMask, const Vector4 &vpOffsetScale, const UavBufferPackedVec *uavBuffers, const ResourceLayoutMap *initialLayouts, const ResourceAccessMap *initialUavAccess)
 
virtual ~CompositorWorkspace ()
 
void _beginUpdate (bool forceBeginFrame, const bool bInsideAutoreleasePool=false)
 Call before _update unless the final render target is not a render window.
 
void _endUpdate (bool forceEndFrame, const bool bInsideAutoreleasePool=false)
 Call after _update unless the final render target is not a render window.
 
void _notifyBarriersDirty (void)
 
void _swapFinalTarget (vector< RenderTarget * >::type &swappedTargets)
 In the case of RenderWindows, swaps/copies/flips the front with the back buffer.
 
void _update (const bool bInsideAutoreleasePool=false)
 Updates the workspace's nodes.
 
void _validateFinalTarget (void)
 For compatibility with D3D9, forces a device lost check on the RenderWindow, so that BeginScene doesn't fail.
 
CamerafindCamera (IdString cameraName) const
 Finds a camera in the scene manager we have.
 
CompositorNodefindNode (IdString aliasName, bool includeShadowNodes=false) const
 Finds a node instance with the given aliased name.
 
CompositorNodefindNodeNoThrow (IdString aliasName, bool includeShadowNodes=false) const
 
CompositorShadowNodefindOrCreateShadowNode (IdString nodeDefName, bool &bCreated)
 Finds a shadow node given it's definition name.
 
CompositorShadowNodefindShadowNode (IdString nodeDefName) const
 Finds a shadow node instance with a given name.
 
bool getAmalgamatedProfiling (void) const
 
CompositorManager2getCompositorManager ()
 Gets the compositor manager (non const)
 
const CompositorManager2getCompositorManager () const
 Gets the compositor manager (const version)
 
CameragetDefaultCamera () const
 Gets the default camera passed through mDefaultViewport.
 
const CompositorWorkspaceDefgetDefinition (void)
 
bool getEnabled () const
 
uint8 getExecutionMask (void) const
 
const CompositorChannelVecgetExternalRenderTargets (void) const
 Usually by convention the RenderTarget[0] is the one we're rendering to. May be empty.
 
RenderTargetgetFinalTarget (void) const
 Returns the RenderTarget we're rendering to.
 
size_t getFrameCount (void) const
 
const CompositorNamedBufferVecgetGlobalBuffers (void) const
 
const CompositorChannelgetGlobalTexture (IdString name) const
 
IdType getId () const
 Get the unique id of this object.
 
CompositorWorkspaceListenergetListener (void) const
 
const CompositorNodeVecgetNodeSequence (void) const
 
const ResourceLayoutMapgetResourcesLayout (void) const
 
SceneManagergetSceneManager () const
 
const ResourceAccessMapgetUavsAccess (void) const
 
const Vector4getViewportModifier (void) const
 
uint8 getViewportModifierMask (void) const
 
bool isValid (void) const
 Only valid workspaces can update without crashing.
 
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
 
bool operator() (const IdObject &left, const IdObject &right)
 
bool operator() (const IdObject *left, const IdObject *right)
 
void reconnectAllNodes (void)
 Reconnects all nodes.
 
void recreateAllNodes (void)
 Destroys and recreates all nodes.
 
void resetAllNumPassesLeft (void)
 Resets the number of passes left for every pass (.
 
void setAmalgamatedProfiling (bool bEnabled)
 When building with OGRE_PROFILING enabled, setting this option to true will cause the profiler to collapse all per-pass profiling information into one group.
 
void setEnabled (bool bEnabled)
 
void setListener (CompositorWorkspaceListener *listener)
 

Detailed Description

A compositor workspace is the main interface to render into an RT, be it a RenderWindow or an RTT (Render Texture Target).

Whereas Ogre 1.x needed you to set a Viewport in order to render to an RTT or RW and then call renderTarget->update, now you need to set a workspace definition instead and call workspace->_update().

Compositors are not just a "fancy effects" system anymore, they tell Ogre how you want to render the scene. You can't render to an RT without setting a compositor!
A workspace may be instantiated multiple times for different RTs, or using different cameras (i.e. multiple monitors, stereo 3D, etc), while they all will share the same definition. A workspace definition (
See also
CompositorWorkspaceDef) contains all the information needed by this CompositorWorkspace to instantiate and know which nodes to create and how to connect them. @See CompositorNodeDef A workspace may define global textures that are visible to all of its Node instances.
If you want to have (e.g.) two monitors rendering the same but with different compositor effects, you will also have to create two different definitions (CompositorWorkspaceDefs)
The intention of Ogre 2.0's compositor is to ideally have one Workspace per monitor (or per eye) while handling all RTTs inside that workspace with compositor nodes, local and global textures (including manually updated stuff like procedural textures, terrain's auto generated normal maps, etc); but it is also possible to do things the 1.x way: use additional Workspaces for manually rendering and controlling RTTs.
Users with basic needs (no advanced effects) can
See also
CompositorManager2::createBasicWorkspaceDef for quickly having a basic definition set for them.
For more information about Compositors, consult the Ogre 2.0 Porting Manual in the Docs folder.
Author
Matias N. Goldberg
Version
1.1

Constructor & Destructor Documentation

◆ CompositorWorkspace()

Ogre::CompositorWorkspace::CompositorWorkspace ( IdType  id,
const CompositorWorkspaceDef definition,
const CompositorChannelVec externalRenderTargets,
SceneManager sceneManager,
Camera defaultCam,
RenderSystem renderSys,
bool  bEnabled,
uint8  executionMask,
uint8  viewportModifierMask,
const Vector4 vpOffsetScale,
const UavBufferPackedVec uavBuffers,
const ResourceLayoutMap initialLayouts,
const ResourceAccessMap initialUavAccess 
)

◆ ~CompositorWorkspace()

virtual Ogre::CompositorWorkspace::~CompositorWorkspace ( )
virtual

Member Function Documentation

◆ _beginUpdate()

void Ogre::CompositorWorkspace::_beginUpdate ( bool  forceBeginFrame,
const bool  bInsideAutoreleasePool = false 
)

Call before _update unless the final render target is not a render window.

Parameters
forceBeginFrameForces a beginFrame call to the D3D9 API, even if the final render target is not a RenderWindow (not recommended). To avoid forcing extra begin/end frame pairs, update your manual workspaces inside @CompositorWorkspaceListener::workspacePreUpdate (performance optimization)
bInsideAutoreleasePoolIf manually updating the workspace, leave this to default.

Relevant only in Metal: If we're not inside an autorelease pool, we automatically wrap the call into one. Otherwise we will leak

◆ _endUpdate()

void Ogre::CompositorWorkspace::_endUpdate ( bool  forceEndFrame,
const bool  bInsideAutoreleasePool = false 
)

Call after _update unless the final render target is not a render window.

Parameters
forceEndFrame@See _beginUpdate !!!WARNING!!! Forcing an end frame can cause API issues w/ D3D9 if Ogre had already issued a begin frame automatically (i.e. if you're calling from inside a RenderTarget or CompositorWorkspace listener). These API issues may not manifest on all HW/Driver combinations, making it hard to detect (if you're on D3D, use the Debug Runtimes)
bInsideAutoreleasePoolIf manually updating the workspace, leave this to default.

Relevant only in Metal: If we're not inside an autorelease pool, we automatically wrap the call into one. Otherwise we will leak

◆ _notifyBarriersDirty()

void Ogre::CompositorWorkspace::_notifyBarriersDirty ( void  )
inline

◆ _swapFinalTarget()

void Ogre::CompositorWorkspace::_swapFinalTarget ( vector< RenderTarget * >::type &  swappedTargets)

In the case of RenderWindows, swaps/copies/flips the front with the back buffer.

In the case of RenderTextures, resolves FSAA (unless it's tagged as explicit resolve, or its contents haven't changed since the last resolve)

Remarks
Call this after _endUpdate

◆ _update()

void Ogre::CompositorWorkspace::_update ( const bool  bInsideAutoreleasePool = false)

Updates the workspace's nodes.

Remarks
If you're calling this manually, it may be possible you first need to call RenderSystem::_beginFrameOnce if it wasn't called by OGRE already. You might also need to enclose the _update calls with _beginUpdate( true ) and _endUpdate( true ) if you're having issues.
Parameters
bInsideAutoreleasePoolIf manually updating the workspace, leave this to default.

Relevant only in Metal: If we're not inside an autorelease pool, we automatically wrap the call into one. Otherwise we will leak

◆ _validateFinalTarget()

void Ogre::CompositorWorkspace::_validateFinalTarget ( void  )

For compatibility with D3D9, forces a device lost check on the RenderWindow, so that BeginScene doesn't fail.

◆ findCamera()

Camera * Ogre::CompositorWorkspace::findCamera ( IdString  cameraName) const

Finds a camera in the scene manager we have.

◆ findNode()

CompositorNode * Ogre::CompositorWorkspace::findNode ( IdString  aliasName,
bool  includeShadowNodes = false 
) const

Finds a node instance with the given aliased name.

Remarks
Linear search O(N)
Parameters
aliasNameName of the node instance (they're unique)
includeShadowNodesWhen true, also looks for ShadowNodes with that name, if the instance doesn't exists, it will not be created (default: false). @See findShadowNode When a Node has the same name of a Shadow Node, the Node takes precedence.
Returns
Regular version: Valid pointer. Throws exception if not found. NoThrow version: Null if not found. Valid pointer otherwise.

◆ findNodeNoThrow()

CompositorNode * Ogre::CompositorWorkspace::findNodeNoThrow ( IdString  aliasName,
bool  includeShadowNodes = false 
) const

◆ findOrCreateShadowNode()

CompositorShadowNode * Ogre::CompositorWorkspace::findOrCreateShadowNode ( IdString  nodeDefName,
bool bCreated 
)

Finds a shadow node given it's definition name.

If it doesn't exist, creates one. Note that unlike nodes, there can only be one ShadowNode instance per definition (in the same workspace)

Remarks
Performs a linear search O(N). There aren't many ShadowNodes active in a workspace to justify a better container (plus we mostly iterate through it).
Throws if the shadow definition doesn't exist.
Parameters
nodeDefNameName of the definition.
bCreated[out] Set to true if we had to create a new shadow node (it didn't exist)
Returns
ShadowNode pointer

◆ findShadowNode()

CompositorShadowNode * Ogre::CompositorWorkspace::findShadowNode ( IdString  nodeDefName) const

Finds a shadow node instance with a given name.

Note that unlike nodes, there can only be one ShadowNode instance per definition (in the same workspace)

Remarks
Performs a linear search O(N). There aren't many ShadowNodes active in a workspace to justify a better container (plus we mostly iterate through it).
Parameters
nodeDefNameName of the definition.
Returns
ShadowNode pointer. Null if not found.

◆ getAmalgamatedProfiling()

bool Ogre::CompositorWorkspace::getAmalgamatedProfiling ( void  ) const
inline

◆ getCompositorManager() [1/2]

CompositorManager2 * Ogre::CompositorWorkspace::getCompositorManager ( )

Gets the compositor manager (non const)

◆ getCompositorManager() [2/2]

const CompositorManager2 * Ogre::CompositorWorkspace::getCompositorManager ( ) const

Gets the compositor manager (const version)

◆ getDefaultCamera()

Camera * Ogre::CompositorWorkspace::getDefaultCamera ( ) const
inline

Gets the default camera passed through mDefaultViewport.

◆ getDefinition()

const CompositorWorkspaceDef * Ogre::CompositorWorkspace::getDefinition ( void  )
inline

◆ getEnabled()

bool Ogre::CompositorWorkspace::getEnabled ( ) const
inline

◆ getExecutionMask()

uint8 Ogre::CompositorWorkspace::getExecutionMask ( void  ) const
inline

◆ getExternalRenderTargets()

const CompositorChannelVec & Ogre::CompositorWorkspace::getExternalRenderTargets ( void  ) const
inline

Usually by convention the RenderTarget[0] is the one we're rendering to. May be empty.

◆ getFinalTarget()

RenderTarget * Ogre::CompositorWorkspace::getFinalTarget ( void  ) const

Returns the RenderTarget we're rendering to.

May be null.

See also
getExternalRenderTargets

◆ getFrameCount()

size_t Ogre::CompositorWorkspace::getFrameCount ( void  ) const

◆ getGlobalBuffers()

const CompositorNamedBufferVec & Ogre::CompositorWorkspace::getGlobalBuffers ( void  ) const
inline

◆ getGlobalTexture()

const CompositorChannel & Ogre::CompositorWorkspace::getGlobalTexture ( IdString  name) const

◆ getId()

IdType Ogre::IdObject::getId ( ) const
inlineinherited

Get the unique id of this object.

◆ getListener()

CompositorWorkspaceListener * Ogre::CompositorWorkspace::getListener ( void  ) const
inline

◆ getNodeSequence()

const CompositorNodeVec & Ogre::CompositorWorkspace::getNodeSequence ( void  ) const
inline

◆ getResourcesLayout()

const ResourceLayoutMap & Ogre::CompositorWorkspace::getResourcesLayout ( void  ) const
inline

◆ getSceneManager()

SceneManager * Ogre::CompositorWorkspace::getSceneManager ( ) const
inline

◆ getUavsAccess()

const ResourceAccessMap & Ogre::CompositorWorkspace::getUavsAccess ( void  ) const
inline

◆ getViewportModifier()

const Vector4 & Ogre::CompositorWorkspace::getViewportModifier ( void  ) const
inline

◆ getViewportModifierMask()

uint8 Ogre::CompositorWorkspace::getViewportModifierMask ( void  ) const
inline

◆ isValid()

bool Ogre::CompositorWorkspace::isValid ( void  ) const
inline

Only valid workspaces can update without crashing.

◆ 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

◆ operator()() [1/2]

bool Ogre::IdObject::operator() ( const IdObject left,
const IdObject right 
)
inlineinherited

◆ operator()() [2/2]

bool Ogre::IdObject::operator() ( const IdObject left,
const IdObject right 
)
inlineinherited

◆ reconnectAllNodes()

void Ogre::CompositorWorkspace::reconnectAllNodes ( void  )

Reconnects all nodes.

Use this function if you only altered the channel connections between nodes, but didn't add new ones or removed existing nodes.

Remarks
If there is a "loose node" (its inputs are not fully connected), disable it (
See also
CompositorNode::setEnabled)

◆ recreateAllNodes()

void Ogre::CompositorWorkspace::recreateAllNodes ( void  )

Destroys and recreates all nodes.

TODO: Only revalidate nodes adjacent to those that were invalidated, to avoid recreating so many D3D/GL resources (local textures) which is important for GUI editors.

◆ resetAllNumPassesLeft()

void Ogre::CompositorWorkspace::resetAllNumPassesLeft ( void  )

Resets the number of passes left for every pass (.

See also
CompositorPassDef::mNumInitialPasses) Useful when you have a few starting 'initialization' passes and you want to reset them.

◆ setAmalgamatedProfiling()

void Ogre::CompositorWorkspace::setAmalgamatedProfiling ( bool  bEnabled)
inline

When building with OGRE_PROFILING enabled, setting this option to true will cause the profiler to collapse all per-pass profiling information into one group.

This is useful if you want to know how much (e.g.) frustum culling is taking overall (all passes combined) rather than knowing how much frustum culling is taking for each pass.

Parameters
bEnabledTrue to collapse all per-pass info into a global one. Default is false.

◆ setEnabled()

void Ogre::CompositorWorkspace::setEnabled ( bool  bEnabled)
inline

◆ setListener()

void Ogre::CompositorWorkspace::setListener ( CompositorWorkspaceListener listener)
inline

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