ClipMapBlenderCache Class Reference

#include <clipMapBlenderCache.h>

Inheritance diagram for ClipMapBlenderCache:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 ClipMapBlenderCache (IClipMapImageSource *opacitySource, IClipMapImageSource *lightmapSource, bool LM1=false)
 ClipMapBlenderCache (IClipMapImageSource *lightmapSource)
virtual ~ClipMapBlenderCache ()
virtual void initialize (ClipMap *cm)
 Initialize the image cache that can hold at least clipMapSize*clipMapSize pixels of data.
virtual void setInterestCenter (const Point2I &origin)
 Indicate our interest area center.
virtual bool beginRectUpdates (ClipMap::ClipStackEntry &cse)
 Indicate that we are going to be updating a series of rectangles on specified level of the clipstack.
virtual void doRectUpdate (U32 mipLevel, ClipMap::ClipStackEntry &cse, const RectI &srcRegion, const RectI &dstRegion)
 Indicate that we're updating a specific rectangle on a clipstack.
virtual void finishRectUpdates (ClipMap::ClipStackEntry &cse)
 And finally, give the cache a chance to finish processing for a specified clipstack level.
virtual bool isDataAvailable (U32 mipLevel, const RectI &region) const
 Is cached data available for a given region?
virtual bool isRenderToTargetCache ()
 If true, we'll allocate render targets rather than normal diffuse maps.
void clearSourceImages ()
void registerSourceImage (const String &imgPath)
void clearOpacitySources ()
void registerOpacitySource (IClipMapImageSource *opacitySource)
void createOpacityScratchTextures ()
void setNewLightmapSource (IClipMapImageSource *lightmapSource)

Private Member Functions

void setupGeometry (const RectF &srcRect0, const RectF &srcRect1, const RectF &masterCoords, const RectI &dstRect)
 Generate appropriate volatile geometry and set it as the current VB.
void setupGeometryFF (const RectF &srcRect0, const RectF &masterCoords, const F32 scaleFactor, const RectI &dstRect)

Private Attributes

VectorPtr< IClipMapImageSource * > mOpacitySources
 References to image source for opacity and lightmap information.
VectorPtr< IClipMapImageSource * > mLightmapSources
Point4F mTempScaleFactors
Vector< F32mScales
Vector< F32mSourceWidths
Vector< GFXTexHandlemOpacityScratchTextures
 Used for streaming video data to card for blend operations.
Vector< GFXTexHandlemLightmapScratchTextures
bool mLM1
 Whether LM1 (lightmap blend factor 1) shaders should be used.
bool mFixedfunction
 Whether mOpacityScratchTexturesFF should be used, amongst other things.
GFXShaderConstBufferRef mShaderConsts
 Shared shader constant blocks.
GFXShaderConstHandlemModelViewProjSC
GFXShaderConstHandlemOpacityMapSC
GFXShaderConstHandlemLightMapSC
GFXShaderConstHandlemTex1SC
GFXShaderConstHandlemTex2SC
GFXShaderConstHandlemTex3SC
GFXShaderConstHandlemTex4SC
GFXShaderConstHandlemSourceTexScalesSC
GFXShadermOnePass
 SM2.0 shader used for one pass blending.
GFXStateBlockRef mOnePassSB
GFXShadermTwoPass [2]
 SM1.0 shaders used for two pass blending.
GFXStateBlockRef mTwoPassSB
GFXStateBlockRef mFFBaseLayerSB
 FF.
GFXStateBlockRef mFFAdditionalLayersSB
GFXStateBlockRef mFFLightmapSB
Vector< GFXTexHandlemSourceImages
 Images that we're blending; in channel-usage order.
U32 mClipMapSize
ClipMapmOwningClipMap

Constructor & Destructor Documentation

ClipMapBlenderCache::ClipMapBlenderCache ( IClipMapImageSource opacitySource,
IClipMapImageSource lightmapSource,
bool  LM1 = false 
)

ClipMapBlenderCache::ClipMapBlenderCache ( IClipMapImageSource lightmapSource  ) 

virtual ClipMapBlenderCache::~ClipMapBlenderCache (  )  [virtual]


Member Function Documentation

virtual void ClipMapBlenderCache::initialize ( ClipMap cm  )  [virtual]

Initialize the image cache that can hold at least clipMapSize*clipMapSize pixels of data.

In general the image cache will allocate a bit more than that so it can be efficient in pre-empting requests.

The image cache will also store mipmap data for the interest point, at least clipMapSize px at each miplevel. e.g., for a parameter of 512, we would have available in the cache at all times 512*512*clipMapDepth pixels. Ideally, we would ensure at least one page quanta's worth of extra data is present at all levels so we can fulfill new data requests quickly.

For instance, if we have 128px paged tiles, we'd want to have at least 512/128 = 4 base tiles and 2 border tiles on each axis, so 36 loaded tiles at all times at the source level of detail. This is about two and a quarter megabytes of data per clipmap level, so a cache of about 7 levels * 2.25mb = 15.75mb in system memory for a 32k px source texture. We don't need any "mip" levels - just pure source data for every cliplevel greater than or equal to the clipmap size.

As we may need to regenerate the full clipmap in the case of zombification, we can't discard the top level of data, even though it is never needed in the course of normal clipmap operation.

Implements IClipMapImageCache.

virtual void ClipMapBlenderCache::setInterestCenter ( const Point2I origin  )  [virtual]

Indicate our interest area center.

The cache is for a fixed size area, so we disallow changing that area size.

Implements IClipMapImageCache.

virtual bool ClipMapBlenderCache::beginRectUpdates ( ClipMap::ClipStackEntry cse  )  [virtual]

Indicate that we are going to be updating a series of rectangles on specified level of the clipstack.

Implements IClipMapImageCache.

virtual void ClipMapBlenderCache::doRectUpdate ( U32  mipLevel,
ClipMap::ClipStackEntry cse,
const RectI srcRegion,
const RectI dstRegion 
) [virtual]

Indicate that we're updating a specific rectangle on a clipstack.

Parameters:
srcRegion The region on the source mip level we are updating from.
dstRegion The region on the clipmap layer we'll be updating into.

Implements IClipMapImageCache.

virtual void ClipMapBlenderCache::finishRectUpdates ( ClipMap::ClipStackEntry cse  )  [virtual]

And finally, give the cache a chance to finish processing for a specified clipstack level.

Implements IClipMapImageCache.

virtual bool ClipMapBlenderCache::isDataAvailable ( U32  mipLevel,
const RectI region 
) const [virtual]

Is cached data available for a given region?

Implements IClipMapImageCache.

virtual bool ClipMapBlenderCache::isRenderToTargetCache (  )  [virtual]

If true, we'll allocate render targets rather than normal diffuse maps.

Implements IClipMapImageCache.

void ClipMapBlenderCache::clearSourceImages (  ) 

void ClipMapBlenderCache::registerSourceImage ( const String imgPath  ) 

void ClipMapBlenderCache::clearOpacitySources (  ) 

void ClipMapBlenderCache::registerOpacitySource ( IClipMapImageSource opacitySource  ) 

void ClipMapBlenderCache::createOpacityScratchTextures (  ) 

void ClipMapBlenderCache::setNewLightmapSource ( IClipMapImageSource lightmapSource  ) 

void ClipMapBlenderCache::setupGeometry ( const RectF srcRect0,
const RectF srcRect1,
const RectF masterCoords,
const RectI dstRect 
) [private]

Generate appropriate volatile geometry and set it as the current VB.

void ClipMapBlenderCache::setupGeometryFF ( const RectF srcRect0,
const RectF masterCoords,
const F32  scaleFactor,
const RectI dstRect 
) [private]


Member Data Documentation

References to image source for opacity and lightmap information.

Used for streaming video data to card for blend operations.

Whether LM1 (lightmap blend factor 1) shaders should be used.

Whether mOpacityScratchTexturesFF should be used, amongst other things.

Shared shader constant blocks.

SM2.0 shader used for one pass blending.

SM1.0 shaders used for two pass blending.

Images that we're blending; in channel-usage order.