xoreos  0.0.5
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Graphics::Shader::ShaderManager Class Reference

The shader manager. More...

#include <shader.h>

Inheritance diagram for Graphics::Shader::ShaderManager:
Inheritance graph
[legend]
Collaboration diagram for Graphics::Shader::ShaderManager:
Collaboration graph
[legend]

Public Member Functions

 ShaderManager ()
 
 ~ShaderManager ()
 
void init ()
 Initialise shader management, including default shader set creation. More...
 
void deinit ()
 Deinitialise shader subsystem. More...
 
ShaderObjectgetShaderObject (const Common::UString &name, ShaderType type)
 
ShaderObjectgetShaderObject (const Common::UString &name, const Common::UString &source, ShaderType type)
 
void bindShaderVariable (ShaderObject::ShaderObjectVariable &var, GLint loc, const void *data)
 
void bindShaderInstance (ShaderProgram *program, const void **vertexVariables, const void **fragmentVariables)
 
ShaderProgramgetShaderProgram (ShaderObject *vertexObject, ShaderObject *fragmentObject)
 
ShaderProgramregisterShaderProgram (ShaderObject *vertexObject, ShaderObject *fragmentObject)
 
void genShaderVariableList (ShaderObject *obj, std::vector< ShaderObject::ShaderObjectVariable > &vars)
 
ShaderVariableType shaderstringToEnum (const Common::UString &stype)
 
void genGLShader (ShaderObject *object)
 Generate GL ids for, and compile a shader object. More...
 
void genGLProgram (ShaderProgram *program)
 Generate GL id for, and link, a shader program. More...
 

Private Member Functions

void registerShaderAttachment (GLuint progid, ShaderObject *obj)
 Recursively attaches shader objects to a given program. More...
 
void parseShaderVariables (const Common::UString &shaderString, std::vector< ShaderObject::ShaderObjectVariable > &variableList)
 Parses a given string, representing a GLSL shader, and extracts uniform variable information from it. More...
 

Private Attributes

uint32 _counterVID
 
uint32 _counterFID
 
std::map< Common::UString, Shader::ShaderObject * > _shaderObjectMap
 
std::vector< Shader::ShaderProgram * > _shaderProgramArray
 
Common::Mutex _shaderMutex
 
Common::Mutex _programMutex
 

Additional Inherited Members

- Static Public Member Functions inherited from Common::Singleton< ShaderManager >
static ShaderManager & instance ()
 
static void destroy ()
 
- Protected Types inherited from Common::Singleton< ShaderManager >
typedef ShaderManager SingletonBaseType
 
- Protected Member Functions inherited from Common::Singleton< ShaderManager >
 Singleton ()
 
virtual ~Singleton ()
 

Detailed Description

The shader manager.

Definition at line 240 of file shader.h.

Constructor & Destructor Documentation

◆ ShaderManager()

Graphics::Shader::ShaderManager::ShaderManager ( )

Definition at line 79 of file shader.cpp.

◆ ~ShaderManager()

Graphics::Shader::ShaderManager::~ShaderManager ( )

Definition at line 82 of file shader.cpp.

References deinit().

Here is the call graph for this function:

Member Function Documentation

◆ bindShaderInstance()

void Graphics::Shader::ShaderManager::bindShaderInstance ( ShaderProgram program,
const void **  vertexVariables,
const void **  fragmentVariables 
)

◆ bindShaderVariable()

void Graphics::Shader::ShaderManager::bindShaderVariable ( ShaderObject::ShaderObjectVariable var,
GLint  loc,
const void *  data 
)

Definition at line 228 of file shader.cpp.

References Graphics::Shader::ShaderObject::ShaderObjectVariable::count, Graphics::Shader::SHADER_FLOAT, Graphics::Shader::SHADER_INT, Graphics::Shader::SHADER_ISAMPLER1D, Graphics::Shader::SHADER_ISAMPLER1DARRAY, Graphics::Shader::SHADER_ISAMPLER2D, Graphics::Shader::SHADER_ISAMPLER2DARRAY, Graphics::Shader::SHADER_ISAMPLER3D, Graphics::Shader::SHADER_ISAMPLERCUBE, Graphics::Shader::SHADER_IVEC2, Graphics::Shader::SHADER_IVEC3, Graphics::Shader::SHADER_IVEC4, Graphics::Shader::SHADER_MAT2, Graphics::Shader::SHADER_MAT3, Graphics::Shader::SHADER_MAT4, Graphics::Shader::SHADER_SAMPLER1D, Graphics::Shader::SHADER_SAMPLER1DARRAY, Graphics::Shader::SHADER_SAMPLER1DARRAYSHADOW, Graphics::Shader::SHADER_SAMPLER1DSHADOW, Graphics::Shader::SHADER_SAMPLER2D, Graphics::Shader::SHADER_SAMPLER2DARRAY, Graphics::Shader::SHADER_SAMPLER2DARRAYSHADOW, Graphics::Shader::SHADER_SAMPLER2DSHADOW, Graphics::Shader::SHADER_SAMPLER3D, Graphics::Shader::SHADER_SAMPLERBUFFER, Graphics::Shader::SHADER_SAMPLERCUBE, Graphics::Shader::SHADER_UNIFORM_BUFFER, Graphics::Shader::SHADER_USAMPLER1D, Graphics::Shader::SHADER_USAMPLER1DARRAY, Graphics::Shader::SHADER_USAMPLER2D, Graphics::Shader::SHADER_USAMPLER2DARRAY, Graphics::Shader::SHADER_USAMPLER3D, Graphics::Shader::SHADER_USAMPLERCUBE, Graphics::Shader::SHADER_VEC2, Graphics::Shader::SHADER_VEC3, Graphics::Shader::SHADER_VEC4, and Graphics::Shader::ShaderObject::ShaderObjectVariable::type.

Referenced by bindShaderInstance().

Here is the caller graph for this function:

◆ deinit()

void Graphics::Shader::ShaderManager::deinit ( )

Deinitialise shader subsystem.

Definition at line 165 of file shader.cpp.

References _shaderObjectMap, _shaderProgramArray, and status().

Referenced by ~ShaderManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ genGLProgram()

void Graphics::Shader::ShaderManager::genGLProgram ( ShaderProgram program)

◆ genGLShader()

void Graphics::Shader::ShaderManager::genGLShader ( ShaderObject object)

Generate GL ids for, and compile a shader object.

Definition at line 544 of file shader.cpp.

References error(), Graphics::Shader::ShaderObject::glid, Graphics::Shader::SHADER_VERTEX, and Graphics::Shader::ShaderObject::type.

Referenced by genGLProgram().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ genShaderVariableList()

void Graphics::Shader::ShaderManager::genShaderVariableList ( ShaderObject obj,
std::vector< ShaderObject::ShaderObjectVariable > &  vars 
)

Definition at line 408 of file shader.cpp.

References Graphics::Shader::ShaderObject::subObjects, and Graphics::Shader::ShaderObject::variablesSelf.

Referenced by getShaderObject().

Here is the caller graph for this function:

◆ getShaderObject() [1/2]

ShaderObject * Graphics::Shader::ShaderManager::getShaderObject ( const Common::UString name,
ShaderType  type 
)

Definition at line 184 of file shader.cpp.

References _shaderObjectMap.

◆ getShaderObject() [2/2]

ShaderObject * Graphics::Shader::ShaderManager::getShaderObject ( const Common::UString name,
const Common::UString source,
ShaderType  type 
)

◆ getShaderProgram()

ShaderProgram * Graphics::Shader::ShaderManager::getShaderProgram ( ShaderObject vertexObject,
ShaderObject fragmentObject 
)

Definition at line 335 of file shader.cpp.

References _programMutex, _shaderProgramArray, Graphics::Shader::ShaderObject::id, Common::Mutex::lock(), and Common::Mutex::unlock().

Referenced by registerShaderProgram().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

void Graphics::Shader::ShaderManager::init ( )

◆ parseShaderVariables()

void Graphics::Shader::ShaderManager::parseShaderVariables ( const Common::UString shaderString,
std::vector< ShaderObject::ShaderObjectVariable > &  variableList 
)
private

Parses a given string, representing a GLSL shader, and extracts uniform variable information from it.

Definition at line 438 of file shader.cpp.

References Common::UString::c_str(), Graphics::Shader::SHADER_INVALID, and shaderstringToEnum().

Referenced by getShaderObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerShaderAttachment()

void Graphics::Shader::ShaderManager::registerShaderAttachment ( GLuint  progid,
ShaderObject obj 
)
private

Recursively attaches shader objects to a given program.

Called prior to linking.

Definition at line 366 of file shader.cpp.

References Graphics::Shader::ShaderObject::glid, and Graphics::Shader::ShaderObject::subObjects.

Referenced by genGLProgram().

Here is the caller graph for this function:

◆ registerShaderProgram()

ShaderProgram * Graphics::Shader::ShaderManager::registerShaderProgram ( ShaderObject vertexObject,
ShaderObject fragmentObject 
)

◆ shaderstringToEnum()

ShaderVariableType Graphics::Shader::ShaderManager::shaderstringToEnum ( const Common::UString stype)

Definition at line 701 of file shader.cpp.

References Graphics::Shader::SHADER_INVALID, and Graphics::Shader::shaderTypeChararray.

Referenced by parseShaderVariables().

Here is the caller graph for this function:

Member Data Documentation

◆ _counterFID

uint32 Graphics::Shader::ShaderManager::_counterFID
private

Definition at line 280 of file shader.h.

Referenced by getShaderObject().

◆ _counterVID

uint32 Graphics::Shader::ShaderManager::_counterVID
private

Definition at line 279 of file shader.h.

Referenced by getShaderObject().

◆ _programMutex

Common::Mutex Graphics::Shader::ShaderManager::_programMutex
private

Definition at line 285 of file shader.h.

Referenced by getShaderProgram(), and registerShaderProgram().

◆ _shaderMutex

Common::Mutex Graphics::Shader::ShaderManager::_shaderMutex
private

Definition at line 284 of file shader.h.

Referenced by getShaderObject().

◆ _shaderObjectMap

std::map<Common::UString, Shader::ShaderObject *> Graphics::Shader::ShaderManager::_shaderObjectMap
private

Definition at line 281 of file shader.h.

Referenced by deinit(), and getShaderObject().

◆ _shaderProgramArray

std::vector<Shader::ShaderProgram *> Graphics::Shader::ShaderManager::_shaderProgramArray
private

Definition at line 282 of file shader.h.

Referenced by deinit(), getShaderProgram(), and registerShaderProgram().


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