Beatmup
Beatmup::GL::ComputeProgram Class Reference

GLSL compute program. More...

#include <compute_program.h>

Inheritance diagram for Beatmup::GL::ComputeProgram:
Beatmup::GL::AbstractProgram Beatmup::GL::RecycleBin::Item

Classes

class  Shader
 

Public Member Functions

 ComputeProgram (const GraphicPipeline &gpu)
 
 ComputeProgram (const GraphicPipeline &gpu, const char *source)
 
void make (const GraphicPipeline &gpu, const char *source)
 
void make (const GraphicPipeline &gpu, const std::string &source)
 
void dispatch (const GraphicPipeline &gpu, msize w, msize h, msize d) const
 
- Public Member Functions inherited from Beatmup::GL::AbstractProgram
 AbstractProgram (const GraphicPipeline &gpu)
 
 ~AbstractProgram ()
 
void enable (const GraphicPipeline &gpu)
 
ChunkgetBinary () const
 
void loadBinary (const Chunk &binary)
 
handle_t findUniformLocation (const char *name)
 Retrieves uniform variable location by its name. More...
 
handle_t findAttribLocation (const char *name)
 Retrieves attribute location by its name. More...
 
handle_t getUniformLocation (const std::string &name)
 Retrieves uniform variable location by its name. More...
 
handle_t getAttribLocation (const std::string &name)
 Retrieves attribute location by its name. More...
 
void setInteger (const std::string &name, const int value, bool safe=false)
 Assigns a value to a specific integer variable in the program. More...
 
void setUnsignedInteger (const std::string &name, const unsigned int value, bool safe=false)
 
void setFloat (const std::string &name, const float value, bool safe=false)
 Assigns a value to a specific floating point variable in the program. More...
 
void setVector2 (const std::string &name, const float x, const float y)
 
void setVector3 (const std::string &name, const float x, const float y, const float z)
 
void setVector4 (const std::string &name, const float x, const float y, const float z, const float w)
 
void setVector4 (const std::string &name, const color4i &color, const float outRange=1.0f)
 
void setMatrix2 (const std::string &name, const Matrix2 &mat)
 
void setMatrix3 (const std::string &name, const Matrix2 &mat, const Point &pos)
 
void setMatrix3 (const std::string &name, const AffineMapping &mapping)
 
void setIntegerArray (const std::string &name, const int *values, const int length)
 
void setIntegerArray (const std::string &name, const int firstValue, const int length)
 
void setFloatArray (const std::string &name, const float *values, const int length)
 
void setVec2Array (const std::string &name, const float *xy, const int length)
 
void setVec4Array (const std::string &name, const float *xyzw, const int length)
 
void bindSampler (GraphicPipeline &gpu, GL::TextureHandler &image, const char *uniformId, TextureParam param)
 
void bindImage (GraphicPipeline &gpu, GL::TextureHandler &image, const char *uniformId, bool read, bool write)
 
void bindAtomicCounter (GraphicPipeline &gpu, AtomicCounter &counter, int unit)
 
- Public Member Functions inherited from Beatmup::GL::RecycleBin::Item
 Item ()
 
virtual ~Item ()
 

Private Member Functions

void link (const GraphicPipeline &gpu)
 

Private Attributes

Shader shader
 

Additional Inherited Members

- Protected Member Functions inherited from Beatmup::GL::AbstractProgram
handle_t getHandle () const
 
void assertLinked () const
 
void clearCaches ()
 

Detailed Description

GLSL compute program.

The compute shader is managed inside the class.

Definition at line 31 of file compute_program.h.

Constructor & Destructor Documentation

◆ ComputeProgram() [1/2]

ComputeProgram::ComputeProgram ( const GraphicPipeline gpu)

Definition at line 29 of file compute_program.cpp.

29 : AbstractProgram(gpu), shader(gpu) {}
AbstractProgram(const AbstractProgram &)=delete
disabling copying constructor

◆ ComputeProgram() [2/2]

ComputeProgram::ComputeProgram ( const GraphicPipeline gpu,
const char *  source 
)

Definition at line 31 of file compute_program.cpp.

31  : ComputeProgram(gpu) {
32  make(gpu, source);
33 }
void make(const GraphicPipeline &gpu, const char *source)
ComputeProgram(const GraphicPipeline &gpu)

Member Function Documentation

◆ link()

void ComputeProgram::link ( const GraphicPipeline gpu)
private

Definition at line 35 of file compute_program.cpp.

35  {
36  glAttachShader(getHandle(), shader.getHandle());
37  glLinkProgram(getHandle());
38  assertLinked();
39 }
handle_t getHandle() const
Definition: program.h:142
handle_t getHandle() const
Definition: program.h:83

◆ make() [1/2]

void ComputeProgram::make ( const GraphicPipeline gpu,
const char *  source 
)

Definition at line 42 of file compute_program.cpp.

42  {
43  shader.compile(gpu, source);
44  link(gpu);
45 }
void link(const GraphicPipeline &gpu)
void compile(const GraphicPipeline &gpu, const char *source)
Definition: program.cpp:50

◆ make() [2/2]

void ComputeProgram::make ( const GraphicPipeline gpu,
const std::string &  source 
)

Definition at line 48 of file compute_program.cpp.

48  {
49  make(gpu, source.c_str());
50 }

◆ dispatch()

void ComputeProgram::dispatch ( const GraphicPipeline gpu,
msize  w,
msize  h,
msize  d 
) const

Definition at line 53 of file compute_program.cpp.

53  {
54  glDispatchCompute(w, h, d);
55 #ifdef BEATMUP_DEBUG
56  GL::GLException::check("dispatching compute");
57 #endif
58  glMemoryBarrier(GL_ALL_BARRIER_BITS);
59 #ifdef BEATMUP_DEBUG
60  GL::GLException::check("memory barrier");
61 #endif
62  glFinish(); // fixme: this helps my Radeon not to crash
63 }
static void check(const std::string &info)
Definition: bgl.h:62
jlong h
jlong jstring jint jint jint jint w

Member Data Documentation

◆ shader

Shader Beatmup::GL::ComputeProgram::shader
private

Definition at line 39 of file compute_program.h.


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