OGRE-Next
2.3
Object-Oriented Graphics Rendering Engine
|
#include <OgreHlmsComputeJob.h>
Public Member Functions | |
HlmsComputeJob (IdString name, Hlms *creator, const String &sourceFilename, const StringVector &includedPieceFiles) | |
~HlmsComputeJob () override | |
void | _calculateNumThreadGroupsBasedOnSetting () |
INTERNAL USE. More... | |
uint8 | _getRawGlTexSlotStart () const |
ShaderParams * | _getShaderParams (IdString key) |
Gets a shader parameter with the given key. More... | |
void | _setSamplerblock (uint8 slotIdx, const HlmsSamplerblock *refParams) |
Sets a samplerblock directly. More... | |
void | _setUavBuffer (uint8 slotIdx, const DescriptorSetUav::BufferSlot &newSlot) |
Sets an UAV buffer at the given slot ID. More... | |
void | _setUavTexture (uint8 slotIdx, const DescriptorSetUav::TextureSlot &texSlot) |
Sets an UAV texture. More... | |
void | _updateAutoProperties () |
void | analyzeBarriers (ResourceTransitionArray &resourceTransitions, bool clearBarriers=true) |
Checks every regular texture and every UAV (texture and buffers) bound and resolves transitions. More... | |
void | clearTexBuffers () |
Sets all texture buffers to nullptr. More... | |
void | clearUavBuffers () |
Sets all UAV buffers to nullptr. More... | |
HlmsComputeJob * | clone (const String &cloneName) |
void | cloneTo (HlmsComputeJob *dstJob) |
void | createShaderParams (IdString key) |
Creates a set of shader paramters with a given key, e.g. More... | |
Hlms * | getCreator () const |
uint8 | getGlTexSlotStart () const |
IdString | getName () const |
String | getNameStr () const |
size_t | getNumSamplerUnits () const |
See setNumSamplerUnits. More... | |
size_t | getNumTexUnits () const |
const uint32 * | getNumThreadGroups () const |
uint32 | getNumThreadGroupsX () const |
uint32 | getNumThreadGroupsY () const |
uint32 | getNumThreadGroupsZ () const |
size_t | getNumUavUnits () const |
int32 | getProperty (IdString key, int32 defaultVal=0) const |
ShaderParams & | getShaderParams (IdString key) |
Gets a shader parameter with the given key. More... | |
TextureGpu * | getTexture (uint8 slotIdx) const |
const uint32 * | getThreadsPerGroup () const |
uint32 | getThreadsPerGroupX () const |
uint32 | getThreadsPerGroupY () const |
uint32 | getThreadsPerGroupZ () const |
UavBufferPacked * | getUavBuffer (uint8 slotIdx) const |
TextureGpu * | getUavTexture (uint8 slotIdx) const |
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... | |
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 | removePiece (IdString pieceName) |
Removes an existing piece. More... | |
void | removeTexUnit (uint8 slotIdx) |
Destroys a given texture unit, displacing all the higher tex units. More... | |
void | removeUavUnit (uint8 slotIdx) |
Destroys a given texture unit, displacing all the higher tex units. More... | |
void | setConstBuffer (uint8 slotIdx, ConstBufferPacked *constBuffer) |
Sets a const/uniform bufferat the given slot ID. More... | |
void | setGlTexSlotStart (uint8 texSlotStart) |
By default HlmsComputeJob::setTexture and HlmsComputeJob::setTexBuffer are in range [0; getNumTexUnits) More... | |
void | setInformHlmsOfTextureData (bool bInformHlms) |
The Hlms has the ability to pass data to the shader source code via its syntax system to add hardcoded values. More... | |
void | setNumSamplerUnits (uint8 numSlots) |
This value is overriden by setNumTexUnits to be compatible with OpenGL. More... | |
void | setNumTexUnits (uint8 numSlots) |
Creates 'numSlots' number of slots before they can be set. More... | |
void | setNumThreadGroups (uint32 numThreadGroupsX, uint32 numThreadGroupsY, uint32 numThreadGroupsZ) |
Sets the number of groups of threads to dispatch. More... | |
void | setNumThreadGroupsBasedOn (ThreadGroupsBasedOn source, uint8 texSlot, uint8 divisorX, uint8 divisorY, uint8 divisorZ) |
Instead of calling setNumThreadGroups, Ogre can automatically deduce them based on the Texture resolution and the threads per group. More... | |
void | setNumUavUnits (uint8 numSlots) |
Creates 'numSlots' number of slots before they can be set. More... | |
void | setPiece (IdString pieceName, const String &pieceContent) |
Defines a piece, i.e. More... | |
void | setProperty (IdString key, int32 value) |
Sets an arbitrary property to pass to the shader. More... | |
void | setSamplerblock (uint8 slotIdx, const HlmsSamplerblock &refParams) |
Sets a samplerblock based on reference parameters. More... | |
void | setTexBuffer (uint8 slotIdx, const DescriptorSetTexture2::BufferSlot &newSlot) |
Sets a texture buffer at the given slot ID. More... | |
void | setTexture (uint8 slotIdx, const DescriptorSetTexture2::TextureSlot &newSlot, const HlmsSamplerblock *refParams=0, bool bSetSampler=true) |
Sets a texture buffer at the given slot ID. More... | |
void | setThreadsPerGroup (uint32 threadsPerGroupX, uint32 threadsPerGroupY, uint32 threadsPerGroupZ) |
Sets the number of threads per group. More... | |
void | setupRootLayout (RootLayout &rootLayout) |
virtual bool | shouldStayLoaded (TextureGpu *texture) |
Return true if this TextureGpu should likely stay loaded or else graphical changes could occur. More... | |
Friends | |
class | HlmsCompute |
|
inherited |
Enumerator | |
---|---|
Unknown | |
FromStorageToSysRam | OnStorage -> OnSystemRam. |
FromSysRamToStorage | OnSystemRam -> OnStorage. |
GainedResidency | OnStorage -> Resident OnSystemRam -> Resident See ReadyForRendering. |
LostResidency | Resident -> OnStorage Resident -> OnSystemRam. |
PoolTextureSlotChanged | |
ResidentToSysRamSync | Only called while TextureGpu is still Resident, and strategy is AlwaysKeepSystemRamCopy. This listener happens when something was done to the TextureGpu that modifies its contents in the GPU, and were thus forced to sync those values back to SystemRam. This listener calls tells that sync is over. |
MetadataCacheOutOfDate | The Metadata cache was out of date and we had to do a ping-pong. Expect this to be followed by at least LostResidency and GainedResidency calls This is very important, because if you were expecting certain sequence of calls (e.g. you were expecting a LostResidency soon to arrive), expect that to be changed. See TextureGpuManager for details about the metadata cache. |
ExceptionThrown | Called when the worker thread caught an exception. This exception has already been logged, and the texture resumed loading normally with a white 2x2 RGBA8 fallback. This listener will get called from the main thread. The texture may still have pending residency transitions (e.g. it may still be loading the 2x2 fallback) Cast Exception e = reinterpret_cast<Exception>( extraData ); to know more info |
FsaaSettingAlteredByApi | Requested FSAA (MSAA / CSAA / EQAA / etc) is not supported by the API, and thus the setting had to be downgraded. Note this may happen on device lost, and a new GPU became in use; thus it's possible for a TextureGpu to initially support certain FSAA but later change. |
ReadyForRendering | This Reason is called when TextureGpu::notifyDataIsReady is called. This normally means worker thread is done loading texture from file and uploading it to GPU; and can now be used for rendering. It does NOT mean that Ogre has finished issueing rendering commands to a RenderTexture and is now ready to be presented to the monitor. |
Deleted |
Ogre::HlmsComputeJob::HlmsComputeJob | ( | IdString | name, |
Hlms * | creator, | ||
const String & | sourceFilename, | ||
const StringVector & | includedPieceFiles | ||
) |
|
override |
void Ogre::HlmsComputeJob::_calculateNumThreadGroupsBasedOnSetting | ( | ) |
INTERNAL USE.
Calculates the number of thread groups as specified in setNumThreadGroupsBasedOn, overriding setNumThreadGroups.
uint8 Ogre::HlmsComputeJob::_getRawGlTexSlotStart | ( | ) | const |
ShaderParams* Ogre::HlmsComputeJob::_getShaderParams | ( | IdString | key | ) |
Gets a shader parameter with the given key.
e.g. "default" "glsl" "hlsl". Returns null if doesn't exist. See createShaderParams
void Ogre::HlmsComputeJob::_setSamplerblock | ( | uint8 | slotIdx, |
const HlmsSamplerblock * | refParams | ||
) |
Sets a samplerblock directly.
For internal use / advanced users.
slotIdx | See setNumTexUnits. |
Must be in range [0; getNumTexUnits) regardless of what getTexSlotStart is
refParams | Direct samplerblock. Reference count is assumed to already have been increased. We won't increase it ourselves. |
params | The sampler block to use as reference. |
void Ogre::HlmsComputeJob::_setUavBuffer | ( | uint8 | slotIdx, |
const DescriptorSetUav::BufferSlot & | newSlot | ||
) |
Sets an UAV buffer at the given slot ID.
slotIdx | See setNumUavUnits. The slot index to bind this UAV buffer. |
newSlot |
void Ogre::HlmsComputeJob::_setUavTexture | ( | uint8 | slotIdx, |
const DescriptorSetUav::TextureSlot & | texSlot | ||
) |
Sets an UAV texture.
slot | See setNumUavUnits. |
void Ogre::HlmsComputeJob::_updateAutoProperties | ( | ) |
void Ogre::HlmsComputeJob::analyzeBarriers | ( | ResourceTransitionArray & | resourceTransitions, |
bool | clearBarriers = true |
||
) |
Checks every regular texture and every UAV (texture and buffers) bound and resolves transitions.
resourceTransitions |
void Ogre::HlmsComputeJob::clearTexBuffers | ( | ) |
Sets all texture buffers to nullptr.
void Ogre::HlmsComputeJob::clearUavBuffers | ( | ) |
Sets all UAV buffers to nullptr.
HlmsComputeJob* Ogre::HlmsComputeJob::clone | ( | const String & | cloneName | ) |
void Ogre::HlmsComputeJob::cloneTo | ( | HlmsComputeJob * | dstJob | ) |
void Ogre::HlmsComputeJob::createShaderParams | ( | IdString | key | ) |
Creates a set of shader paramters with a given key, e.g.
"default" "glsl" "hlsl". Does nothing if parameters already exist.
|
inline |
uint8 Ogre::HlmsComputeJob::getGlTexSlotStart | ( | ) | const |
|
inline |
String Ogre::HlmsComputeJob::getNameStr | ( | ) | const |
|
inline |
See setNumSamplerUnits.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
ShaderParams& Ogre::HlmsComputeJob::getShaderParams | ( | IdString | key | ) |
Gets a shader parameter with the given key.
e.g. "default" "glsl" "hlsl". Creates if does not exist.
TextureGpu* Ogre::HlmsComputeJob::getTexture | ( | uint8 | slotIdx | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
UavBufferPacked* Ogre::HlmsComputeJob::getUavBuffer | ( | uint8 | slotIdx | ) | const |
TextureGpu* Ogre::HlmsComputeJob::getUavTexture | ( | uint8 | slotIdx | ) | const |
|
overridevirtual |
Called when a TextureGpu changed in a way that affects how it is displayed:
Implements Ogre::TextureGpuListener.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
operator new, with debug line info
|
inlineinherited |
placement operator new
|
inlineinherited |
|
inlineinherited |
array operator new, with debug line info
void Ogre::HlmsComputeJob::removePiece | ( | IdString | pieceName | ) |
Removes an existing piece.
See setPiece. Does nothing if the piece didn't exist.
void Ogre::HlmsComputeJob::removeTexUnit | ( | uint8 | slotIdx | ) |
Destroys a given texture unit, displacing all the higher tex units.
void Ogre::HlmsComputeJob::removeUavUnit | ( | uint8 | slotIdx | ) |
Destroys a given texture unit, displacing all the higher tex units.
void Ogre::HlmsComputeJob::setConstBuffer | ( | uint8 | slotIdx, |
ConstBufferPacked * | constBuffer | ||
) |
Sets a const/uniform bufferat the given slot ID.
slotIdx | Slot to bind to. It's independent from the texture & UAV ones. |
constBuffer | Const buffer to bind. |
void Ogre::HlmsComputeJob::setGlTexSlotStart | ( | uint8 | texSlotStart | ) |
By default HlmsComputeJob::setTexture and HlmsComputeJob::setTexBuffer are in range [0; getNumTexUnits)
However this allows you to offset the range to [texSlotStart; texSlotStart + getNumTexUnits)
This is useful when ReadOnlyBuffers are bound via setTexBuffers, because in OpenGL these will map to uav buffer slots, thus overlapping/conflicting with UAVs
texSlotStart | The offset at which the textures/texbuffers should start being bound |
void Ogre::HlmsComputeJob::setInformHlmsOfTextureData | ( | bool | bInformHlms | ) |
The Hlms has the ability to pass data to the shader source code via its syntax system to add hardcoded values.
For example, you may want to unroll a loop based on the width of a texture for maximum performance.
bInformHlms | True to enable this feature, false to disable. |
void Ogre::HlmsComputeJob::setNumSamplerUnits | ( | uint8 | numSlots | ) |
This value is overriden by setNumTexUnits to be compatible with OpenGL.
However you can later override this behavior to minimize the number of samplers by shrinking (or enlarging?) the sampler units.
This is an advanced function. Don't use it unless you're careful not to assume 1 tex unit = 1 sampler unit
void Ogre::HlmsComputeJob::setNumTexUnits | ( | uint8 | numSlots | ) |
Creates 'numSlots' number of slots before they can be set.
void Ogre::HlmsComputeJob::setNumThreadGroups | ( | uint32 | numThreadGroupsX, |
uint32 | numThreadGroupsY, | ||
uint32 | numThreadGroupsZ | ||
) |
Sets the number of groups of threads to dispatch.
Note the actual value may be changed by the shader template using the @pset() function. These values are passed to the template as: num_thread_groups_x num_thread_groups_y num_thread_groups_z
void Ogre::HlmsComputeJob::setNumThreadGroupsBasedOn | ( | ThreadGroupsBasedOn | source, |
uint8 | texSlot, | ||
uint8 | divisorX, | ||
uint8 | divisorY, | ||
uint8 | divisorZ | ||
) |
Instead of calling setNumThreadGroups, Ogre can automatically deduce them based on the Texture resolution and the threads per group.
It is calculated as follows: scaledWidth = (textureWidth + divisorX - 1u) / divisorX; numThreadGroupsX = (scaledWidth + threadsPerGroupX - 1u) / threadsPerGroupX;
source | What to use as source for the calculations. See ThreadGroupsBasedOn |
texSlot | Index of the texture/uav unit. |
divisorX | divisorY divisorZ Often compute shaders operate on multiple pixels, thus you need less thread groups. For example if you operate on blocks of 2x2, then you want divisorX = 2 and divisorY = 2. |
void Ogre::HlmsComputeJob::setNumUavUnits | ( | uint8 | numSlots | ) |
Creates 'numSlots' number of slots before they can be set.
Defines a piece, i.e.
the same as doing @piece( pieceName )pieceContent@end If the piece doesn't exist, it gets created. If the piece already exists, it gets overwritten.
pieceName | Name of the piece. |
pieceContent | The contents of the piece. |
Sets an arbitrary property to pass to the shader.
key | Name of the property |
value | Value to set |
void Ogre::HlmsComputeJob::setSamplerblock | ( | uint8 | slotIdx, |
const HlmsSamplerblock & | refParams | ||
) |
Sets a samplerblock based on reference parameters.
slotIdx | See setNumTexUnits. |
Must be in range [0; getNumTexUnits) regardless of what getTexSlotStart is
refParams | We'll create (or retrieve an existing) samplerblock based on the input parameters. |
void Ogre::HlmsComputeJob::setTexBuffer | ( | uint8 | slotIdx, |
const DescriptorSetTexture2::BufferSlot & | newSlot | ||
) |
Sets a texture buffer at the given slot ID.
See HlmsComputeJob::setTexSlotStart to workaround that
slotIdx | See setNumTexUnits. The slot index to bind this texture buffer In OpenGL, a few cards support between to 16-18 texture units, while most cards support up to 32 |
Must be in range [0; getNumTexUnits) regardless of what getTexSlotStart is
newSlot |
void Ogre::HlmsComputeJob::setTexture | ( | uint8 | slotIdx, |
const DescriptorSetTexture2::TextureSlot & | newSlot, | ||
const HlmsSamplerblock * | refParams = 0 , |
||
bool | bSetSampler = true |
||
) |
Sets a texture buffer at the given slot ID.
slotIdx | See setNumTexUnits. The slot index to bind this texture In OpenGL, some cards support up to 16-18 texture units, while most cards support up to 32 |
Must be in range [0; getNumTexUnits) regardless of what getTexSlotStart is
samplerblock | Optional. We'll create (or retrieve an existing) samplerblock based on the input parameters. When null, we leave the previously set samplerblock (if a texture is being set, and if no samplerblock was set, we'll create a default one) |
bSetSampler | If true, samplerblock will behave as described. When false and samplerblock is nullptr, we won't touch the samplerblock. Only use this with APIs that have separate texturse & sampler (e.g. everyone except GL) |
void Ogre::HlmsComputeJob::setThreadsPerGroup | ( | uint32 | threadsPerGroupX, |
uint32 | threadsPerGroupY, | ||
uint32 | threadsPerGroupZ | ||
) |
Sets the number of threads per group.
Note the actual value may be changed by the shader template using the @pset() function. These values are passed to the template as: threads_per_group_x threads_per_group_y threads_per_group_z
void Ogre::HlmsComputeJob::setupRootLayout | ( | RootLayout & | rootLayout | ) |
|
inlinevirtualinherited |
Return true if this TextureGpu should likely stay loaded or else graphical changes could occur.
Return false if it is certainly safe to unload.
Reimplemented in Ogre::VctLighting, and Ogre::OGRE_HLMS_TEXTURE_BASE_CLASS.
|
friend |