OGRE-Next: Ogre::HlmsCompute Class Reference

| OGRE-Next 3.0.0 Object-Oriented Graphics Rendering Engine

Loading...
Searching...
No Matches
Ogre::HlmsCompute Class Reference
Component » Material

HLMS implementation that handles compute shaders. More...

`#include <OgreHlmsCompute.h>`

Inheritance diagram for Ogre::HlmsCompute:
[legend]

## Public Member Functions
| HlmsCompute (AutoParamDataSource *autoParamDataSource)
| ~HlmsCompute () override
void | _changeRenderSystem (RenderSystem *newRs) override
void | clearShaderCache () override
| Destroys the shader cache from all jobs, causing us to reload shaders from file again.
HlmsComputeJob * | createComputeJob (IdString datablockName, const String &refName, const String &sourceFilename, const StringVector &includedPieceFiles)
| An HlmsComputeJob is very similar to an HlmsDatablock, except it contains a compute job instead.
HlmsDatablock * | createDefaultDatablock () override
void | destroyAllComputeJobs ()
| Destroys all jobs created via.
void | destroyComputeJob (IdString name)
| Destroys a specific Compute Job.
void | dispatch (HlmsComputeJob *job, SceneManager *sceneManager, Camera *camera)
| Main function for dispatching a compute job.
uint32 | fillBuffersFor (const HlmsCache *cache, const QueuedRenderable &queuedRenderable, bool casterPass, uint32 lastCacheHash, uint32 lastTextureHash) override
| Fills the constant buffers.
uint32 | fillBuffersForV1 (const HlmsCache *cache, const QueuedRenderable &queuedRenderable, bool casterPass, uint32 lastCacheHash, CommandBuffer *commandBuffer) override
uint32 | fillBuffersForV2 (const HlmsCache *cache, const QueuedRenderable &queuedRenderable, bool casterPass, uint32 lastCacheHash, CommandBuffer *commandBuffer) override
HlmsComputeJob * | findComputeJob (IdString datablockName) const
| Finds an existing Compute Job. If none found, throws an exception.
HlmsComputeJob * | findComputeJobNoThrow (IdString datablockName) const
| Finds an existing Compute Job. If none found, returns null.
const String * | getJobNameStr (IdString name) const
| Returns the string name associated with its hashed name (this was passed as refName in createComputeJob()).
void | reloadFrom (Archive *newDataFolder, ArchiveVec *libraryFolders=0) override
| Destroys all the cached shaders and in the next opportunity will recreate them from the new location.
Public Member Functions inherited from Ogre::Hlms
| Hlms (HlmsTypes type, const String &typeName, Archive *dataFolder, ArchiveVec *libraryFolders)
virtual | ~Hlms ()
void | _clearShaderCache ()
virtual void | _collectSamplerblocks (set< const HlmsSamplerblock * >::type &outSamplerblocks, const HlmsDatablock *datablock) const
void | _compileShaderFromPreprocessedSource (const RenderableCache &mergedCache, const String source[NumShaderTypes])
int32 | _getProperty (IdString key, int32 defaultVal=0) const
virtual void | _loadJson (const rapidjson::Value &jsonValue, const HlmsJson::NamedBlocks &blocks, HlmsDatablock *datablock, const String &resourceGroup, HlmsJsonListener *listener, const String &additionalTextureExtension) const
| Loads datablock values from a JSON value.
void | _notifyManager (HlmsManager *manager)
virtual void | _saveJson (const HlmsDatablock *datablock, String &outString, HlmsJsonListener *listener, const String &additionalTextureExtension) const
void | _setProperty (IdString key, int32 value)
| For debugging stuff. I.e. the Command line uses it for testing manually set properties.
void | _setTextureReg (ShaderType shaderType, const char *texName, int32 texUnit)
virtual void | analyzeBarriers (BarrierSolver &barrierSolver, ResourceTransitionArray &resourceTransitions, Camera *renderingCamera, const bool bCasterPass)
virtual void | calculateHashFor (Renderable *renderable, uint32 &outHash, uint32 &outCasterHash)
| Called by the renderable when either it changes the material, or its properties change (e.g.
void | compileShaderCode (ShaderCodeCache &codeCache)
| Compiles input properties and adds it to the shader code cache.
HlmsDatablock * | createDatablock (IdString name, const String &refName, const HlmsMacroblock &macroblockRef, const HlmsBlendblock &blendblockRef, const HlmsParamVec &paramVec, bool visibleToManager=true, const String &filename=BLANKSTRING, const String &resourceGroup=BLANKSTRING)
| Creates a unique datablock that can be shared by multiple renderables.
void | destroyAllDatablocks ()
| Destroys all datablocks created with createDatablock().
void | destroyDatablock (IdString name)
| Destroys a datablocks given its name.
virtual void | frameEnded ()
| Called when the frame has fully ended (ALL passes have been executed to all RTTs).
uint16 | getAreaLightsApproxLimit () const
uint16 | getAreaLightsLtcLimit () const
HlmsDatablock * | getDatablock (IdString name) const
| Finds an existing datablock based on its name (.
const HlmsDatablockMap & | getDatablockMap () const
| Returns all datablocks owned by this Hlms, including the default one.
Archive * | getDataFolder ()
HlmsDatablock * | getDefaultDatablock () const
| Datablock to use when another datablock failed or none was specified.
bool | getFastShaderBuildHack () const
| Returns true if shaders are being compiled with Fast Shader Build Hack (D3D11 only).
void | getFilenameAndResourceGroup (IdString name, String const **outFilename, String const **outResourceGroup) const
| Returns the filaname & resource group a datablock was created from, and is associated with its hashed name (this was passed as in createDatablock()).
HlmsManager * | getHlmsManager () const
HlmsListener * | getListener () const
| Returns the current listener.
const HlmsCache * | getMaterial (HlmsCache const *lastReturnedValue, const HlmsCache &passCache, const QueuedRenderable &queuedRenderable, bool casterPass)
| Retrieves an HlmsCache filled with the GPU programs to be used by the given renderable.
uint16 | getMaxNonCasterDirectionalLights () const
const String * | getNameStr (IdString name) const
| Returns the string name associated with its hashed name (this was passed as refName in createDatablock()).
const LibraryVec & | getPiecesLibrary () const
ArchiveVec | getPiecesLibraryAsArchiveVec () const
PrecisionMode | getPrecisionMode () const
| Returns requested precision mode (i.e.
RenderSystem * | getRenderSystem () const
const ShaderCodeCacheVec & | getShaderCodeCache () const
const String & | getShaderProfile () const
IdString | getShaderSyntax () const
bool | getStaticBranchingLights () const
PrecisionMode | getSupportedPrecisionMode () const
| Some GPUs don't support all precision modes.
void | getTemplateChecksum (uint64 outHash[2]) const
HlmsTypes | getType () const
IdString | getTypeName () const
const String & | getTypeNameStr () const
bool | parseOffline (const String &filename, String &inBuffer, String &outBuffer)
| For standalone parsing.
virtual void | postCommandBufferExecution (CommandBuffer *commandBuffer)
| This gets called after executing the command buffer.
virtual void | preCommandBufferExecution (CommandBuffer *commandBuffer)
| This gets called right before executing the command buffer.
virtual HlmsCache | preparePassHash (const Ogre::CompositorShadowNode *shadowNode, bool casterPass, bool dualParaboloid, SceneManager *sceneManager)
| Called every frame by the Render Queue to cache the properties needed by this pass.
void | saveAllTexturesFromDatablocks (const String &folderPath, set< String >::type &savedTextures, bool saveOitd, bool saveOriginal, HlmsTextureExportListener *listener)
void | setAreaLightForwardSettings (uint16 areaLightsApproxLimit, uint16 areaLightsLtcLimit)
| Area lights use regular Forward.
void | setDebugOutputPath (bool enableDebugOutput, bool outputProperties, const String &path=BLANKSTRING)
| Call to output the automatically generated shaders (which are usually made from templates) on the given folder for inspection, analyzing, debugging, etc.
void | setListener (HlmsListener *listener)
| Sets a listener to extend an existing Hlms implementation's with custom code, without having to rewrite it or modify the source code directly.
void | setMaxNonCasterDirectionalLights (uint16 maxLights)
| Non-caster directional lights are hardcoded into shaders.
void | setPrecisionMode (PrecisionMode precisionMode)
| Sets the precision mode of Hlms.
virtual void | setStaticBranchingLights (bool staticBranchingLights)
| By default shadow-caster spot and point lights are hardcoded into shaders.

## Additional Inherited Members
Public Types inherited from Ogre::Hlms
typedef std::map< IdString, DatablockEntry > | HlmsDatablockMap
typedef vector< Library >::type | LibraryVec
enum | LightGatheringMode { LightGatherForward , LightGatherForwardPlus , LightGatherDeferred , LightGatherNone }
enum | PrecisionMode { PrecisionFull32 , PrecisionMidf16 , PrecisionRelaxed }
Static Public Member Functions inherited from Ogre::Hlms
static bool | findParamInVec (const HlmsParamVec &paramVec, IdString key, String &inOut)
| Finds the parameter with key 'key' in the given 'paramVec'.
static int32 | getProperty (const HlmsPropertyVec &properties, IdString key, int32 defaultVal=0)
| Utility helper, mostly useful to HlmsListener implementations.
static void | setProperty (HlmsPropertyVec &properties, IdString key, int32 value)
| Utility helper, mostly useful to HlmsListener implementations.

## Detailed Description

HLMS implementation that handles compute shaders.

It isn't registered in the usual way to the HlmsManager.

## Constructor & Destructor Documentation

## ◆ HlmsCompute()

Ogre::HlmsCompute::HlmsCompute | ( | AutoParamDataSource * | autoParamDataSource | ) |

## ◆ ~HlmsCompute()

Ogre::HlmsCompute::~HlmsCompute | ( |  | ) |
| override

## Member Function Documentation

## ◆ _changeRenderSystem()

void Ogre::HlmsCompute::_changeRenderSystem | ( | RenderSystem * | newRs | ) |
| overridevirtual

Reimplemented from Ogre::Hlms.

## ◆ clearShaderCache()

void Ogre::HlmsCompute::clearShaderCache | ( |  | ) |
| overridevirtual

Destroys the shader cache from all jobs, causing us to reload shaders from file again.

Reimplemented from Ogre::Hlms.

## ◆ createComputeJob()

HlmsComputeJob * Ogre::HlmsCompute::createComputeJob | ( | IdString | datablockName,
|  | const String & | refName,
|  | const String & | sourceFilename,
|  | const StringVector & | includedPieceFiles )

An HlmsComputeJob is very similar to an HlmsDatablock, except it contains a compute job instead.

If multiple HlmsComputeJob end up having the same compute shader (i.e. the resulting source code is the same); they will share the same shader.

Parameters

  datablockName | Name to assign to the job, for lookup.
  refName | User-friendly readable name of the job. Normally should match the datablockName
  sourceFilename | Main file to use for compiling.
  includedPieceFiles | Included files, to be parsed to defined pieces for the main file to use (can be empty).

Returns
  A new job.

## ◆ createDefaultDatablock()

HlmsDatablock * Ogre::HlmsCompute::createDefaultDatablock | ( |  | ) |
| overridevirtual

Reimplemented from Ogre::Hlms.

## ◆ destroyAllComputeJobs()

void Ogre::HlmsCompute::destroyAllComputeJobs | ( |  | ) |

Destroys all jobs created via.

See also
  createComputeJob

## ◆ destroyComputeJob()

void Ogre::HlmsCompute::destroyComputeJob | ( | IdString | name | ) |

Destroys a specific Compute Job.

You are responsible for ensuring is not in use anywhere (otherwise a dangling pointer will ensue)

## ◆ dispatch()

void Ogre::HlmsCompute::dispatch | ( | HlmsComputeJob * | job,
|  | SceneManager * | sceneManager,
|  | Camera * | camera )

Main function for dispatching a compute job.

## ◆ fillBuffersFor()

uint32 Ogre::HlmsCompute::fillBuffersFor | ( | const HlmsCache * | cache,
|  | const QueuedRenderable & | queuedRenderable,
|  | bool | casterPass,
|  | uint32 | lastCacheHash,
|  | uint32 | lastTextureHash )
| overridevirtual

Fills the constant buffers.

Gets executed right before drawing the mesh.

Parameters

  cache | Current cache of Shaders to be used.
  queuedRenderable | The Renderable-MovableObject pair about to be rendered.
  casterPass | Whether this is a shadow mapping caster pass.
  lastCacheHash | The hash of the cache of shaders that was the used by the previous renderable.
  lastTextureHash | Last Texture Hash, used to let the Hlms know whether the textures should be changed again

Returns
  New Texture hash (may be equal or different to lastTextureHash).

Implements Ogre::Hlms.

## ◆ fillBuffersForV1()

uint32 Ogre::HlmsCompute::fillBuffersForV1 | ( | const HlmsCache * | cache,
|  | const QueuedRenderable & | queuedRenderable,
|  | bool | casterPass,
|  | uint32 | lastCacheHash,
|  | CommandBuffer * | commandBuffer )
| overridevirtual

Implements Ogre::Hlms.

## ◆ fillBuffersForV2()

uint32 Ogre::HlmsCompute::fillBuffersForV2 | ( | const HlmsCache * | cache,
|  | const QueuedRenderable & | queuedRenderable,
|  | bool | casterPass,
|  | uint32 | lastCacheHash,
|  | CommandBuffer * | commandBuffer )
| overridevirtual

Implements Ogre::Hlms.

## ◆ findComputeJob()

HlmsComputeJob * Ogre::HlmsCompute::findComputeJob | ( | IdString | datablockName | ) | const

Finds an existing Compute Job. If none found, throws an exception.

## ◆ findComputeJobNoThrow()

HlmsComputeJob * Ogre::HlmsCompute::findComputeJobNoThrow | ( | IdString | datablockName | ) | const

Finds an existing Compute Job. If none found, returns null.

## ◆ getJobNameStr()

const String * Ogre::HlmsCompute::getJobNameStr | ( | IdString | name | ) | const

Returns the string name associated with its hashed name (this was passed as refName in createComputeJob()).

Returns null ptr if not found. The reason this String doesn't live in HlmsComputeJob is to prevent cache trashing (jobs are hot iterated every frame, and the full name is rarely ever used)

## ◆ reloadFrom()

void Ogre::HlmsCompute::reloadFrom | ( | Archive * | newDataFolder,
|  | ArchiveVec * | libraryFolders = 0 )
| overridevirtual

Destroys all the cached shaders and in the next opportunity will recreate them from the new location.

This is very useful for fast iteration and real-time editing of Hlms shader templates.

Remarks
  Calling with null pointer is possible and will only invalidate existing shaders but you should provide a valid pointer before we start generating the first shader (or else crash).

  Existing datablock materials won't be reloaded from files, so their properties won't change (i.e. changed from blue to red), but the shaders will.

Parameters

  libraryFolders | When null pointer, the library folders paths won't be changed at all (but still will be reloaded). When non-null pointer, the library folders will be overwriten. Pass an empty container if you want to stop using libraries.

Reimplemented from Ogre::Hlms.

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

- OgreHlmsCompute.h