FastUIDraw
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
fastuidraw::glsl::PainterShaderRegistrarGLSL Class Reference

A PainterShaderRegistrarGLSL is an implementation of PainterRegistrar that assembles the shader source code of PainterItemShaderGLSL and PainterBlendShaderGLSL into an uber-shader. More...

#include <painter_shader_registrar_glsl.hpp>

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

Public Member Functions

 PainterShaderRegistrarGLSL (void)
 
void add_fragment_shader_util (const ShaderSource &src)
 
void add_vertex_shader_util (const ShaderSource &src)
 
void construct_item_coverage_shader (const BackendConstants &backend_constants, ShaderSource &out_vertex, ShaderSource &out_fragment, const UberShaderParams &construct_params, unsigned int shader_id)
 
void construct_item_shader (enum PainterBlendShader::shader_type tp, const BackendConstants &backend_constants, ShaderSource &out_vertex, ShaderSource &out_fragment, const UberShaderParams &construct_params, unsigned int shader_id, c_string discard_macro_value="discard")
 
void construct_item_uber_coverage_shader (const BackendConstants &backend_constants, ShaderSource &out_vertex, ShaderSource &out_fragment, const UberShaderParams &construct_params, const ShaderFilter< PainterItemCoverageShaderGLSL > *item_shader_filter=nullptr)
 
void construct_item_uber_shader (enum PainterBlendShader::shader_type tp, const BackendConstants &backend_constants, ShaderSource &out_vertex, ShaderSource &out_fragment, const UberShaderParams &construct_params, const ShaderFilter< PainterItemShaderGLSL > *item_shader_filter=nullptr, c_string discard_macro_value="discard")
 
void fill_uniform_buffer (const PainterSurface::Viewport &vwp, c_array< uint32_t > p)
 
unsigned int registered_blend_shader_count (enum PainterBlendShader::shader_type tp)
 
unsigned int registered_shader_count (void)
 
- Public Member Functions inherited from fastuidraw::PainterShaderRegistrar
 PainterShaderRegistrar (void)
 
void register_shader (PainterItemShader *shader)
 
void register_shader (PainterItemCoverageShader *shader)
 
void register_shader (PainterBlendShader *shader)
 
void register_shader (PainterBrushShader *shader)
 
void register_shader (const PainterImageBrushShader *shader)
 
void register_shader (const PainterGradientBrushShader *shader)
 
template<typename T >
void register_shader (const reference_counted_ptr< T > &shader)
 
void register_shader (const PainterStrokeShader &p)
 
void register_shader (const PainterFillShader &p)
 
void register_shader (const PainterDashedStrokeShaderSet &p)
 
void register_shader (const PainterGlyphShader &p)
 
void register_shader (const PainterBlendShaderSet &p)
 
void register_shader (const PainterBrushShaderSet &p)
 
void register_shader (const PainterShaderSet &p)
 
unsigned int unique_id (void) const
 
- Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
 reference_counted_base (void)
 

Static Public Member Functions

static uint32_t ubo_size (void)
 
- 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)
 

Protected Member Functions

virtual PainterShader::Tag absorb_blend_shader (const reference_counted_ptr< PainterBlendShader > &shader) final override
 
virtual PainterShader::Tag absorb_custom_brush_shader (const reference_counted_ptr< PainterBrushShader > &shader) final override
 
virtual PainterShader::Tag absorb_item_coverage_shader (const reference_counted_ptr< PainterItemCoverageShader > &shader) final override
 
virtual PainterShader::Tag absorb_item_shader (const reference_counted_ptr< PainterItemShader > &shader) final override
 
virtual uint32_t compute_blend_shader_group (PainterShader::Tag tag, const reference_counted_ptr< PainterBlendShader > &shader)
 
virtual uint32_t compute_blend_sub_shader_group (const reference_counted_ptr< PainterBlendShader > &shader) final override
 
virtual uint32_t compute_custom_brush_shader_group (PainterShader::Tag tag, const reference_counted_ptr< PainterBrushShader > &shader)
 
virtual uint32_t compute_custom_brush_sub_shader_group (const reference_counted_ptr< PainterBrushShader > &shader) final override
 
virtual uint32_t compute_item_coverage_shader_group (PainterShader::Tag tag, const reference_counted_ptr< PainterItemCoverageShader > &shader)
 
virtual uint32_t compute_item_coverage_sub_shader_group (const reference_counted_ptr< PainterItemCoverageShader > &shader) final override
 
virtual uint32_t compute_item_shader_group (PainterShader::Tag tag, const reference_counted_ptr< PainterItemShader > &shader)
 
virtual uint32_t compute_item_sub_shader_group (const reference_counted_ptr< PainterItemShader > &shader) final override
 
- Protected Member Functions inherited from fastuidraw::PainterShaderRegistrar
virtual bool blend_type_supported (enum PainterBlendShader::shader_type) const =0
 
Mutexmutex (void)
 

Additional Inherited Members

- Public Types inherited from fastuidraw::glsl::PainterShaderRegistrarGLSLTypes
enum  clipping_type_t { clipping_via_gl_clip_distance, clipping_via_discard, clipping_via_skip_color_write }
 
enum  colorstop_backing_t { colorstop_texture_1d_array, colorstop_texture_2d_array }
 Enumeration to specify how to access the backing store of a color stop atlas store in ColorStopAtlas::backing_store(). More...
 
enum  data_store_backing_t { data_store_tbo, data_store_ubo, data_store_ssbo }
 Enumeration to specify how the data store filled by PainterDraw::m_store is realized. More...
 
enum  fbf_blending_type_t { fbf_blending_not_supported, fbf_blending_framebuffer_fetch, fbf_blending_interlock }
 Enumeration to specify how to perform framebuffer-fetch blending. More...
 
enum  glyph_data_backing_t { glyph_data_tbo, glyph_data_texture_array, glyph_data_ssbo }
 Enumeration to specify how to access the backing store of the glyph data stored in GlyphAtlas::store() More...
 
enum  vertex_shader_in_layout { attribute0_slot = 0, attribute1_slot, attribute2_slot, header_attrib_slot }
 Enumeration to describe vertex shader input slot layout. More...
 
enum  z_coordinate_convention_t { z_minus_1_to_1, z_0_to_1 }
 Enumeration to specify the convention for a 3D API for its normalized device coordinate in z. More...
 

Detailed Description

A PainterShaderRegistrarGLSL is an implementation of PainterRegistrar that assembles the shader source code of PainterItemShaderGLSL and PainterBlendShaderGLSL into an uber-shader.

Definition at line 876 of file painter_shader_registrar_glsl.hpp.

Constructor & Destructor Documentation

◆ PainterShaderRegistrarGLSL()

fastuidraw::glsl::PainterShaderRegistrarGLSL::PainterShaderRegistrarGLSL ( void  )
explicit

Ctor.

Member Function Documentation

◆ absorb_blend_shader()

virtual PainterShader::Tag fastuidraw::glsl::PainterShaderRegistrarGLSL::absorb_blend_shader ( const reference_counted_ptr< PainterBlendShader > &  shader)
finaloverrideprotectedvirtual

To be implemented by a derived class to take into use a blend shader. Typically this means inserting the the blend shader into a large uber shader. Returns the PainterShader::Tag to be used by the backend to identify the shader. An implementation will never be passed an object for which PainterShader::parent() is non-nullptr. In addition, mutex() will be locked on entry.

Parameters
shadershader whose Tag is to be computed

Implements fastuidraw::PainterShaderRegistrar.

◆ absorb_custom_brush_shader()

virtual PainterShader::Tag fastuidraw::glsl::PainterShaderRegistrarGLSL::absorb_custom_brush_shader ( const reference_counted_ptr< PainterBrushShader > &  shader)
finaloverrideprotectedvirtual

To be implemented by a derived class to take into use a blend shader. Typically this means inserting the the blend shader into a large uber shader. Returns the PainterShader::Tag to be used by the backend to identify the shader. An implementation will never be passed an object for which PainterShader::parent() is non-nullptr. In addition, mutex() will be locked on entry.

Parameters
shadershader whose Tag is to be computed

Implements fastuidraw::PainterShaderRegistrar.

◆ absorb_item_coverage_shader()

virtual PainterShader::Tag fastuidraw::glsl::PainterShaderRegistrarGLSL::absorb_item_coverage_shader ( const reference_counted_ptr< PainterItemCoverageShader > &  shader)
finaloverrideprotectedvirtual

To be implemented by a derived class to take into use an item shader. Typically this means inserting the the shader into a large uber shader. Returns the PainterShader::Tag to be used by the backend to identify the shader. An implementation will never be passed an object for which PainterShader::parent() is non-nullptr. In addition, mutex() will be locked on entry.

Parameters
shadershader whose Tag is to be computed

Implements fastuidraw::PainterShaderRegistrar.

◆ absorb_item_shader()

virtual PainterShader::Tag fastuidraw::glsl::PainterShaderRegistrarGLSL::absorb_item_shader ( const reference_counted_ptr< PainterItemShader > &  shader)
finaloverrideprotectedvirtual

To be implemented by a derived class to take into use an item shader. Typically this means inserting the the shader into a large uber shader. Returns the PainterShader::Tag to be used by the backend to identify the shader. An implementation will never be passed an object for which PainterShader::parent() is non-nullptr. In addition, mutex() will be locked on entry.

Parameters
shadershader whose Tag is to be computed

Implements fastuidraw::PainterShaderRegistrar.

◆ add_fragment_shader_util()

void fastuidraw::glsl::PainterShaderRegistrarGLSL::add_fragment_shader_util ( const ShaderSource src)

Add GLSL code that is to be visible to all vertex shaders. The code can define functions or macros.

Parameters
srcshader source to add

◆ add_vertex_shader_util()

void fastuidraw::glsl::PainterShaderRegistrarGLSL::add_vertex_shader_util ( const ShaderSource src)

Add GLSL code that is to be visible to all vertex shaders. The code can define functions or macros.

Parameters
srcshader source to add

◆ compute_blend_shader_group()

virtual uint32_t fastuidraw::glsl::PainterShaderRegistrarGLSL::compute_blend_shader_group ( PainterShader::Tag  tag,
const reference_counted_ptr< PainterBlendShader > &  shader 
)
protectedvirtual

To be optionally implemented by a derived class to compute the shader group of a PainterBlendShader. The passed shader may or may not be a sub-shader. The mutex() is locked for the duration of the function. Default implementation is to return 0.

Parameters
tagThe value of PainterShader::tag() that PainterShaderRegistrarGLSL will assign to the shader. Do NOT access PainterShader::tag(), PainterShader::ID() or PainterShader::group() as they are not yet assgined.
shadershader whose group is to be computed

◆ compute_blend_sub_shader_group()

virtual uint32_t fastuidraw::glsl::PainterShaderRegistrarGLSL::compute_blend_sub_shader_group ( const reference_counted_ptr< PainterBlendShader > &  shader)
finaloverrideprotectedvirtual

To be implemented by a derived class to compute the PainterShader::group() of a sub-shader. When called, the value of the shader's PainterShader::ID() and PainterShader::registered_to() are already set correctly. In addition, the value of PainterShader::group() is initialized to the same value as that of the PainterBlendShader::parent(). In addition, mutex() will be locked on entry.

Parameters
shadershader whose group is to be computed

Implements fastuidraw::PainterShaderRegistrar.

◆ compute_custom_brush_shader_group()

virtual uint32_t fastuidraw::glsl::PainterShaderRegistrarGLSL::compute_custom_brush_shader_group ( PainterShader::Tag  tag,
const reference_counted_ptr< PainterBrushShader > &  shader 
)
protectedvirtual

To be optionally implemented by a derived class to compute the shader group of a PainterBrushShader. The passed shader may or may not be a sub-shader. The mutex() is locked for the duration of the function. Default implementation is to return 0.

Parameters
tagThe value of PainterShader::tag() that PainterShaderRegistrarGLSL will assign to the shader. Do NOT access PainterShader::tag(), PainterShader::ID() or PainterShader::group() as they are not yet assgined.
shadershader whose group is to be computed

◆ compute_custom_brush_sub_shader_group()

virtual uint32_t fastuidraw::glsl::PainterShaderRegistrarGLSL::compute_custom_brush_sub_shader_group ( const reference_counted_ptr< PainterBrushShader > &  shader)
finaloverrideprotectedvirtual

To be implemented by a derived class to compute the PainterShader::group() of a sub-shader. When called, the value of the shader's PainterShader::ID() and PainterShader::registered_to() are already set correctly. In addition, the value of PainterShader::group() is initialized to the same value as that of the PainterBrushShader::parent(). In addition, mutex() will be locked on entry.

Parameters
shadershader whose group is to be computed

Implements fastuidraw::PainterShaderRegistrar.

◆ compute_item_coverage_shader_group()

virtual uint32_t fastuidraw::glsl::PainterShaderRegistrarGLSL::compute_item_coverage_shader_group ( PainterShader::Tag  tag,
const reference_counted_ptr< PainterItemCoverageShader > &  shader 
)
protectedvirtual

To be optionally implemented by a derived class to compute the shader group of a PainterItemCoverageShader. The passed shader may or may not be a sub-shader. The mutex() is locked for the duration of the function. Default implementation is to return 0.

Parameters
tagThe value of PainterShader::tag() that PainterShaderRegistrarGLSL will assign to the shader. Do NOT access PainterShader::tag(), PainterShader::ID() or PainterShader::group() as they are not yet assgined.
shadershader whose group is to be computed

◆ compute_item_coverage_sub_shader_group()

virtual uint32_t fastuidraw::glsl::PainterShaderRegistrarGLSL::compute_item_coverage_sub_shader_group ( const reference_counted_ptr< PainterItemCoverageShader > &  shader)
finaloverrideprotectedvirtual

To be implemented by a derived class to compute the PainterShader::group() of a sub-shader. When called, the value of the shader's PainterShader::ID() and PainterShader::registered_to() are already set correctly. In addition, the value of PainterShader::group() is initialized to the same value as that of the PainterItemShader::parent(). In addition, mutex() will be locked on entry.

Parameters
shadershader whose group is to be computed

Implements fastuidraw::PainterShaderRegistrar.

◆ compute_item_shader_group()

virtual uint32_t fastuidraw::glsl::PainterShaderRegistrarGLSL::compute_item_shader_group ( PainterShader::Tag  tag,
const reference_counted_ptr< PainterItemShader > &  shader 
)
protectedvirtual

To be optionally implemented by a derived class to compute the shader group of a PainterItemShader. The passed shader may or may not be a sub-shader. The mutex() is locked for the duration of the function. Default implementation is to return 0.

Parameters
tagThe value of PainterShader::tag() that PainterShaderRegistrarGLSL will assign to the shader. Do NOT access PainterShader::tag(), PainterShader::ID() or PainterShader::group() as they are not yet assgined.
shadershader whose group is to be computed

◆ compute_item_sub_shader_group()

virtual uint32_t fastuidraw::glsl::PainterShaderRegistrarGLSL::compute_item_sub_shader_group ( const reference_counted_ptr< PainterItemShader > &  shader)
finaloverrideprotectedvirtual

To be implemented by a derived class to compute the PainterShader::group() of a sub-shader. When called, the value of the shader's PainterShader::ID() and PainterShader::registered_to() are already set correctly. In addition, the value of PainterShader::group() is initialized to the same value as that of the PainterItemShader::parent(). In addition, mutex() will be locked on entry.

Parameters
shadershader whose group is to be computed

Implements fastuidraw::PainterShaderRegistrar.

◆ construct_item_coverage_shader()

void fastuidraw::glsl::PainterShaderRegistrarGLSL::construct_item_coverage_shader ( const BackendConstants backend_constants,
ShaderSource out_vertex,
ShaderSource out_fragment,
const UberShaderParams construct_params,
unsigned int  shader_id 
)

Add the vertex and fragment shaders of a specific item shader to given ShaderSource values. The Mutex mutex() is NOT locked during this call, a caller should lock the mutex before calling it. This way a derived class can use the same lock as used by the PainterShaderRegistrarGLSL.

Parameters
backend_constantsconstant values that affect the created uber-shader.
out_vertexShaderSource to which to add uber-vertex shader
out_fragmentShaderSource to which to add uber-fragment shader
construct_paramsspecifies how to construct the uber-shaders.
shader_iditem shader ID, i.e. PainterItemShader::ID().

◆ construct_item_shader()

void fastuidraw::glsl::PainterShaderRegistrarGLSL::construct_item_shader ( enum PainterBlendShader::shader_type  tp,
const BackendConstants backend_constants,
ShaderSource out_vertex,
ShaderSource out_fragment,
const UberShaderParams construct_params,
unsigned int  shader_id,
c_string  discard_macro_value = "discard" 
)

Add the vertex and fragment shaders of a specific item shader to given ShaderSource values. The Mutex mutex() is NOT locked during this call, a caller should lock the mutex before calling it. This way a derived class can use the same lock as used by the PainterShaderRegistrarGLSL.

Parameters
tpblend type of PainterBlendShader objects to include in the uber-shader
backend_constantsconstant values that affect the created uber-shader.
out_vertexShaderSource to which to add uber-vertex shader
out_fragmentShaderSource to which to add uber-fragment shader
construct_paramsspecifies how to construct the uber-shaders.
shader_iditem shader ID, i.e. PainterItemShader::ID().
discard_macro_valuemacro-value definintion for the macro FASTUIDRAW_DISCARD. PainterItemShaderGLSL fragment sources use FASTUIDRAW_DISCARD instead of discard.

◆ construct_item_uber_coverage_shader()

void fastuidraw::glsl::PainterShaderRegistrarGLSL::construct_item_uber_coverage_shader ( const BackendConstants backend_constants,
ShaderSource out_vertex,
ShaderSource out_fragment,
const UberShaderParams construct_params,
const ShaderFilter< PainterItemCoverageShaderGLSL > *  item_shader_filter = nullptr 
)

Add the uber-vertex and fragment shaders to given ShaderSource values. The Mutex mutex() is NOT locked during this call, a caller should lock the mutex before calling it. This way a derived class can use the same lock as used by the PainterShaderRegistrarGLSL.

Parameters
backend_constantsconstant values that affect the created uber-shader.
out_vertexShaderSource to which to add uber-vertex shader
out_fragmentShaderSource to which to add uber-fragment shader
construct_paramsspecifies how to construct the uber-shaders.
item_shader_filterpointer to PainterShaderRegistrarGLSLTypes::ShaderFilter to use to filter which shaders to place into the uber-shader. A value of nullptr indicates to add all item coverage shaders to the uber-shader.

◆ construct_item_uber_shader()

void fastuidraw::glsl::PainterShaderRegistrarGLSL::construct_item_uber_shader ( enum PainterBlendShader::shader_type  tp,
const BackendConstants backend_constants,
ShaderSource out_vertex,
ShaderSource out_fragment,
const UberShaderParams construct_params,
const ShaderFilter< PainterItemShaderGLSL > *  item_shader_filter = nullptr,
c_string  discard_macro_value = "discard" 
)

Add the uber-vertex and fragment shaders to given ShaderSource values. The Mutex mutex() is NOT locked during this call, a caller should lock the mutex before calling it. This way a derived class can use the same lock as used by the PainterShaderRegistrarGLSL. A backend will need to define the the functions (or macros) in their GLSL preamble:

  • fastuidraw_begin_interlock() which is called before access
  • fastuidraw_end_interlock() which is called after access if UberShaderParams::ffb_blending_type() is fbf_blending_interlock.
    Parameters
    tpblend type of PainterBlendShader objects to include in the uber-shader
    backend_constantsconstant values that affect the created uber-shader.
    out_vertexShaderSource to which to add uber-vertex shader
    out_fragmentShaderSource to which to add uber-fragment shader
    construct_paramsspecifies how to construct the uber-shaders.
    item_shader_filterpointer to PainterShaderRegistrarGLSLTypes::ShaderFilter to use to filter which shaders to place into the uber-shader. A value of nullptr indicates to add all item shaders to the uber-shader.
    discard_macro_valuemacro-value definintion for the macro FASTUIDRAW_DISCARD. PainterItemShaderGLSL fragment sources use FASTUIDRAW_DISCARD instead of discard.

◆ fill_uniform_buffer()

void fastuidraw::glsl::PainterShaderRegistrarGLSL::fill_uniform_buffer ( const PainterSurface::Viewport vwp,
c_array< uint32_t >  p 
)

Fill a buffer to hold the values used by the uber-shader. The buffer must be that p.size() is atleast ubo_size().

Parameters
vwpcurrent PainterSurface::Viewport to which is being rendered
pbuffer to which to fill uniform data

◆ registered_blend_shader_count()

unsigned int fastuidraw::glsl::PainterShaderRegistrarGLSL::registered_blend_shader_count ( enum PainterBlendShader::shader_type  tp)

Returns the number of blend shaders registered to this PainterShaderRegistrarGLSL; a derived class should track this count value and use it to determine when it needs to reconstruct its shaders. The mutex() is NOT locked for the duration of the function.

◆ registered_shader_count()

unsigned int fastuidraw::glsl::PainterShaderRegistrarGLSL::registered_shader_count ( void  )

Returns the total number of shaders (item and blend) registered to this PainterShaderRegistrarGLSL; a derived class should track this count value and use it to determine when it needs to reconstruct its uber-shader. The mutex() is NOT locked for the duration of the function.

◆ ubo_size()

static uint32_t fastuidraw::glsl::PainterShaderRegistrarGLSL::ubo_size ( void  )
static

Total size of UBO for uniforms in units of uint32_t, see also fill_uniform_ubo().


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