CSCI441 OpenGL Library 5.13.0
CS@Mines CSCI441 Computer Graphics Course Library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CSCI441::ComputeShaderProgram Class Referencefinal

Handles registration and compilation of Compute Shaders. More...

#include <ComputeShaderProgram.hpp>

Inheritance diagram for CSCI441::ComputeShaderProgram:
CSCI441::ShaderProgram

Public Member Functions

 ComputeShaderProgram (const char *computeShaderFilename)
 Creates a Compute Shader Program.
 
 ~ComputeShaderProgram () override=default
 Clean up memory associated with the Compute Shader Program.
 
 ComputeShaderProgram (const ComputeShaderProgram &)=delete
 do not allow shader programs to be copied
 
ComputeShaderProgramoperator= (const ComputeShaderProgram &)=delete
 do not allow shader programs to be copied
 
 ComputeShaderProgram (ComputeShaderProgram &&) noexcept=default
 construct a new compute shader program by moving an existing computer shader program
 
ComputeShaderProgramoperator= (ComputeShaderProgram &&) noexcept=default
 assign this compute shader program by moving an existing computer shader program
 
void dispatchWork (GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ)
 dispatches work to the Compute Shader on the GPU
 
- Public Member Functions inherited from CSCI441::ShaderProgram
 ShaderProgram (const char *vertexShaderFilename, const char *fragmentShaderFilename)
 Creates a Shader Program using a Vertex Shader and Fragment Shader.
 
 ShaderProgram (const char *vertexShaderFilename, const char *fragmentShaderFilename, bool isSeparable)
 Creates a Shader Program using a Vertex Shader and Fragment Shader.
 
 ShaderProgram (const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename)
 Creates a Shader Program using a Vertex Shader, Tessellation Shader, Geometry Shader, and Fragment Shader.
 
 ShaderProgram (const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, bool isSeparable)
 Creates a Shader Program using a Vertex Shader, Tessellation Shader, Geometry Shader, and Fragment Shader.
 
 ShaderProgram (const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *fragmentShaderFilename)
 Creates a Shader Program using a Vertex Shader, Tessellation Shader, and Fragment Shader.
 
 ShaderProgram (const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *fragmentShaderFilename, bool isSeparable)
 Creates a Shader Program using a Vertex Shader, Tessellation Shader, and Fragment Shader.
 
 ShaderProgram (const char *vertexShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename)
 Creates a Shader Program using a Vertex Shader, Geometry Shader, and Fragment Shader.
 
 ShaderProgram (const char *vertexShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, bool isSeparable)
 Creates a Shader Program using a Vertex Shader, Geometry Shader, and Fragment Shader.
 
 ShaderProgram (const char **shaderFilenames, bool vertexPresent, bool tessellationPresent, bool geometryPresent, bool fragmentPresent, bool isSeparable)
 Creates a Shader Program using any combination of shaders. Intended to be used to create separable programs but can be used as an alternative to the above overloaded constructors to explicitly state which shaders are present.
 
virtual ~ShaderProgram ()
 Clean up memory associated with the Shader Program.
 
 ShaderProgram (const ShaderProgram &)=delete
 do not allow shader programs to be copied
 
ShaderProgramoperator= (const ShaderProgram &)=delete
 do not allow shader programs to be copied
 
 ShaderProgram (ShaderProgram &&) noexcept
 create a shader program by moving another shader program
 
ShaderProgramoperator= (ShaderProgram &&) noexcept
 reassign this shader program by moving another shader program
 
virtual bool writeShaderProgramBinaryToFile (const char *BINARY_FILE_NAME) const final
 writes precompiled shader program binary to external file
 
virtual GLint getUniformLocation (const GLchar *uniformName) const final
 Returns the location of the given uniform in this shader program.
 
virtual GLint getUniformBlockIndex (const GLchar *uniformBlockName) const final
 Returns the index of the given uniform block in this shader program.
 
virtual GLint getUniformBlockSize (const GLchar *uniformBlockName) const final
 Returns the size of the given uniform block in this shader program.
 
virtual GLubyte * getUniformBlockBuffer (const GLchar *uniformBlockName) const final
 Returns an allocated buffer for the given uniform block in this shader program.
 
virtual GLint * getUniformBlockOffsets (const GLchar *uniformBlockName) const final
 Returns an array of offsets into the buffer for the given uniform block in this shader program.
 
virtual GLint * getUniformBlockOffsets (const GLchar *uniformBlockName, const GLchar *names[]) const final
 Returns an array of offsets into the buffer for the given uniform block and names in this shader program.
 
virtual GLint * getUniformBlockOffsets (GLint uniformBlockIndex) const final
 Returns an array of offsets into the buffer for the given uniform block in this shader program.
 
virtual GLint * getUniformBlockOffsets (GLint uniformBlockIndex, const GLchar *names[]) const final
 Returns an array of offsets into the buffer for the given uniform block and names in this shader program.
 
virtual void setUniformBlockBinding (const GLchar *uniformBlockName, GLuint binding) const final
 Set the binding point for the given uniform block in this shader program.
 
virtual GLint getAttributeLocation (const GLchar *attributeName) const final
 Returns the location of the given attribute in this shader program.
 
virtual GLuint getSubroutineIndex (GLenum shaderStage, const GLchar *subroutineName) const final
 Returns the index of the given subroutine for a shader stage in this shader program.
 
virtual GLint getSubroutineUniformLocation (GLenum shaderStage, const GLchar *subroutineName) const final
 Returns the uniform location within the subroutine array for a given subroutine.
 
virtual void setSubroutineIndices (GLenum shaderStage, GLsizei numIndices, const GLuint *indices) final
 Sets the subroutines to use for a given shader stage.
 
virtual GLint getImageBinding (const GLchar *imageName) const final
 Returns the binding point for the corresponding image uniform.
 
virtual GLint getShaderStorageBlockBinding (const GLchar *ssboName) const final
 Returns the binding point for the corresponding shader storage block.
 
virtual GLint getAtomicCounterBufferBinding (const GLchar *atomicName) const final
 Returns the binding point for the corresponding atomic counter buffer.
 
virtual GLint getAtomicCounterBufferOffset (const GLchar *atomicName) const final
 Returns the offset into the buffer for the corresponding atomic counter buffer.
 
virtual GLint getAtomicCounterBufferSize (const GLchar *atomicName) const final
 Returns the full buffer size for the corresponding atomic counter buffer.
 
virtual GLuint getNumUniforms () const final
 Returns the number of active uniforms in this shader program.
 
virtual GLuint getNumUniformBlocks () const final
 Returns the number of active uniform blocks in this shader program.
 
virtual GLuint getNumAttributes () const final
 Returns the number of active attributes in this shader program.
 
virtual GLuint getShaderProgramHandle () const final
 Returns the handle for this shader program.
 
virtual void useProgram () const final
 Sets the Shader Program to be active.
 
virtual void setProgramUniform (const GLchar *uniformName, GLfloat v0) const final
 sets the program uniform consisting of one float
 
virtual void setProgramUniform (const GLchar *uniformName, GLint v0) const final
 sets the program uniform consisting of one integer
 
virtual void setProgramUniform (const GLchar *uniformName, GLuint v0) const final
 sets the program uniform consisting of one unsigned integer
 
virtual void setProgramUniform (const GLchar *uniformName, glm::mat2 mtx) const final
 sets the program uniform consisting of one 2x2 matrix
 
virtual void setProgramUniform (const GLchar *uniformName, glm::mat3 mtx) const final
 sets the program uniform consisting of one 3x3 matrix
 
virtual void setProgramUniform (const GLchar *uniformName, glm::mat4 mtx) const final
 sets the program uniform consisting of one 4x4 matrix
 
virtual void setProgramUniform (const GLchar *uniformName, glm::mat2x3 mtx) const final
 sets the program uniform consisting of one 2x3 matrix
 
virtual void setProgramUniform (const GLchar *uniformName, glm::mat3x2 mtx) const final
 sets the program uniform consisting of one 3x2 matrix
 
virtual void setProgramUniform (const GLchar *uniformName, glm::mat2x4 mtx) const final
 sets the program uniform consisting of one 2x4 matrix
 
virtual void setProgramUniform (const GLchar *uniformName, glm::mat4x2 mtx) const final
 sets the program uniform consisting of one 4x2 matrix
 
virtual void setProgramUniform (const GLchar *uniformName, glm::mat3x4 mtx) const final
 sets the program uniform consisting of one 3x4 matrix
 
virtual void setProgramUniform (const GLchar *uniformName, glm::mat4x3 mtx) const final
 sets the program uniform consisting of one 4x3 matrix
 
virtual void setProgramUniform (const GLchar *uniformName, GLfloat v0, GLfloat v1) const final
 sets the program uniform consisting of two floats
 
virtual void setProgramUniform (const GLchar *uniformName, GLint v0, GLint v1) const final
 sets the program uniform consisting of two integers
 
virtual void setProgramUniform (const GLchar *uniformName, GLuint v0, GLuint v1) const final
 sets the program uniform consisting of two unsigned integers
 
virtual void setProgramUniform (const GLchar *uniformName, GLfloat v0, GLfloat v1, GLfloat v2) const final
 sets the program uniform consisting of three floats
 
virtual void setProgramUniform (const GLchar *uniformName, GLint v0, GLint v1, GLint v2) const final
 sets the program uniform consisting of three integers
 
virtual void setProgramUniform (const GLchar *uniformName, GLuint v0, GLuint v1, GLuint v2) const final
 sets the program uniform consisting of three unsigned integers
 
virtual void setProgramUniform (const GLchar *uniformName, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const final
 sets the program uniform consisting of four floats
 
virtual void setProgramUniform (const GLchar *uniformName, GLint v0, GLint v1, GLint v2, GLint v3) const final
 sets the program uniform consisting of four integers
 
virtual void setProgramUniform (const GLchar *uniformName, GLuint v0, GLuint v1, GLuint v2, GLuint v3) const final
 sets the program uniform consisting of four unsigned integers
 
virtual void setProgramUniform (const GLchar *uniformName, glm::vec2 value) const final
 sets the program uniform consisting of two floats
 
virtual void setProgramUniform (const GLchar *uniformName, glm::ivec2 value) const final
 sets the program uniform consisting of two integers
 
virtual void setProgramUniform (const GLchar *uniformName, glm::uvec2 value) const final
 sets the program uniform consisting of two unsigned integers
 
virtual void setProgramUniform (const GLchar *uniformName, glm::vec3 value) const final
 sets the program uniform consisting of three floats
 
virtual void setProgramUniform (const GLchar *uniformName, glm::ivec3 value) const final
 sets the program uniform consisting of three integers
 
virtual void setProgramUniform (const GLchar *uniformName, glm::uvec3 value) const final
 sets the program uniform consisting of three unsigned integers
 
virtual void setProgramUniform (const GLchar *uniformName, glm::vec4 value) const final
 sets the program uniform consisting of four floats
 
virtual void setProgramUniform (const GLchar *uniformName, glm::ivec4 value) const final
 sets the program uniform consisting of four integers
 
virtual void setProgramUniform (const GLchar *uniformName, glm::uvec4 value) const final
 sets the program uniform consisting of four unsigned integers
 
virtual void setProgramUniform (const GLchar *uniformName, GLuint dim, GLsizei count, const GLfloat *value) const final
 sets the program uniform consisting of floats
 
virtual void setProgramUniform (const GLchar *uniformName, GLuint dim, GLsizei count, const GLint *value) const final
 sets the program uniform consisting of integers
 
virtual void setProgramUniform (const GLchar *uniformName, GLuint dim, GLsizei count, const GLuint *value) const final
 sets the program uniform consisting of unsigned integers
 
virtual void setProgramUniform (GLint uniformLocation, GLfloat v0) const final
 sets the program uniform consisting of one float
 
virtual void setProgramUniform (GLint uniformLocation, GLint v0) const final
 sets the program uniform consisting of one integer
 
virtual void setProgramUniform (GLint uniformLocation, GLuint v0) const final
 sets the program uniform consisting of one unsigned integer
 
virtual void setProgramUniform (GLint uniformLocation, glm::mat2 mtx) const final
 sets the program uniform consisting of one 2x2 matrix
 
virtual void setProgramUniform (GLint uniformLocation, glm::mat3 mtx) const final
 sets the program uniform consisting of one 3x3 matrix
 
virtual void setProgramUniform (GLint uniformLocation, glm::mat4 mtx) const final
 sets the program uniform consisting of one 4x4 matrix
 
virtual void setProgramUniform (GLint uniformLocation, glm::mat2x3 mtx) const final
 sets the program uniform consisting of one 2x3 matrix
 
virtual void setProgramUniform (GLint uniformLocation, glm::mat3x2 mtx) const final
 sets the program uniform consisting of one 3x2 matrix
 
virtual void setProgramUniform (GLint uniformLocation, glm::mat2x4 mtx) const final
 sets the program uniform consisting of one 2x4 matrix
 
virtual void setProgramUniform (GLint uniformLocation, glm::mat4x2 mtx) const final
 sets the program uniform consisting of one 4x2 matrix
 
virtual void setProgramUniform (GLint uniformLocation, glm::mat3x4 mtx) const final
 sets the program uniform consisting of one 3x4 matrix
 
virtual void setProgramUniform (GLint uniformLocation, glm::mat4x3 mtx) const final
 sets the program uniform consisting of one 4x3 matrix
 
virtual void setProgramUniform (GLint uniformLocation, GLfloat v0, GLfloat v1) const final
 sets the program uniform consisting of two floats
 
virtual void setProgramUniform (GLint uniformLocation, GLint v0, GLint v1) const final
 sets the program uniform consisting of two integers
 
virtual void setProgramUniform (GLint uniformLocation, GLuint v0, GLuint v1) const final
 sets the program uniform consisting of two unsigned integers
 
virtual void setProgramUniform (GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2) const final
 sets the program uniform consisting of three floats
 
virtual void setProgramUniform (GLint uniformLocation, GLint v0, GLint v1, GLint v2) const final
 sets the program uniform consisting of three integers
 
virtual void setProgramUniform (GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2) const final
 sets the program uniform consisting of three unsigned integers
 
virtual void setProgramUniform (GLint uniformLocation, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const final
 sets the program uniform consisting of four floats
 
virtual void setProgramUniform (GLint uniformLocation, GLint v0, GLint v1, GLint v2, GLint v3) const final
 sets the program uniform consisting of four integers
 
virtual void setProgramUniform (GLint uniformLocation, GLuint v0, GLuint v1, GLuint v2, GLuint v3) const final
 sets the program uniform consisting of four unsigned integers
 
virtual void setProgramUniform (GLint uniformLocation, glm::vec2 value) const final
 sets the program uniform consisting of two floats
 
virtual void setProgramUniform (GLint uniformLocation, glm::ivec2 value) const final
 sets the program uniform consisting of two integers
 
virtual void setProgramUniform (GLint uniformLocation, glm::uvec2 value) const final
 sets the program uniform consisting of two unsigned integers
 
virtual void setProgramUniform (GLint uniformLocation, glm::vec3 value) const final
 sets the program uniform consisting of three floats
 
virtual void setProgramUniform (GLint uniformLocation, glm::ivec3 value) const final
 sets the program uniform consisting of three integers
 
virtual void setProgramUniform (GLint uniformLocation, glm::uvec3 value) const final
 sets the program uniform consisting of three unsigned integers
 
virtual void setProgramUniform (GLint uniformLocation, glm::vec4 value) const final
 sets the program uniform consisting of four floats
 
virtual void setProgramUniform (GLint uniformLocation, glm::ivec4 value) const final
 sets the program uniform consisting of four integers
 
virtual void setProgramUniform (GLint uniformLocation, glm::uvec4 value) const final
 sets the program uniform consisting of four unsigned integers
 
virtual void setProgramUniform (GLint uniformLocation, GLuint dim, GLsizei count, const GLfloat *value) const final
 sets the program uniform consisting of floats
 
virtual void setProgramUniform (GLint uniformLocation, GLuint dim, GLsizei count, const GLint *value) const final
 sets the program uniform consisting of integers
 
virtual void setProgramUniform (GLint uniformLocation, GLuint dim, GLsizei count, const GLuint *value) const final
 sets the program uniform consisting of unsigned integers
 
virtual GLbitfield getProgramStages () const final
 returns a single value corresponding to which shader stages are present in this shader program
 

Additional Inherited Members

- Static Public Member Functions inherited from CSCI441::ShaderProgram
static void enableDebugMessages ()
 Enables debug messages from Shader Program functions.
 
static void disableDebugMessages ()
 Disables debug messages from Shader Program functions.
 
static ShaderProgramloadShaderProgramFromBinaryFile (const char *BINARY_FILE_NAME, GLenum format)
 loads precompiled shader program binary from external file
 
- Protected Member Functions inherited from CSCI441::ShaderProgram
 ShaderProgram ()
 creates an empty shader program object
 
virtual bool mRegisterShaderProgram (const char *vertexShaderFilename, const char *tessellationControlShaderFilename, const char *tessellationEvaluationShaderFilename, const char *geometryShaderFilename, const char *fragmentShaderFilename, bool isSeparable) final
 registers a shader program with the GPU
 
- Protected Attributes inherited from CSCI441::ShaderProgram
GLuint mVertexShaderHandle
 handle to the vertex shader stage
 
GLuint mTessellationControlShaderHandle
 handle to the tessellation control shader stage
 
GLuint mTessellationEvaluationShaderHandle
 handle to the tessellation evaluation shader stage
 
GLuint mGeometryShaderHandle
 handle to the geometry shader stage
 
GLuint mFragmentShaderHandle
 handle to the fragment shader stage
 
GLuint mShaderProgramHandle
 handle to the shader program
 
std::map< std::string, GLint > * mpUniformLocationsMap
 caches locations of uniform names within shader program
 
std::map< std::string, GLint > * mpAttributeLocationsMap
 caches locations of attribute names within shader program
 
- Static Protected Attributes inherited from CSCI441::ShaderProgram
static bool sDEBUG = true
 if DEBUG information should be printed or not
 

Detailed Description

Handles registration and compilation of Compute Shaders.

Constructor & Destructor Documentation

◆ ComputeShaderProgram() [1/2]

CSCI441::ComputeShaderProgram::ComputeShaderProgram ( const char *  computeShaderFilename)
inlineexplicit

Creates a Compute Shader Program.

Parameters
computeShaderFilenamename of the file corresponding to the compute shader

◆ ComputeShaderProgram() [2/2]

CSCI441::ComputeShaderProgram::ComputeShaderProgram ( ComputeShaderProgram &&  )
defaultnoexcept

construct a new compute shader program by moving an existing computer shader program

Note
uses default implementation which is to call the parent CSCI441::ShaderProgram implementation

Member Function Documentation

◆ dispatchWork()

void CSCI441::ComputeShaderProgram::dispatchWork ( GLuint  numGroupsX = 1,
GLuint  numGroupsY = 1,
GLuint  numGroupsZ = 1 
)
inline

dispatches work to the Compute Shader on the GPU

Parameters
numGroupsXnumber of work groups in X dimension (defaults to 1)
numGroupsYnumber of work groups in Y dimension (defaults to 1)
numGroupsZnumber of work groups in Z dimension (defaults to 1)
Note
call after calling ShaderProgram::useProgram()

◆ operator=()

ComputeShaderProgram & CSCI441::ComputeShaderProgram::operator= ( ComputeShaderProgram &&  )
defaultnoexcept

assign this compute shader program by moving an existing computer shader program

Returns
our newly assigned computer shader program
Note
uses default implementation which is to call the parent CSCI441::ShaderProgram implementation

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