![]() |
OGRE
2.1.0unstable
Object-Oriented Graphics Rendering Engine
|
#include <OgreHlmsComputeJob.h>
Public Types | |
enum | ThreadGroupsBasedOn { ThreadGroupsBasedOnNothing, ThreadGroupsBasedOnTexture, ThreadGroupsBasedOnUav } |
Public Member Functions | |
HlmsComputeJob (IdString name, Hlms *creator, const String &sourceFilename, const StringVector &includedPieceFiles) | |
virtual | ~HlmsComputeJob () |
void | _calculateNumThreadGroupsBasedOnSetting () |
INTERNAL USE. More... | |
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, UavBufferPacked *uavBuffer, ResourceAccess::ResourceAccess access, size_t offset=0, size_t sizeBytes=0) |
Sets an UAV buffer at the given slot ID. More... | |
void | _setUavTexture (uint8 slotIdx, TexturePtr &texture, int32 textureArrayIndex, ResourceAccess::ResourceAccess access, int32 mipmapLevel, PixelFormat pixelFormat) |
Sets an UAV texture. More... | |
void | _updateAutoProperties (void) |
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 (void) const |
IdString | getName (void) const |
size_t | getNumTexUnits (void) const |
const uint32 * | getNumThreadGroups (void) const |
uint32 | getNumThreadGroupsX (void) const |
uint32 | getNumThreadGroupsY (void) const |
uint32 | getNumThreadGroupsZ (void) const |
size_t | getNumUavUnits (void) const |
int32 | getProperty (IdString key, int32 defaultVal=0) const |
ShaderParams & | getShaderParams (IdString key) |
Gets a shader parameter with the given key. More... | |
const TexturePtr & | getTexture (uint8 slotIdx) const |
const uint32 * | getThreadsPerGroup (void) const |
uint32 | getThreadsPerGroupX (void) const |
uint32 | getThreadsPerGroupY (void) const |
uint32 | getThreadsPerGroupZ (void) const |
UavBufferPacked * | getUavBuffer (uint8 slotIdx) const |
const TexturePtr & | getUavTexture (uint8 slotIdx) const |
void | operator delete (void *ptr) |
void | operator delete (void *ptr, void *) |
void | operator delete (void *ptr, const char *, int, const char *) |
void | operator delete[] (void *ptr) |
void | operator delete[] (void *ptr, const char *, int, const char *) |
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 * | operator new (size_t sz, void *ptr) |
placement operator new More... | |
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
array operator new, with debug line info More... | |
void * | operator new[] (size_t sz) |
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 | 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 | 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, TexBufferPacked *texBuffer, size_t offset=0, size_t sizeBytes=0) |
Sets a texture buffer at the given slot ID. More... | |
void | setTexture (uint8 slotIdx, TexturePtr &texture, const HlmsSamplerblock *refParams=0) |
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... | |
Friends | |
class | HlmsCompute |
Ogre::HlmsComputeJob::HlmsComputeJob | ( | IdString | name, |
Hlms * | creator, | ||
const String & | sourceFilename, | ||
const StringVector & | includedPieceFiles | ||
) |
|
virtual |
void Ogre::HlmsComputeJob::_calculateNumThreadGroupsBasedOnSetting | ( | ) |
INTERNAL USE.
Calculates the number of thread groups as specified in setNumThreadGroupsBasedOn, overriding setNumThreadGroups.
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. |
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, |
UavBufferPacked * | uavBuffer, | ||
ResourceAccess::ResourceAccess | access, | ||
size_t | offset = 0 , |
||
size_t | sizeBytes = 0 |
||
) |
Sets an UAV buffer at the given slot ID.
slotIdx | See setNumUavUnits. The slot index to bind this UAV buffer. |
access | Access. Should match what the shader expects. Needed by Ogre to resolve memory barrier dependencies. |
uavBuffer | UAV buffer to bind. |
offset | 0-based offset. It is possible to bind a region of the buffer. Offset needs to be aligned. You can query the RS capabilities for the alignment, however 256 bytes is the maximum allowed alignment per the OpenGL specification, making it a safe bet to hardcode. |
sizeBytes | Size in bytes to bind the tex buffer. When zero, binds from offset until the end of the buffer. |
void Ogre::HlmsComputeJob::_setUavTexture | ( | uint8 | slotIdx, |
TexturePtr & | texture, | ||
int32 | textureArrayIndex, | ||
ResourceAccess::ResourceAccess | access, | ||
int32 | mipmapLevel, | ||
PixelFormat | pixelFormat | ||
) |
Sets an UAV texture.
slot | See setNumUavUnits. |
texture | |
textureArrayIndex | |
access | |
mipmapLevel | |
pixelFormat |
void Ogre::HlmsComputeJob::_updateAutoProperties | ( | void | ) |
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 |
|
inline |
|
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.
const TexturePtr& Ogre::HlmsComputeJob::getTexture | ( | uint8 | slotIdx | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
UavBufferPacked* Ogre::HlmsComputeJob::getUavBuffer | ( | uint8 | slotIdx | ) | const |
const TexturePtr& Ogre::HlmsComputeJob::getUavTexture | ( | uint8 | slotIdx | ) | const |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
operator new, with debug line info
|
inlineinherited |
|
inlineinherited |
placement operator new
|
inlineinherited |
array operator new, with debug line info
|
inlineinherited |
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::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::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 () 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 ( pieceName )pieceContent 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. |
refParams | We'll create (or retrieve an existing) samplerblock based on the input parameters. |
void Ogre::HlmsComputeJob::setTexBuffer | ( | uint8 | slotIdx, |
TexBufferPacked * | texBuffer, | ||
size_t | offset = 0 , |
||
size_t | sizeBytes = 0 |
||
) |
Sets a texture buffer at the given slot ID.
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 |
texBuffer | Texture buffer to bind. |
offset | 0-based offset. It is possible to bind a region of the buffer. Offset needs to be aligned. You can query the RS capabilities for the alignment, however 256 bytes is the maximum allowed alignment per the OpenGL specification, making it a safe bet to hardcode. |
sizeBytes | Size in bytes to bind the tex buffer. When zero, binds from offset until the end of the buffer. |
void Ogre::HlmsComputeJob::setTexture | ( | uint8 | slotIdx, |
TexturePtr & | texture, | ||
const HlmsSamplerblock * | refParams = 0 |
||
) |
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 |
texBuffer | Texture buffer to bind. |
texture | Texture to bind. |
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) |
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 () function. These values are passed to the template as: threads_per_group_x threads_per_group_y threads_per_group_z
|
friend |