OGRE-Next  3.0.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::DefaultTextureGpuManagerListener Class Reference

This is a Default implementation of TextureGpuManagerListener based on heuristics. More...

#include <OgreTextureGpuManagerListener.h>

+ Inheritance diagram for Ogre::DefaultTextureGpuManagerListener:

Public Member Functions

 DefaultTextureGpuManagerListener ()
 
uint32 getFiltersFor (const String &name, const String &aliasName, uint32 filters) const override
 getFiltersFor Gets a chance to alter the filters needed for the given texture to load More...
 
size_t getNumSlicesFor (TextureGpu *texture, TextureGpuManager *textureManager) override
 Ogre normally puts Textures into pools (a Type2DArray texture) for efficient rendering Note that only textures of the same resolution and format can be put together in the same pool. More...
 
void notifyTextureChanged (TextureGpu *texture, TextureGpuListener::Reason reason, void *extraData) override
 Called when a TextureGpu changed in a way that affects how it is displayed: More...
 
- Public Member Functions inherited from Ogre::TextureGpuManagerListener
 ~TextureGpuManagerListener () override
 
- Public Member Functions inherited from Ogre::TextureGpuListener
virtual ~TextureGpuListener ()
 
virtual bool shouldStayLoaded (TextureGpu *texture)
 Return true if this TextureGpu should likely stay loaded or else graphical changes could occur. More...
 

Public Attributes

uint32 mMaxResolutionToApplyMinSlices [4]
 If texture resolution is <= maxResolutionToApplyMinSlices[i]; we'll apply minSlicesPerPool[i]. More...
 
uint16 mMinSlicesPerPool [4]
 Minimum slices per pool, regardless of maxBytesPerPool. More...
 
bool mPackNonPow2
 Whether non-power-of-2 textures should also be pooled, or we should return 1. More...
 

Additional Inherited Members

- Public Types inherited from Ogre::TextureGpuListener
enum  Reason {
  Unknown , FromStorageToSysRam , FromSysRamToStorage , GainedResidency ,
  LostResidency , PoolTextureSlotChanged , ResidentToSysRamSync , MetadataCacheOutOfDate ,
  ExceptionThrown , FsaaSettingAlteredByApi , ReadyForRendering , Deleted
}
 

Detailed Description

This is a Default implementation of TextureGpuManagerListener based on heuristics.

These heuristics can be adjusted by modifying its member variables directly.

Constructor & Destructor Documentation

◆ DefaultTextureGpuManagerListener()

Ogre::DefaultTextureGpuManagerListener::DefaultTextureGpuManagerListener ( )

Member Function Documentation

◆ getFiltersFor()

uint32 Ogre::DefaultTextureGpuManagerListener::getFiltersFor ( const String name,
const String aliasName,
uint32  filters 
) const
overridevirtual

getFiltersFor Gets a chance to alter the filters needed for the given texture to load

Parameters
nameName of the texture
aliasNameAlias name of the texture
filtersCurrent filters that are to be applied
Returns
Actual filters to apply, if the listener modifies them

Implements Ogre::TextureGpuManagerListener.

◆ getNumSlicesFor()

size_t Ogre::DefaultTextureGpuManagerListener::getNumSlicesFor ( TextureGpu texture,
TextureGpuManager textureManager 
)
overridevirtual

Ogre normally puts Textures into pools (a Type2DArray texture) for efficient rendering Note that only textures of the same resolution and format can be put together in the same pool.

This creates two issues:

  • Unless it is known in advance, we do not know how large the array should be. if we create a pool that can hold 64 entries but only 1 texture is actually needed, then we waste a lot of GPU memory.
  • Large textures, such as 4096x4096 RGBA8 occupy a lot of memory 64MB. These pools should not contain a large number of entries. For example creating a pool of 8 entries of these textures means we'd be asking the OS for 512MB of contiguous memory. Due to memory fragmentation, such request is likely to fail and cause Out of Memory conditions.
    Parameters
    textureThe first texture to which will be creating a pool based on its parameters
    textureManagerThe manager, in case you need more info.
    Returns
    How many entries the pool should be able to hold.

Implements Ogre::TextureGpuManagerListener.

◆ notifyTextureChanged()

void Ogre::DefaultTextureGpuManagerListener::notifyTextureChanged ( TextureGpu texture,
TextureGpuListener::Reason  reason,
void *  extraData 
)
overridevirtual

Called when a TextureGpu changed in a way that affects how it is displayed:

  1. TextureGpu::notifyDataIsReady got called (texture is ready to be displayed)
  2. Texture changed residency status.
  3. Texture is being deleted. It won't be a valid pointer after this call.

Implements Ogre::TextureGpuListener.

Member Data Documentation

◆ mMaxResolutionToApplyMinSlices

uint32 Ogre::DefaultTextureGpuManagerListener::mMaxResolutionToApplyMinSlices[4]

If texture resolution is <= maxResolutionToApplyMinSlices[i]; we'll apply minSlicesPerPool[i].

Otherwise, we'll apply minSlicesPerPool[i+1] If resolution > mMaxResolutionToApplyMinSlices[N]; then minSlicesPerPool = 1;

◆ mMinSlicesPerPool

uint16 Ogre::DefaultTextureGpuManagerListener::mMinSlicesPerPool[4]

Minimum slices per pool, regardless of maxBytesPerPool.

It's also the starting num of slices. See mMaxResolutionToApplyMinSlices

◆ mPackNonPow2

bool Ogre::DefaultTextureGpuManagerListener::mPackNonPow2

Whether non-power-of-2 textures should also be pooled, or we should return 1.


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