Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::gfx::ResourceManager Class Reference

A ResourceManager is an interface for getting information about a Renderer's internal resources. More...

#include "resourcemanager.h"

Inheritance diagram for ion::gfx::ResourceManager:
Collaboration diagram for ion::gfx::ResourceManager:

Classes

struct  ArrayResourceInfo
 The below info types contain additional informative fields about resources. More...
 
struct  BufferTargetInfo
 
struct  DataRequest
 Wrapper struct for data requests. More...
 
struct  FramebufferResourceInfo
 
struct  InfoCallback
 Callbacks called when requested resource information is available. More...
 
struct  PlatformInfo
 Struct for getting information about the local OpenGL platform. More...
 
struct  ResourceInfo
 Resource info types. More...
 
struct  ResourceRequest
 Wrapper struct for resource info requests. More...
 
struct  TextureImageInfo
 Struct containing information about a texture and its image(s). More...
 
struct  TextureResourceInfo
 

Public Types

typedef gfx::ProgramInfo
< ResourceInfo
ProgramInfo
 
typedef gfx::RenderbufferInfo
< ResourceInfo
RenderbufferInfo
 
typedef gfx::SamplerInfo
< ResourceInfo
SamplerInfo
 
typedef gfx::ShaderInfo
< ResourceInfo
ShaderInfo
 
typedef gfx::ArrayInfo
< ArrayResourceInfo
ArrayInfo
 The actual info types. More...
 
typedef gfx::BufferInfo
< BufferTargetInfo
BufferInfo
 
typedef gfx::FramebufferInfo
< FramebufferResourceInfo
FramebufferInfo
 
typedef gfx::TextureInfo
< TextureResourceInfo
TextureInfo
 

Public Member Functions

const GraphicsManagerPtrGetGraphicsManager () const
 Functions. More...
 
template<typename HolderType , typename InfoType >
void RequestResourceInfo (const typename base::ReferentPtr< HolderType >::Type &holder, const typename InfoCallback< InfoType >::Type &callback)
 Requests information about a particular resource if the ReferentPtr is non-NULL. More...
 
template<typename HolderType , typename InfoType >
void RequestAllResourceInfos (const typename InfoCallback< InfoType >::Type &callback)
 Requests information about all resources of the passed type. More...
 
void RequestPlatformInfo (const InfoCallback< PlatformInfo >::Type &callback)
 Requests information about the local OpenGL platform. More...
 
void RequestTextureImage (GLuint id, const InfoCallback< TextureImageInfo >::Type &callback)
 Executes the callback passing a TextureImageInfo that contains a pointer to the texture that has the passed OpenGL ID. More...
 
template<>
void FillInfoFromOpenGL (ResourceManager::ArrayInfo *info)
 
template<>
void FillInfoFromOpenGL (ResourceManager::BufferInfo *info)
 
template<>
void FillInfoFromOpenGL (ResourceManager::FramebufferInfo *info)
 
template<>
void FillInfoFromOpenGL (ResourceManager::ProgramInfo *info)
 
template<>
void FillInfoFromOpenGL (ResourceManager::SamplerInfo *info)
 
template<>
void FillInfoFromOpenGL (ResourceManager::ShaderInfo *info)
 
template<>
void FillInfoFromOpenGL (ResourceManager::PlatformInfo *info)
 
template<>
void FillInfoFromOpenGL (ResourceManager::TextureInfo *info)
 
template<>
void FillInfoFromOpenGL (ResourceManager::TextureImageInfo *info)
 Nothing to do as the renderer has already filled the info. More...
 
const AllocatorPtr & GetAllocator () const
 Returns the Allocator that was used for the instance. More...
 
const AllocatorPtr & GetNonNullAllocator () const
 Return our allocator, or the default allocator if the instance was declared on the stack. More...
 
const AllocatorPtr & GetAllocatorForLifetime (AllocationLifetime lifetime) const
 Convenience function that returns the Allocator to use to allocate an object with a specific lifetime. More...
 
void * operator new (size_t size)
 The standard no-parameter new operator uses the default Allocator. More...
 
void * operator new (size_t size, AllocationLifetime lifetime)
 This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime. More...
 
void * operator new (size_t size, const AllocatorPtr &allocator)
 This overloaded version of the new operator takes the Allocator to use directly as a parameter. More...
 
void * operator new (size_t size, const AllocatorPtr &allocator, void *ptr)
 Special operator new for using placement new with Allocatables. More...
 
void * operator new (size_t size, void *ptr)
 The placement new operator is defined conventionally. More...
 
void operator delete (void *ptr)
 Define the delete operator to use specialized functions dealing with an Allocator. More...
 
void operator delete (void *ptr, AllocationLifetime lifetime)
 Windows requires these (or it issues C4291 warnings). More...
 
void operator delete (void *ptr, const AllocatorPtr &allocator)
 
void operator delete (void *ptr, void *ptr2)
 The placement delete operator does nothing, as usual. More...
 

Protected Member Functions

 ResourceManager (const GraphicsManagerPtr &gm)
 A valid GraphicsManagerPtr must be passed to the constructor. More...
 
 ~ResourceManager () override
 
template<typename HolderType , typename InfoType >
std::vector< ResourceRequest
< HolderType, InfoType > > * 
GetResourceRequestVector ()
 Returns a pointer to the vector of requests for the templated holder and info types. More...
 
template<typename InfoType >
std::vector< DataRequest
< InfoType > > * 
GetDataRequestVector ()
 Returns a pointer to the vector of data requests for the templated info type. More...
 
template<typename InfoType >
void FillInfoFromOpenGL (InfoType *info)
 Performs OpenGL calls to fill in info details, specialized for each type derived from ResourceInfo. More...
 

Protected Attributes

port::Mutex request_mutex_
 For locking access to request vectors. More...
 

Detailed Description

A ResourceManager is an interface for getting information about a Renderer's internal resources.

Some of the work is performed by this class, and some must be done by a subclass before it calls functions here. Subclasses should call FillInfoFromOpenGL() to finish the info filling and call the callback passed to GetInfo().

ResourceManager is somewhat of a testing and debugging class, as it obtains information about internal OpenGL state. It is useful for verifying that Renderer has created expected state objects, and for seeing if an application is wasting resources or if resources are not being destroyed as expected. The returned OpenGL object ids may also be passed to other OpenGL state debugging libraries.

Note
the resource information is returned for the current Renderer. If more than one Renderer exists, each may potentially return different information depending on which OpenGL context they are created and used in.

Definition at line 69 of file resourcemanager.h.

Member Typedef Documentation

The actual info types.

Definition at line 125 of file resourcemanager.h.

Constructor & Destructor Documentation

ion::gfx::ResourceManager::ResourceManager ( const GraphicsManagerPtr gm)
explicitprotected

A valid GraphicsManagerPtr must be passed to the constructor.

The constructor and destructor are protected since this is an abstract base class.

Definition at line 769 of file resourcemanager.cc.

ion::gfx::ResourceManager::~ResourceManager ( )
overrideprotected

Definition at line 773 of file resourcemanager.cc.

Member Function Documentation

template<typename InfoType >
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( InfoType *  info)
protected

Performs OpenGL calls to fill in info details, specialized for each type derived from ResourceInfo.

Should only be called on the same thread that the OpenGL context was created from. This function assumes that the resource being queried is currently bound in OpenGL.

template<>
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( ResourceManager::ArrayInfo info)

Definition at line 856 of file resourcemanager.cc.

template<>
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( ResourceManager::BufferInfo info)

Definition at line 861 of file resourcemanager.cc.

template<>
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( ResourceManager::FramebufferInfo info)

Definition at line 866 of file resourcemanager.cc.

template<>
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( ResourceManager::ProgramInfo info)

Definition at line 872 of file resourcemanager.cc.

template<>
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( ResourceManager::SamplerInfo info)

Definition at line 877 of file resourcemanager.cc.

template<>
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( ResourceManager::ShaderInfo info)

Definition at line 882 of file resourcemanager.cc.

template<>
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( ResourceManager::PlatformInfo info)

Definition at line 887 of file resourcemanager.cc.

template<>
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( ResourceManager::TextureInfo info)

Definition at line 892 of file resourcemanager.cc.

template<>
void ion::gfx::ResourceManager::FillInfoFromOpenGL ( ResourceManager::TextureImageInfo info)

Nothing to do as the renderer has already filled the info.

Definition at line 897 of file resourcemanager.cc.

const AllocatorPtr& ion::base::Allocatable::GetAllocator ( ) const
inlineinherited

Returns the Allocator that was used for the instance.

This will be NULL if the instance was declared on the stack or created with normal placement new.

Definition at line 68 of file allocatable.h.

References allocator_.

Referenced by ion::base::DataContainer::CreateAndCopy(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), and ion::text::DynamicFontImage::FindImageDataIndex().

const AllocatorPtr& ion::base::Allocatable::GetAllocatorForLifetime ( AllocationLifetime  lifetime) const
inlineinherited
template<typename InfoType >
std::vector<DataRequest<InfoType> >* ion::gfx::ResourceManager::GetDataRequestVector ( )
protected

Returns a pointer to the vector of data requests for the templated info type.

const GraphicsManagerPtr& ion::gfx::ResourceManager::GetGraphicsManager ( ) const
inline

Functions.

Returns the GraphicsManager used for the instance.

Definition at line 199 of file resourcemanager.h.

const AllocatorPtr& ion::base::Allocatable::GetNonNullAllocator ( ) const
inlineinherited

Return our allocator, or the default allocator if the instance was declared on the stack.

Definition at line 72 of file allocatable.h.

References allocator_, and ion::base::AllocationManager::GetNonNullAllocator().

template<typename HolderType , typename InfoType >
std::vector<ResourceRequest<HolderType, InfoType> >* ion::gfx::ResourceManager::GetResourceRequestVector ( )
protected

Returns a pointer to the vector of requests for the templated holder and info types.

void ion::base::Allocatable::operator delete ( void *  ptr)
inlineinherited

Define the delete operator to use specialized functions dealing with an Allocator.

Definition at line 109 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
AllocationLifetime  lifetime 
)
inlineinherited

Windows requires these (or it issues C4291 warnings).

Definition at line 112 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
const AllocatorPtr allocator 
)
inlineinherited

Definition at line 113 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
void *  ptr2 
)
inlineinherited

The placement delete operator does nothing, as usual.

Definition at line 118 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size)
inlineinherited

The standard no-parameter new operator uses the default Allocator.

Definition at line 84 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
AllocationLifetime  lifetime 
)
inlineinherited

This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime.

Definition at line 88 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator 
)
inlineinherited

This overloaded version of the new operator takes the Allocator to use directly as a parameter.

If the Allocator pointer is NULL, this uses the default Allocator.

Definition at line 95 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator,
void *  ptr 
)
inlineinherited

Special operator new for using placement new with Allocatables.

Definition at line 100 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
void *  ptr 
)
inlineinherited

The placement new operator is defined conventionally.

Definition at line 105 of file allocatable.h.

template<typename HolderType , typename InfoType >
void ion::gfx::ResourceManager::RequestAllResourceInfos ( const typename InfoCallback< InfoType >::Type &  callback)
inline

Requests information about all resources of the passed type.

See the comment for RequestInfoForResource() for details about the callback.

Definition at line 222 of file resourcemanager.h.

void ion::gfx::ResourceManager::RequestPlatformInfo ( const InfoCallback< PlatformInfo >::Type &  callback)

Requests information about the local OpenGL platform.

See the comment for RequestInfoForResource() for details about the callback.

Definition at line 842 of file resourcemanager.cc.

References request_mutex_.

template<typename HolderType , typename InfoType >
void ion::gfx::ResourceManager::RequestResourceInfo ( const typename base::ReferentPtr< HolderType >::Type &  holder,
const typename InfoCallback< InfoType >::Type &  callback 
)
inline

Requests information about a particular resource if the ReferentPtr is non-NULL.

The passed callback function will be called with the info about the resource, and will execute on the same thread as the Renderer that owns this ResourceManager. It will be called at the next call to Renderer::DrawScene or Renderer::ProcessResourceInfoRequests.

Definition at line 209 of file resourcemanager.h.

References ion::base::SharedPtr< T >::Get().

void ion::gfx::ResourceManager::RequestTextureImage ( GLuint  id,
const InfoCallback< TextureImageInfo >::Type &  callback 
)

Executes the callback passing a TextureImageInfo that contains a pointer to the texture that has the passed OpenGL ID.

The callback will receive a NULL TextureBasePtr if the ID is not valid. If it is valid, the images vector will contain a single Image pointer for a regular Texture and exactly 6 Image pointers for a CubeMapTexture. Any of the Image pointers may be NULL. See above comments for when the callback will be executed.

Definition at line 849 of file resourcemanager.cc.

Member Data Documentation

port::Mutex ion::gfx::ResourceManager::request_mutex_
protected

For locking access to request vectors.

Definition at line 291 of file resourcemanager.h.

Referenced by RequestPlatformInfo().


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