Compute & log max primitive count in ui painter
This commit is contained in:
parent
c949e0fad9
commit
fd8bec44ab
1 changed files with 11 additions and 0 deletions
|
|
@ -185,6 +185,7 @@ void main()
|
||||||
std::vector<std::variant<colored_batch, textured_batch, stencil_batch>> batches;
|
std::vector<std::variant<colored_batch, textured_batch, stencil_batch>> batches;
|
||||||
|
|
||||||
std::size_t max_batch_count = 0;
|
std::size_t max_batch_count = 0;
|
||||||
|
std::size_t max_primitive_count = 0;
|
||||||
|
|
||||||
template <typename Batch>
|
template <typename Batch>
|
||||||
Batch & batch(Batch && n)
|
Batch & batch(Batch && n)
|
||||||
|
|
@ -224,6 +225,7 @@ void main()
|
||||||
painter_impl::~painter_impl()
|
painter_impl::~painter_impl()
|
||||||
{
|
{
|
||||||
log::debug() << "UI painter max batch count: " << impl().max_batch_count;
|
log::debug() << "UI painter max batch count: " << impl().max_batch_count;
|
||||||
|
log::debug() << "UI painter max primitive count: " << impl().max_primitive_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void painter_impl::draw_rect(geom::box<float, 2> const & rect, gfx::color_rgba const & color)
|
void painter_impl::draw_rect(geom::box<float, 2> const & rect, gfx::color_rgba const & color)
|
||||||
|
|
@ -388,14 +390,21 @@ void main()
|
||||||
|
|
||||||
gl::ActiveTexture(gl::TEXTURE0);
|
gl::ActiveTexture(gl::TEXTURE0);
|
||||||
|
|
||||||
|
std::size_t primitive_count = 0;
|
||||||
|
|
||||||
auto batch_visitor = util::overload(
|
auto batch_visitor = util::overload(
|
||||||
[&](colored_batch const & b){
|
[&](colored_batch const & b){
|
||||||
|
primitive_count += b.indices.size() / 3;
|
||||||
|
|
||||||
impl().colored_program.bind();
|
impl().colored_program.bind();
|
||||||
impl().colored_mesh.load(b.vertices, b.indices, gl::TRIANGLES);
|
impl().colored_mesh.load(b.vertices, b.indices, gl::TRIANGLES);
|
||||||
impl().colored_mesh.draw();
|
impl().colored_mesh.draw();
|
||||||
},
|
},
|
||||||
[&](textured_batch const & b){
|
[&](textured_batch const & b){
|
||||||
if (!b.texture) return;
|
if (!b.texture) return;
|
||||||
|
|
||||||
|
primitive_count += b.indices.size() / 3;
|
||||||
|
|
||||||
gfx::program & program = (b.mode == ui::painter::color_mode::mix) ? impl().textured_mix_program : impl().textured_multiply_program;
|
gfx::program & program = (b.mode == ui::painter::color_mode::mix) ? impl().textured_mix_program : impl().textured_multiply_program;
|
||||||
program.bind();
|
program.bind();
|
||||||
program["u_texture_size"] = geom::cast<float>(b.texture->size());
|
program["u_texture_size"] = geom::cast<float>(b.texture->size());
|
||||||
|
|
@ -437,6 +446,8 @@ void main()
|
||||||
|
|
||||||
impl().max_batch_count = std::max(impl().max_batch_count, impl().batches.size());
|
impl().max_batch_count = std::max(impl().max_batch_count, impl().batches.size());
|
||||||
|
|
||||||
|
impl().max_primitive_count = std::max(impl().max_primitive_count, primitive_count);
|
||||||
|
|
||||||
impl().depth = 0;
|
impl().depth = 0;
|
||||||
impl().batches.clear();
|
impl().batches.clear();
|
||||||
impl().stencil_level = 0;
|
impl().stencil_level = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue