SenOGL  0.2
Library aiming to ease the use of OpenGL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
ComputeShader Class Reference

Compute Shader. More...

#include <ComputeShader.hpp>

Inheritance diagram for ComputeShader:
Shader OpenGLObject

Classes

struct  WorkgroupSize
 Structure containing size information about Compute shader workgroups. More...
 

Public Types

enum  BarrierBit : GLbitfield {
  BarrierBit::VertexAttribArray = GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT, BarrierBit::ElementArrayBarrier = GL_ELEMENT_ARRAY_BARRIER_BIT, BarrierBit::Uniform = GL_UNIFORM_BARRIER_BIT, BarrierBit::TextureFetch = GL_TEXTURE_FETCH_BARRIER_BIT,
  BarrierBit::ShaderImageAccess = GL_SHADER_IMAGE_ACCESS_BARRIER_BIT, BarrierBit::Commande = GL_COMMAND_BARRIER_BIT, BarrierBit::PixelBuffer = GL_PIXEL_BUFFER_BARRIER_BIT, BarrierBit::TextureUpdate = GL_TEXTURE_UPDATE_BARRIER_BIT,
  BarrierBit::BufferUpdate = GL_BUFFER_UPDATE_BARRIER_BIT, BarrierBit::Framebuffer = GL_FRAMEBUFFER_BARRIER_BIT, BarrierBit::TransformFeedback = GL_TRANSFORM_FEEDBACK_BARRIER_BIT, BarrierBit::AtomicCounter = GL_ATOMIC_COUNTER_BARRIER_BIT,
  BarrierBit::ShaderStorage = GL_SHADER_STORAGE_BARRIER_BIT, BarrierBit::All = GL_ALL_BARRIER_BITS
}
 Barrier Bits. More...
 

Public Member Functions

 ComputeShader (bool standalone=true)
 Default constructor. More...
 
 ~ComputeShader ()
 Destructor. More...
 
void compile ()
 Compiles and, if set as standalone, links the associated Program. More...
 
void use () const
 Use the associated Program. More...
 
void compute (GLint x, GLint y=1, GLint z=1) const
 Starts the execution of the compute shader. More...
 
ProgramgetProgram ()
 
const ProgramgetProgram () const
 
const WorkgroupSizegetWorkgroupSize ()
 Note: Shader must be compiled and associated to a linked Program. More...
 
- Public Member Functions inherited from Shader
 Shader ()=default
 Default constructor. More...
 
virtual ~Shader ()
 Destructor. More...
 
virtual void init () override
 Generates a OpenGL object name to manage. More...
 
virtual void cleanup () override
 Deletes the managed OpenGL object. More...
 
void loadFromFile (const std::string &path)
 Loads the source for this shader from the file at path. More...
 
void reload ()
 Reloads shader from file. More...
 
void compile ()
 Compiles this shader. More...
 
bool isValid () const override
 
- Public Member Functions inherited from OpenGLObject
 OpenGLObject ()
 
 OpenGLObject (GLuint handle)
 Constructs a instance managing an existing OpenGL Object. More...
 
 OpenGLObject (const OpenGLObject &)=default
 
 OpenGLObject (OpenGLObject &&)=default
 
OpenGLObjectoperator= (const OpenGLObject &)=default
 
OpenGLObjectoperator= (OpenGLObject &&)=default
 
virtual ~OpenGLObject ()
 
GLuint getName () const
 Returns OpenGL name of the object. More...
 
void setName (GLuint n)
 Sets the OpenGL name of the object managed by this instance /!\ Use with caution ! (assignment operator is probably what you're looking for) More...
 
 operator bool () const
 Syntactic sugar for isValid(). More...
 

Static Public Member Functions

static void memoryBarrier (BarrierBit BF=BarrierBit::All)
 
static void memoryBarrierByRegion (BarrierBit BF=BarrierBit::All)
 
static void dispatchCompute (GLint x, GLint y=1, GLint z=1)
 Starts the execution of the curently 'bound' compute shader. More...
 

Friends

class Program
 

Additional Inherited Members

- Protected Attributes inherited from Shader
std::string _srcPath = ""
 Path to the last file read by loadFromFile. More...
 
bool _compiled = false
 Says if the shader have already been successfully compiled. More...
 
- Protected Attributes inherited from OpenGLObject
GLuint _handle
 OpenGL name of the managed object. More...
 

Detailed Description

Compute Shader.

This type of shader can hold a program and be used alone.

See also
Shader
Program

Member Enumeration Documentation

enum ComputeShader::BarrierBit : GLbitfield
strong

Barrier Bits.

See also
https://www.khronos.org/opengles/sdk/docs/man31/html/glMemoryBarrier.xhtml
Enumerator
VertexAttribArray 
ElementArrayBarrier 
Uniform 
TextureFetch 
ShaderImageAccess 
Commande 
PixelBuffer 
TextureUpdate 
BufferUpdate 
Framebuffer 
TransformFeedback 
AtomicCounter 
ShaderStorage 
All 

Constructor & Destructor Documentation

ComputeShader::ComputeShader ( bool  standalone = true)

Default constructor.

Parameters
standaloneIf true, attach the shader to a new dedicated program.
ComputeShader::~ComputeShader ( )

Destructor.

Member Function Documentation

void ComputeShader::compile ( )

Compiles and, if set as standalone, links the associated Program.

See also
Shader::compile()
void ComputeShader::compute ( GLint  x,
GLint  y = 1,
GLint  z = 1 
) const
inline

Starts the execution of the compute shader.

Parameters
xNumber of workgroups to start on the x 'axis'
yNumber of workgroups to start on the y 'axis'
zNumber of workgroups to start on the z 'axis'
void ComputeShader::dispatchCompute ( GLint  x,
GLint  y = 1,
GLint  z = 1 
)
inlinestatic

Starts the execution of the curently 'bound' compute shader.

Parameters
xNumber of workgroups to start on the x 'axis'
yNumber of workgroups to start on the y 'axis'
zNumber of workgroups to start on the z 'axis'
Program & ComputeShader::getProgram ( )
inline
Returns
Associated Program
See also
Program
const Program & ComputeShader::getProgram ( ) const
inline
Returns
Associated Program
See also
Program
const ComputeShader::WorkgroupSize & ComputeShader::getWorkgroupSize ( )

Note: Shader must be compiled and associated to a linked Program.

Returns
Workgroup sizes as specified in the compute shader.
See also
compile()
Program
void ComputeShader::memoryBarrier ( BarrierBit  BF = BarrierBit::All)
inlinestatic
Parameters
BFBitwise combinaison of any BarrierBit, or BarrierBit::All.
See also
glMemoryBarrier
void ComputeShader::memoryBarrierByRegion ( BarrierBit  BF = BarrierBit::All)
inlinestatic
Parameters
BFMust be a combinaison of BarrierBit::AtomicCounter, BarrierBit::Framebuffer, BarrierBit::ShaderImageAccess BarrierBit::ShaderStorage, BarrierBit::TextureFetch and BarrierBit::UniformBarrier. Or BarrierBit::All.
See also
glMemoryBarrier
void ComputeShader::use ( ) const

Use the associated Program.

See also
Program::use()

Friends And Related Function Documentation

friend class Program
friend

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