FastUIDraw
|
A PainterItemShaderGLSL is a collection of GLSL source code fragments for a PainterShaderRegistrarGLSL. More...
#include <painter_item_shader_glsl.hpp>
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... | |
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) |
A PainterItemShaderGLSL is a collection of GLSL source code fragments for a PainterShaderRegistrarGLSL.
The vertex shader code needs to implement the function:
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:
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.
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_ptr< PainterItemCoverageShaderGLSL >() , |
||
const DependencyList & | dependencies = DependencyList() |
||
) |
Ctor.
puses_discard | set 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_src | GLSL source holding vertex shader routine |
fragment_src | GLSL source holding fragment shader routine |
symbols | list of symbols of the shader |
num_sub_shaders | the number of sub-shaders it supports |
cvg | the coverage shader (if any) to be used by the item shader |
dependencies | list of other PainterItemShaderGLSL that are used directly. |
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.
puses_discard | set 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_src | GLSL source holding vertex shader routine |
fragment_src | GLSL source holding fragment shader routine |
symbols | list of symbols of the shader |
num_sub_shaders | the number of sub-shaders it supports |
cvg | the coverage shader (if any) to be used by the item shader |
dependencies | list of other PainterItemShaderGLSL that are used directly. |
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_ptr< PainterItemCoverageShaderGLSL >() , |
||
unsigned int | num_sub_shaders = 1 |
||
) |
Ctor.
puses_discard | set 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_src | GLSL source holding vertex shader routine |
fragment_src | GLSL source holding fragment shader routine |
symbols | list of symbols of the shader |
num_sub_shaders | the number of sub-shaders it supports |
cvg | the coverage shader (if any) to be used by the item shader |
dependencies | list of other PainterItemShaderGLSL that are used directly. |
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_ptr< PainterItemCoverageShaderGLSL >() |
||
) |
Ctor.
puses_discard | set 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_src | GLSL source holding vertex shader routine |
fragment_src | GLSL source holding fragment shader routine |
symbols | list of symbols of the shader |
num_sub_shaders | the number of sub-shaders it supports |
cvg | the coverage shader (if any) to be used by the item shader |
dependencies | list of other PainterItemShaderGLSL that are used directly. |
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().
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.
const ShaderSource& fastuidraw::glsl::PainterItemShaderGLSL::fragment_src | ( | void | ) | const |
Return the GLSL source of the fragment shader
const symbol_list& fastuidraw::glsl::PainterItemShaderGLSL::symbols | ( | void | ) | const |
Returns the symbol of the shader
bool fastuidraw::glsl::PainterItemShaderGLSL::uses_discard | ( | void | ) | const |
Returns true if the fragment shader uses discard
|
inline |
Returns the varyings of the shader, equivalent to
Definition at line 493 of file painter_item_shader_glsl.hpp.
const ShaderSource& fastuidraw::glsl::PainterItemShaderGLSL::vertex_src | ( | void | ) | const |
Return the GLSL source of the vertex shader