|
| PsoCacheHelper (RenderSystem *renderSystem) |
|
| ~PsoCacheHelper () |
|
void | clearState () |
|
HlmsPso * | getPso () |
| Returns an HlmsPso you can set via renderSystem->_setPipelineStateObject based on all past calls to setRenderTarget + setVertexFormat + setMacroblock + etc. More...
|
|
HlmsPso * | getPso (uint32 renderableHash, bool renderableCacheAlreadySet=false) |
| Returns an HlmsPso you can set via renderSystem->_setPipelineStateObject based on the input hash calculated via getRenderableHash. More...
|
|
uint32 | getRenderableHash () |
| Returns a hash value you can cache into a Renderable (or whatever you're rendering). More...
|
|
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 *) |
|
void * | operator new (size_t sz) |
|
void * | operator new (size_t sz, const char *file, int line, const char *func) |
| operator new, with debug line info More...
|
|
void * | operator new (size_t sz, void *ptr) |
| placement operator new More...
|
|
void * | operator new[] (size_t sz) |
|
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
| array operator new, with debug line info More...
|
|
void | setBlendblock (const HlmsBlendblock *blendblock) |
| Calls to this function cannot be skipped unless you have a renderableHash. More...
|
|
void | setMacroblock (const HlmsMacroblock *macroblock) |
| Calls to this function cannot be skipped unless you have a renderableHash. More...
|
|
void | setPixelShader (GpuProgramPtr &shader) |
| Calls to this function can be skipped if it's valid to not have a shader set at this stage, or if you have a renderableHash. More...
|
|
void | setRenderTarget (const RenderPassDescriptor *renderPassDesc) |
| You must call this function every frame, and every time the RenderTarget changes. More...
|
|
void | setVertexFormat (const VertexElement2VecVec &vertexElements, OperationType operationType, bool enablePrimitiveRestart) |
| This function can be skipped if no vertex buffer is used (e.g. More...
|
|
void | setVertexShader (GpuProgramPtr &shader) |
| Calls to this function can be skipped if it's valid to not have a shader set at this stage, or if you have a renderableHash. More...
|
|
Utility class to cache PSOs.
Useful for porting v1 libraries (eg. Gorilla) that render in "immediate mode" style and weren't build with PSOs in mind. Ideally a PSO would be created ahead of time and its pointer stored alongside the renderable you need to render.
- Almost all functions already do redundant state checking unless explicitly stated, thus there is no need for you to do it yourself.
- Usage (example) "OK": PsoCacheHelper psoCache( renderSystem ); //Save this variable (i.e. per class)
void render() { psoCache.clearState(); psoCache.setRenderTarget( renderTarget ); for( int i=0; i<numMaterials; ++i ) { psoCache.setMacroblock( material[i].macroblock ); psoCache.setBlendblock( material[i].blendblock ); psoCache.setVertexShader( material[i].vertexShader ); psoCache.setPixelShader( material[i].pixelShader ); for( int j=0; j<numThingsToRenderPerMaterial; ++j ) { v1::RenderOperation renderOp = renderables[j].renderOp; Consider caching 'vertexElements' somewhere as convertToV2 involves allocations VertexElement2VecVec vertexElements = renderOp.vertexData-> vertexDeclaration->convertToV2(); psoCache.setVertexFormat( vertexElements, renderOp.operationType, enablePrimitiveRestart );
HlmsPso *pso = psoCache.getPso(); renderSystem->_setPipelineStateObject( pso ); } } }
Usage "MUCH better": PsoCacheHelper psoCache( renderSystem ); //Save this variable (i.e. per class)
Outside rendering, just ONCE at loading time or when the material changes (or the vertex layout changes): psoCache.clearState(); psoCache.setMacroblock( material[i].macroblock ); psoCache.setBlendblock( material[i].blendblock ); psoCache.setVertexShader( material[i].vertexShader ); psoCache.setPixelShader( material[i].pixelShader ); for( int j=0; j<numThingsToRenderPerMaterial; ++j ) { v1::RenderOperation renderOp = renderables[j].renderOp; Consider caching 'vertexElements' somewhere as convertToV2 involves allocations VertexElement2VecVec vertexElements = renderOp.vertexData-> vertexDeclaration->convertToV2(); psoCache.setVertexFormat( vertexElements, renderOp.operationType, enablePrimitiveRestart );
renderables[j].customSavedValue = psoCache.getRenderableHash(); }
During render: void render() { psoCache.clearState(); setRenderTarget still needs to be called. psoCache.setRenderTarget( renderTarget ); for( int i=0; i<numMaterials; ++i ) { for( int j=0; j<numThingsToRenderPerMaterial; ++j ) { HlmsPso *pso = psoCache.getPso( renderables[j].customSavedValue ); renderSystem->_setPipelineStateObject( pso ); } } }