|
cgv
|
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 |
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.
| 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 |
||
| ) |
construct and configure
Definition at line 27 of file a_buffer.cxx.
References depth_tex, depth_tex_unit, fragments_per_pixel, node_counter_binding_point, nodes_per_pixel, cgv::render::texture::set_mag_filter(), and cgv::render::texture::set_min_filter().
| void cgv::render::a_buffer::destruct | ( | context & | ctx | ) |
destruct all render objects
Definition at line 53 of file a_buffer.cxx.
References depth_tex, cgv::render::shader_program::destruct(), cgv::render::texture::destruct(), cgv::render::vertex_buffer::destruct(), and node_counter_buffer.
| 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().
| 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().
|
protected |
Definition at line 6 of file a_buffer.cxx.
| void cgv::render::a_buffer::finish_frame | ( | context & | ctx | ) |
per fragment sort nodes and blend over current framebuffer
Definition at line 148 of file a_buffer.cxx.
References cgv::render::vertex_buffer::bind(), cgv::render::shader_program::disable(), cgv::render::shader_program::enable(), cgv::render::context::enable_blending(), cgv::render::context::get_height(), cgv::render::context::get_width(), nodes_per_pixel, cgv::render::context::pop_blend_state(), cgv::render::context::push_blend_state(), cgv::render::context::set_blend_func_back_to_front(), cgv::render::shader_program::set_uniform(), and cgv::render::vertex_buffer::unbind().
| 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().
| void cgv::render::a_buffer::init_frame | ( | context & | ctx | ) |
ensure that a_buffer size corresponds to context size
Definition at line 62 of file a_buffer.cxx.
References cgv::render::vertex_buffer::bind(), cgv::render::shader_program::build_program(), cgv::render::texture::create(), depth_tex, cgv::render::shader_program::destruct(), cgv::render::texture::destruct(), cgv::render::shader_program::disable(), cgv::render::shader_program::enable(), cgv::data::data_format::get_height(), cgv::render::context::get_height(), cgv::data::data_format::get_width(), cgv::render::context::get_width(), cgv::render::render_component::is_created(), node_counter_buffer, cgv::render::vertex_buffer::replace(), cgv::render::shader_program::set_uniform(), and cgv::render::vertex_buffer::unbind().
|
inline |
Definition at line 68 of file a_buffer.h.
|
inline |
Definition at line 70 of file a_buffer.h.
|
inline |
Definition at line 69 of file a_buffer.h.
|
inline |
Definition at line 71 of file a_buffer.h.
| 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.
|
protected |
Definition at line 14 of file a_buffer.cxx.
|
protected |
Definition at line 35 of file a_buffer.h.
|
protected |
Definition at line 34 of file a_buffer.h.
|
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().
|
protected |
Default texture unit used for depth texture.
Definition at line 28 of file a_buffer.h.
Referenced by a_buffer(), and enable().
| 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().
|
protected |
Definition at line 25 of file a_buffer.h.
|
protected |
Definition at line 31 of file a_buffer.h.
|
protected |
Definition at line 26 of file a_buffer.h.
|
protected |
Buffer binding point indices.
Definition at line 30 of file a_buffer.h.
Referenced by a_buffer(), disable(), and enable().
|
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().
|
protected |
Definition at line 32 of file a_buffer.h.
| 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().