Add in profiling counters
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include "core.hpp"
|
#include "core.hpp"
|
||||||
#include "engine/buffers/Buffer.hpp"
|
#include "engine/buffers/Buffer.hpp"
|
||||||
#include "engine/literals/size.hpp"
|
#include "engine/literals/size.hpp"
|
||||||
|
#include "engine/profiling/counters.hpp"
|
||||||
#include "safe_include.hpp"
|
#include "safe_include.hpp"
|
||||||
|
|
||||||
namespace fgl::engine::gui
|
namespace fgl::engine::gui
|
||||||
@@ -75,6 +76,21 @@ namespace fgl::engine::gui
|
|||||||
ImGui::Text( "|- %s Unused", to_string( host.free() ).c_str() );
|
ImGui::Text( "|- %s Unused", to_string( host.free() ).c_str() );
|
||||||
ImGui::Text( "|- %s Available in most allocated buffer", to_string( host.m_largest_free_block ).c_str() );
|
ImGui::Text( "|- %s Available in most allocated buffer", to_string( host.m_largest_free_block ).c_str() );
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if ( ImGui::CollapsingHeader( "Buffers" ) )
|
||||||
|
{
|
||||||
|
for ( const auto* buffer : memory::getActiveBuffers() )
|
||||||
|
{
|
||||||
|
ImGui::Text( "Name: %s", "FIXME" );
|
||||||
|
ImGui::Text(
|
||||||
|
"Allocated: %s/%s (%2.1f\%)",
|
||||||
|
to_string( buffer->used() ).c_str(),
|
||||||
|
to_string( buffer->size() ).c_str(),
|
||||||
|
( static_cast< float >( buffer->used() ) / static_cast< float >( buffer->size() ) * 100.0f ) );
|
||||||
|
ImGui::Text( "Largest block: %s", to_string( buffer->largestBlock() ).c_str() );
|
||||||
|
ImGui::Separator();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawStats( const FrameInfo& info )
|
void drawStats( const FrameInfo& info )
|
||||||
@@ -82,6 +98,12 @@ namespace fgl::engine::gui
|
|||||||
ImGui::Begin( "Stats" );
|
ImGui::Begin( "Stats" );
|
||||||
|
|
||||||
ImGui::Text( "FPS: %0.1f", ImGui::GetIO().Framerate );
|
ImGui::Text( "FPS: %0.1f", ImGui::GetIO().Framerate );
|
||||||
|
const auto& counters { profiling::getCounters() };
|
||||||
|
ImGui::Text( "Models drawn: %zu", counters.models_draw );
|
||||||
|
ImGui::Text( "Verts drawn: %zu", counters.verts_drawn );
|
||||||
|
|
||||||
|
//TODO: This should likely be moved to the just before we start rendering again.
|
||||||
|
profiling::resetCounters();
|
||||||
|
|
||||||
if ( ImGui::CollapsingHeader( "Memory" ) )
|
if ( ImGui::CollapsingHeader( "Memory" ) )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ namespace fgl::engine
|
|||||||
EngineContext::EngineContext() :
|
EngineContext::EngineContext() :
|
||||||
m_ubo_buffer_pool( 512_KiB, vk::BufferUsageFlagBits::eUniformBuffer, vk::MemoryPropertyFlagBits::eHostVisible ),
|
m_ubo_buffer_pool( 512_KiB, vk::BufferUsageFlagBits::eUniformBuffer, vk::MemoryPropertyFlagBits::eHostVisible ),
|
||||||
m_matrix_info_pool(
|
m_matrix_info_pool(
|
||||||
512_KiB,
|
2_MiB,
|
||||||
vk::BufferUsageFlagBits::eVertexBuffer,
|
vk::BufferUsageFlagBits::eVertexBuffer,
|
||||||
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible ),
|
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible ),
|
||||||
m_draw_parameter_pool(
|
m_draw_parameter_pool(
|
||||||
16_KiB,
|
1_MiB,
|
||||||
vk::BufferUsageFlagBits::eIndirectBuffer,
|
vk::BufferUsageFlagBits::eIndirectBuffer,
|
||||||
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible ),
|
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible ),
|
||||||
m_delta_time( 0.0 )
|
m_delta_time( 0.0 )
|
||||||
|
|||||||
40
src/engine/profiling/counters.cpp
Normal file
40
src/engine/profiling/counters.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// Created by kj16609 on 8/8/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "counters.hpp"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace fgl::engine::profiling
|
||||||
|
{
|
||||||
|
inline static Counters counters;
|
||||||
|
|
||||||
|
Counters& getCounters()
|
||||||
|
{
|
||||||
|
return counters;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addModelDrawn( std::size_t n )
|
||||||
|
{
|
||||||
|
counters.models_draw += n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addVertexDrawn( std::size_t n )
|
||||||
|
{
|
||||||
|
counters.verts_drawn += n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetCounters()
|
||||||
|
{
|
||||||
|
counters.verts_drawn = 0;
|
||||||
|
counters.models_draw = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In order for resetCounters to work we need to ensure we can just zero the struct.
|
||||||
|
// It being trivially copyable fits this requirement
|
||||||
|
static_assert( std::is_trivially_copyable_v< Counters > );
|
||||||
|
static_assert( std::is_trivially_default_constructible_v< Counters > );
|
||||||
|
|
||||||
|
} // namespace fgl::engine::profiling
|
||||||
24
src/engine/profiling/counters.hpp
Normal file
24
src/engine/profiling/counters.hpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// Created by kj16609 on 8/8/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace fgl::engine::profiling
|
||||||
|
{
|
||||||
|
struct Counters
|
||||||
|
{
|
||||||
|
std::size_t verts_drawn;
|
||||||
|
std::size_t models_draw;
|
||||||
|
};
|
||||||
|
|
||||||
|
Counters& getCounters();
|
||||||
|
|
||||||
|
void addModelDrawn( std::size_t n = 1 );
|
||||||
|
void addVertexDrawn( std::size_t n );
|
||||||
|
|
||||||
|
void resetCounters();
|
||||||
|
|
||||||
|
} // namespace fgl::engine::profiling
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "DrawPair.hpp"
|
#include "DrawPair.hpp"
|
||||||
#include "engine/camera/Camera.hpp"
|
#include "engine/camera/Camera.hpp"
|
||||||
#include "engine/literals/size.hpp"
|
#include "engine/literals/size.hpp"
|
||||||
|
#include "engine/profiling/counters.hpp"
|
||||||
#include "engine/tree/octtree/OctTreeNode.hpp"
|
#include "engine/tree/octtree/OctTreeNode.hpp"
|
||||||
|
|
||||||
namespace fgl::engine
|
namespace fgl::engine
|
||||||
@@ -132,6 +133,8 @@ namespace fgl::engine
|
|||||||
|
|
||||||
if ( draw_commands.empty() ) return;
|
if ( draw_commands.empty() ) return;
|
||||||
|
|
||||||
|
profiling::addModelDrawn( model_matricies.size() );
|
||||||
|
|
||||||
auto& model_matrix_info_buffer { m_textured_model_matrix_info_buffers[ info.frame_idx ] };
|
auto& model_matrix_info_buffer { m_textured_model_matrix_info_buffers[ info.frame_idx ] };
|
||||||
model_matrix_info_buffer =
|
model_matrix_info_buffer =
|
||||||
std::make_unique< ModelMatrixInfoBufferSuballocation >( info.model_matrix_info_buffer, model_matricies );
|
std::make_unique< ModelMatrixInfoBufferSuballocation >( info.model_matrix_info_buffer, model_matricies );
|
||||||
|
|||||||
Reference in New Issue
Block a user