FastUIDraw
Classes | Public Member Functions | List of all members
fastuidraw::glsl::PainterItemShaderGLSL Class Reference

A PainterItemShaderGLSL is a collection of GLSL source code fragments for a PainterShaderRegistrarGLSL. More...

#include <painter_item_shader_glsl.hpp>

Inheritance diagram for fastuidraw::glsl::PainterItemShaderGLSL:
Inheritance graph
[legend]

Classes

class  DependencyList
 If one wishes to make use of other PainterItemShaderGLSL fastuidraw_gl_vert_main()/fastuidraw_gl_frag_main() of other shaders (for example to have a simple shader that adds on to a previous shader), a DependencyList provides the means to do so. More...
 

Public Member Functions

 PainterItemShaderGLSL (bool puses_discard, const ShaderSource &vertex_src, const ShaderSource &fragment_src, const symbol_list &symbols, unsigned int num_sub_shaders=1, const reference_counted_ptr< PainterItemCoverageShaderGLSL > &cvg=reference_counted_ptr< PainterItemCoverageShaderGLSL >(), const DependencyList &dependencies=DependencyList())
 
 PainterItemShaderGLSL (bool puses_discard, const ShaderSource &vertex_src, const ShaderSource &fragment_src, const symbol_list &symbols, const reference_counted_ptr< PainterItemCoverageShaderGLSL > &cvg, const DependencyList &dependencies=DependencyList(), unsigned int num_sub_shaders=1)
 
 PainterItemShaderGLSL (bool puses_discard, const ShaderSource &vertex_src, const ShaderSource &fragment_src, const symbol_list &symbols, const DependencyList &dependencies, const reference_counted_ptr< PainterItemCoverageShaderGLSL > &cvg=reference_counted_ptr< PainterItemCoverageShaderGLSL >(), unsigned int num_sub_shaders=1)
 
 PainterItemShaderGLSL (bool puses_discard, const ShaderSource &vertex_src, const ShaderSource &fragment_src, const symbol_list &symbols, const DependencyList &dependencies, unsigned int num_sub_shaders, const reference_counted_ptr< PainterItemCoverageShaderGLSL > &cvg=reference_counted_ptr< PainterItemCoverageShaderGLSL >())
 
c_array< const c_stringdependency_list_names (void) const
 
c_array< const reference_counted_ptr< const PainterItemShaderGLSL > > dependency_list_shaders (void) const
 
const ShaderSourcefragment_src (void) const
 
const symbol_listsymbols (void) const
 
bool uses_discard (void) const
 
const varying_listvaryings (void) const
 
const ShaderSourcevertex_src (void) const
 
- Public Member Functions inherited from fastuidraw::PainterItemShader
 PainterItemShader (const reference_counted_ptr< PainterItemCoverageShader > &cvg=reference_counted_ptr< PainterItemCoverageShader >())
 
 PainterItemShader (unsigned int num_sub_shaders, const reference_counted_ptr< PainterItemCoverageShader > &cvg=reference_counted_ptr< PainterItemCoverageShader >())
 
 PainterItemShader (reference_counted_ptr< PainterItemShader > parent, unsigned int sub_shader, const reference_counted_ptr< PainterItemCoverageShader > &cvg=reference_counted_ptr< PainterItemCoverageShader >())
 
const reference_counted_ptr< PainterItemCoverageShader > & coverage_shader (void) const
 
- Public Member Functions inherited from fastuidraw::PainterShader
 PainterShader (unsigned int num_sub_shaders=1)
 
 PainterShader (reference_counted_ptr< PainterShader > parent, unsigned int sub_shader)
 
uint32_t group (const PainterShaderRegistrar &) const
 
uint32_t ID (const PainterShaderRegistrar &) const
 
unsigned int number_sub_shaders (void) const
 
const reference_counted_ptr< PainterShader > & parent (void) const
 
bool registered_to (const PainterShaderRegistrar &) const
 
uint32_t sub_shader (void) const
 
Tag tag (const PainterShaderRegistrar &) const
 
- Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
 reference_counted_base (void)
 

Additional Inherited Members

- Static Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
static void add_reference (const reference_counted_base< T, Counter > *p)
 
static void remove_reference (const reference_counted_base< T, Counter > *p)
 

Detailed Description

A PainterItemShaderGLSL is a collection of GLSL source code fragments for a PainterShaderRegistrarGLSL.

The vertex shader code needs to implement the function:

void
fastuidraw_gl_vert_main(in uint sub_shader,
in uvec4 attrib0,
in uvec4 attrib1,
in uvec4 attrib2,
inout uint shader_data_block,
out uint z_add,
out vec2 brush_p,
out vec3 clip_p)

where

The output clip_p is to hold the clip-coordinate of the vertex. The output brush_p is to hold the coordinate for the brush of the vertex. The out z_add must be written to as well and it is how much to add to the value in PainterHeader::m_z for the purpose of intra-item z-occluding. Items that do not self-occlude should write 0 to z_add.

The fragment shader code needs to implement the function:

fastuidraw_gl_frag_main(in uint sub_shader,
inout uint shader_data_block)

which returns the color of the fragment for the item -before- the color modulation by the pen, brush or having blending applied. In addition, the color value returned MUST be pre-multiplied by alpha.

Available to only the vertex shader are the following:

Available to only the fragment shader are the following:

Available to both the vertex and fragment shader are the following:

For both stages, the value of the argument of shader_data_block is which 128-bit block into the data store (PainterDraw::m_store) of the shader data to be read with the GLSL macro fastuidraw_fetch_data. On exit, this value must be updated to the location just past the shader data of the shader.

For both stages, the value of the argument of sub_shader() is the value of PainterShader::sub_shader() of the active shader.

Also, if one defines macros in any of the passed ShaderSource objects, those macros MUST be undefined at the end. In addition, if one has local helper functions, to avoid global name collision, those function names should be wrapped in the macro FASTUIDRAW_LOCAL() to make sure that the function is given a unique global name within the uber-shader.

Lastly, one can use the class UnpackSourceGenerator to generate shader code to unpack values from the data in the data store buffer. That machine generated code uses the macro fastuidraw_fetch_data().

Definition at line 324 of file painter_item_shader_glsl.hpp.

Constructor & Destructor Documentation

◆ PainterItemShaderGLSL() [1/4]

fastuidraw::glsl::PainterItemShaderGLSL::PainterItemShaderGLSL ( bool  puses_discard,
const ShaderSource vertex_src,
const ShaderSource fragment_src,
const symbol_list symbols,
unsigned int  num_sub_shaders = 1,
const reference_counted_ptr< PainterItemCoverageShaderGLSL > &  cvg = reference_counted_ptrPainterItemCoverageShaderGLSL >(),
const DependencyList dependencies = DependencyList() 
)

Ctor.

Parameters
puses_discardset to true if and only if the shader code will use discard. Discard should be used in the GLSL code via the macro FASTUIDRAW_DISCARD.
vertex_srcGLSL source holding vertex shader routine
fragment_srcGLSL source holding fragment shader routine
symbolslist of symbols of the shader
num_sub_shadersthe number of sub-shaders it supports
cvgthe coverage shader (if any) to be used by the item shader
dependencieslist of other PainterItemShaderGLSL that are used directly.

◆ PainterItemShaderGLSL() [2/4]

fastuidraw::glsl::PainterItemShaderGLSL::PainterItemShaderGLSL ( bool  puses_discard,
const ShaderSource vertex_src,
const ShaderSource fragment_src,
const symbol_list symbols,
const reference_counted_ptr< PainterItemCoverageShaderGLSL > &  cvg,
const DependencyList dependencies = DependencyList(),
unsigned int  num_sub_shaders = 1 
)

Ctor.

Parameters
puses_discardset to true if and only if the shader code will use discard. Discard should be used in the GLSL code via the macro FASTUIDRAW_DISCARD.
vertex_srcGLSL source holding vertex shader routine
fragment_srcGLSL source holding fragment shader routine
symbolslist of symbols of the shader
num_sub_shadersthe number of sub-shaders it supports
cvgthe coverage shader (if any) to be used by the item shader
dependencieslist of other PainterItemShaderGLSL that are used directly.

◆ PainterItemShaderGLSL() [3/4]

fastuidraw::glsl::PainterItemShaderGLSL::PainterItemShaderGLSL ( bool  puses_discard,
const ShaderSource vertex_src,
const ShaderSource fragment_src,
const symbol_list symbols,
const DependencyList dependencies,
const reference_counted_ptr< PainterItemCoverageShaderGLSL > &  cvg = reference_counted_ptrPainterItemCoverageShaderGLSL >(),
unsigned int  num_sub_shaders = 1 
)

Ctor.

Parameters
puses_discardset to true if and only if the shader code will use discard. Discard should be used in the GLSL code via the macro FASTUIDRAW_DISCARD.
vertex_srcGLSL source holding vertex shader routine
fragment_srcGLSL source holding fragment shader routine
symbolslist of symbols of the shader
num_sub_shadersthe number of sub-shaders it supports
cvgthe coverage shader (if any) to be used by the item shader
dependencieslist of other PainterItemShaderGLSL that are used directly.

◆ PainterItemShaderGLSL() [4/4]

fastuidraw::glsl::PainterItemShaderGLSL::PainterItemShaderGLSL ( bool  puses_discard,
const ShaderSource vertex_src,
const ShaderSource fragment_src,
const symbol_list symbols,
const DependencyList dependencies,
unsigned int  num_sub_shaders,
const reference_counted_ptr< PainterItemCoverageShaderGLSL > &  cvg = reference_counted_ptrPainterItemCoverageShaderGLSL >() 
)

Ctor.

Parameters
puses_discardset to true if and only if the shader code will use discard. Discard should be used in the GLSL code via the macro FASTUIDRAW_DISCARD.
vertex_srcGLSL source holding vertex shader routine
fragment_srcGLSL source holding fragment shader routine
symbolslist of symbols of the shader
num_sub_shadersthe number of sub-shaders it supports
cvgthe coverage shader (if any) to be used by the item shader
dependencieslist of other PainterItemShaderGLSL that are used directly.

Member Function Documentation

◆ dependency_list_names()

c_array<const c_string> fastuidraw::glsl::PainterItemShaderGLSL::dependency_list_names ( void  ) const

Returns the names that each shader listed in dependency_list_shaders() is referenced by, i.e. the i'th element of dependency_list_shaders() is referenced as the i'th element of dependency_list_names().

◆ dependency_list_shaders()

c_array<const reference_counted_ptr<const PainterItemShaderGLSL> > fastuidraw::glsl::PainterItemShaderGLSL::dependency_list_shaders ( void  ) const

Return the list of shaders on which this shader is dependent.

◆ fragment_src()

const ShaderSource& fastuidraw::glsl::PainterItemShaderGLSL::fragment_src ( void  ) const

Return the GLSL source of the fragment shader

◆ symbols()

const symbol_list& fastuidraw::glsl::PainterItemShaderGLSL::symbols ( void  ) const

Returns the symbol of the shader

◆ uses_discard()

bool fastuidraw::glsl::PainterItemShaderGLSL::uses_discard ( void  ) const

Returns true if the fragment shader uses discard

◆ varyings()

const varying_list& fastuidraw::glsl::PainterItemShaderGLSL::varyings ( void  ) const
inline

Returns the varyings of the shader, equivalent to

Definition at line 493 of file painter_item_shader_glsl.hpp.

◆ vertex_src()

const ShaderSource& fastuidraw::glsl::PainterItemShaderGLSL::vertex_src ( void  ) const

Return the GLSL source of the vertex shader


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