Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
ProgramState Class Reference

A program state object can create or reuse a program. More...

#include <ProgramState.h>

Inherits Object.

Classes

class  AutoBindingResolver
 An abstract base class that can be extended to support custom material auto bindings. More...

Public Member Functions

 ProgramState (Program *program)
virtual ~ProgramState ()
 destructor
ProgramState * clone () const
 Creates a deep copy of the current ProgramState.
rhi::Program * getProgram () const
 Get the program object.
void setUniform (const rhi::UniformLocation &uniformLocation, const void *data, size_t size)
 Specify the value of a uniform variable for the current program state object.
bool setUniformBlock (ShaderStage stage, std::string_view blockName, const void *data, size_t size)
 Writes an active uniform block selected by shader stage and source block name.
rhi::UniformLocation getUniformLocation (std::string_view name) const
 Get uniform location in given uniform name.
rhi::UniformLocation getUniformLocation (rhi::Uniform kind) const
 Get uniform location in a more efficient way by the given built-in uniform name.
void setCallbackUniform (const rhi::UniformLocation &, const UniformCallback &)
 A callback to update unifrom.
const std::unordered_map< UniformLocation, UniformCallback, UniformLocationHash > & getCallbackUniforms () const
 Get the uniform callback function.
void setTexture (rhi::Texture *texture)
 Set texture.
void setTextureArray (const rhi::UniformLocation &uniformLocation, std::span< TextureBinding > units)
 Set texture array in shader 'uniform sampler2D xxx[4];' unlikely sampoler2DArray, the array will use multi texture units.
const std::unordered_map< int, TextureBindingSet > & getTextureBindingSets () const
 Get vertex texture informations.
void setParameterAutoBinding (std::string_view uniformName, std::string_view autoBinding)
 Sets a uniform auto-binding.
Public Member Functions inherited from Object
void retain ()
 Retains the ownership.
void release ()
 Releases the ownership immediately.
Object * autorelease ()
 Releases the ownership sometime soon automatically.
unsigned int getReferenceCount () const
 Returns the Object's current reference count.
uint64_t getObjectID () const noexcept
 Returns the process-local diagnostic identifier assigned at construction.
virtual ~Object ()
 Destructor.

Detailed Description

A program state object can create or reuse a program.

Each program state object keep its own unifroms and textures data.

Constructor & Destructor Documentation

◆ ProgramState()

ProgramState ( Program * program)
Parameters
programSpecifies the program.

Member Function Documentation

◆ clone()

ProgramState * clone ( ) const

Creates a deep copy of the current ProgramState.

Unlike other clone methods, this function does not use autorelease. The returned object is allocated on the heap, and the caller is responsible for managing its lifetime and explicitly releasing it when no longer needed.

◆ setUniform()

void setUniform ( const rhi::UniformLocation & uniformLocation,
const void * data,
size_t size )

Specify the value of a uniform variable for the current program state object.

Parameters
uniformLocationSpecifies the uniform location.
dataSpecifies the new values to be used for the specified uniform variable.
sizeSpecifies the uniform data size.

◆ getUniformLocation() [1/2]

rhi::UniformLocation getUniformLocation ( std::string_view name) const

Get uniform location in given uniform name.

Parameters
uniformSpecifies the uniform name.
Returns
Uniform location.
See also
rhi::UniformLocation getUniformLocation(rhi::Uniform name) const

◆ getUniformLocation() [2/2]

rhi::UniformLocation getUniformLocation ( rhi::Uniform kind) const

Get uniform location in a more efficient way by the given built-in uniform name.

Parameters
uniformSpecifies the engin built-in uniform name.
Returns
Uniform location.
See also
rhi::UniformLocation getUniformLocation(rhi::Uniform kind) const

◆ setCallbackUniform()

void setCallbackUniform ( const rhi::UniformLocation & ,
const UniformCallback &  )

A callback to update unifrom.

Parameters
uniformLocationSpecifies the uniform location.
unifromCallbackSpecifies a callback function to update the uniform.

◆ getCallbackUniforms()

const std::unordered_map< UniformLocation, UniformCallback, UniformLocationHash > & getCallbackUniforms ( ) const
inline

Get the uniform callback function.

Returns
Uniform callback funciton.

◆ setTexture()

void setTexture ( rhi::Texture * texture)

Set texture.

Parameters
uniformLocationSpecifies texture location.
textureSpecifies a pointer to backend texture.

◆ getTextureBindingSets()

const std::unordered_map< int, TextureBindingSet > & getTextureBindingSets ( ) const
inline

Get vertex texture informations.

Returns
Vertex texture informations. Key is the texture location, Value store the texture informations

◆ setParameterAutoBinding()

void setParameterAutoBinding ( std::string_view uniformName,
std::string_view autoBinding )

Sets a uniform auto-binding.

This method parses the passed in autoBinding string and attempts to convert it to an enumeration value. If it matches to one of the predefined strings, it will create a callback to get the correct value at runtime.

Parameters
uniformNameThe name of the material parameter to store an auto-binding for.
autoBindingA string matching one of the built-in AutoBinding enum constants.

The documentation for this class was generated from the following file:
  • ProgramState.h