cgv
Loading...
Searching...
No Matches
cgv::render::a_buffer Class Reference

This class provides a_buffer functionality. More...

#include <a_buffer.h>

Public Member Functions

 a_buffer (unsigned _fragments_per_pixel=32, unsigned _nodes_per_pixel=64, int _depth_tex_unit=0, int _node_counter_binding_point=0, int _head_pointers_binding_point=0, int _nodes_binding_point=1)
 construct and configure
 
bool init (context &ctx)
 construct internally used programs
 
void destruct (context &ctx)
 destruct all render objects
 
void init_frame (context &ctx)
 ensure that a_buffer size corresponds to context size
 
void update_shader_program_options (shader_compile_options &options)
 update the provided shader compile options with respect to a_buffer settings. Call before enabling a program.
 
bool enable (context &ctx, shader_program &prog, int tex_unit=-1)
 Enable writing fragments to a_buffer with provided program.
 
void disable (context &ctx, size_t *out_node_count=nullptr)
 finish writing fragments to a_buffer and return current number of nodes in node buffer
 
void finish_frame (context &ctx)
 per fragment sort nodes and blend over current framebuffer
 
int & ref_depth_tex_unit ()
 
int & ref_node_counter_binding_point ()
 
int & ref_head_pointers_binding_point ()
 
int & ref_nodes_binding_point ()
 

Public Attributes

unsigned fragments_per_pixel
 to be handled fragments per pixel (changes are applied when in init_frame() function)
 
unsigned nodes_per_pixel
 to be reserved number of fragment nodes per pixel (changes are applied when in init_frame() function)
 

Protected Member Functions

void ensure_buffers (context &ctx)
 
void update_shader_program_options (shader_compile_options &options, bool include_binding_points)
 

Protected Attributes

texture depth_tex
 Depth texture used to emulate depth buffer.
 
cgv::render::vertex_buffer node_counter_buffer = { cgv::render::VertexBufferType::VBT_ATOMIC_COUNTER }
 Buffers used to store per pixel frament lists.
 
cgv::render::vertex_buffer head_pointer_buffer = { cgv::render::VertexBufferType::VBT_STORAGE }
 
cgv::render::vertex_buffer node_buffer = { cgv::render::VertexBufferType::VBT_STORAGE }
 
int depth_tex_unit
 Default texture unit used for depth texture.
 
int node_counter_binding_point
 Buffer binding point indices.
 
int head_pointers_binding_point
 
int nodes_binding_point
 
shader_program clear_ssbo_prog
 
shader_program a_buffer_prog
 

Detailed Description

This class provides a_buffer functionality.

Compare cgv/test/a_buffer_test for an example of using this class.

Definition at line 15 of file a_buffer.h.

Constructor & Destructor Documentation

◆ a_buffer()

cgv::render::a_buffer::a_buffer ( unsigned  _fragments_per_pixel = 32,
unsigned  _nodes_per_pixel = 64,
int  _depth_tex_unit = 0,
int  _node_counter_binding_point = 0,
int  _head_pointers_binding_point = 0,
int  _nodes_binding_point = 1 
)

Member Function Documentation

◆ destruct()

void cgv::render::a_buffer::destruct ( context ctx)

◆ disable()

void cgv::render::a_buffer::disable ( context ctx,
size_t *  out_node_count = nullptr 
)

finish writing fragments to a_buffer and return current number of nodes in node buffer

Definition at line 132 of file a_buffer.cxx.

References cgv::render::vertex_buffer::copy(), depth_tex, cgv::render::texture::disable(), node_counter_binding_point, node_counter_buffer, and cgv::render::vertex_buffer::unbind().

◆ enable()

bool cgv::render::a_buffer::enable ( context ctx,
shader_program prog,
int  tex_unit = -1 
)

Enable writing fragments to a_buffer with provided program.

In first call after each init frame call, the current depth buffer is copied to a_buffer's depth texture. Function sets necessary uniforms in program and binds depth texture and buffers. In a_buffer constructor depth texture unit can be overwritten by third argument. Function fails by returning false if program query of binding points to buffers fail.

Definition at line 100 of file a_buffer.cxx.

References cgv::render::vertex_buffer::bind(), depth_tex, depth_tex_unit, cgv::render::texture::enable(), cgv::render::context::get_height(), cgv::render::context::get_width(), node_counter_binding_point, node_counter_buffer, nodes_per_pixel, cgv::render::texture::replace_from_buffer(), and cgv::render::shader_program::set_uniform().

◆ ensure_buffers()

void cgv::render::a_buffer::ensure_buffers ( context ctx)
protected

Definition at line 6 of file a_buffer.cxx.

◆ finish_frame()

◆ init()

bool cgv::render::a_buffer::init ( context ctx)

construct internally used programs

Definition at line 43 of file a_buffer.cxx.

References cgv::render::shader_program::build_files(), and cgv::render::shader_program::build_program().

◆ init_frame()

◆ ref_depth_tex_unit()

int & cgv::render::a_buffer::ref_depth_tex_unit ( )
inline

Definition at line 68 of file a_buffer.h.

◆ ref_head_pointers_binding_point()

int & cgv::render::a_buffer::ref_head_pointers_binding_point ( )
inline

Definition at line 70 of file a_buffer.h.

◆ ref_node_counter_binding_point()

int & cgv::render::a_buffer::ref_node_counter_binding_point ( )
inline

Definition at line 69 of file a_buffer.h.

◆ ref_nodes_binding_point()

int & cgv::render::a_buffer::ref_nodes_binding_point ( )
inline

Definition at line 71 of file a_buffer.h.

◆ update_shader_program_options() [1/2]

void cgv::render::a_buffer::update_shader_program_options ( shader_compile_options options)

update the provided shader compile options with respect to a_buffer settings. Call before enabling a program.

Definition at line 23 of file a_buffer.cxx.

◆ update_shader_program_options() [2/2]

void cgv::render::a_buffer::update_shader_program_options ( shader_compile_options options,
bool  include_binding_points 
)
protected

Definition at line 14 of file a_buffer.cxx.

Member Data Documentation

◆ a_buffer_prog

shader_program cgv::render::a_buffer::a_buffer_prog
protected

Definition at line 35 of file a_buffer.h.

◆ clear_ssbo_prog

shader_program cgv::render::a_buffer::clear_ssbo_prog
protected

Definition at line 34 of file a_buffer.h.

◆ depth_tex

texture cgv::render::a_buffer::depth_tex
protected

Depth texture used to emulate depth buffer.

Definition at line 22 of file a_buffer.h.

Referenced by a_buffer(), destruct(), disable(), enable(), and init_frame().

◆ depth_tex_unit

int cgv::render::a_buffer::depth_tex_unit
protected

Default texture unit used for depth texture.

Definition at line 28 of file a_buffer.h.

Referenced by a_buffer(), and enable().

◆ fragments_per_pixel

unsigned cgv::render::a_buffer::fragments_per_pixel

to be handled fragments per pixel (changes are applied when in init_frame() function)

Definition at line 45 of file a_buffer.h.

Referenced by a_buffer().

◆ head_pointer_buffer

cgv::render::vertex_buffer cgv::render::a_buffer::head_pointer_buffer = { cgv::render::VertexBufferType::VBT_STORAGE }
protected

Definition at line 25 of file a_buffer.h.

◆ head_pointers_binding_point

int cgv::render::a_buffer::head_pointers_binding_point
protected

Definition at line 31 of file a_buffer.h.

◆ node_buffer

cgv::render::vertex_buffer cgv::render::a_buffer::node_buffer = { cgv::render::VertexBufferType::VBT_STORAGE }
protected

Definition at line 26 of file a_buffer.h.

◆ node_counter_binding_point

int cgv::render::a_buffer::node_counter_binding_point
protected

Buffer binding point indices.

Definition at line 30 of file a_buffer.h.

Referenced by a_buffer(), disable(), and enable().

◆ node_counter_buffer

cgv::render::vertex_buffer cgv::render::a_buffer::node_counter_buffer = { cgv::render::VertexBufferType::VBT_ATOMIC_COUNTER }
protected

Buffers used to store per pixel frament lists.

Definition at line 24 of file a_buffer.h.

Referenced by destruct(), disable(), enable(), and init_frame().

◆ nodes_binding_point

int cgv::render::a_buffer::nodes_binding_point
protected

Definition at line 32 of file a_buffer.h.

◆ nodes_per_pixel

unsigned cgv::render::a_buffer::nodes_per_pixel

to be reserved number of fragment nodes per pixel (changes are applied when in init_frame() function)

Definition at line 47 of file a_buffer.h.

Referenced by a_buffer(), enable(), and finish_frame().


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