mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-29 17:27:30 +01:00
perf(debug): memory of the process and of its parts in the debug panel: resident, peak and private memory, card memory (GL_NVX_gpu_memory_info), the copies kept by the textures, geometry banks, models, scenery shapes and lines, sleepers and sound buffers
This commit is contained in:
@@ -40,6 +40,29 @@ TMdlContainer::LoadModel(std::string const &Name, bool const Dynamic) {
|
||||
TModelsManager::modelcontainer_sequence TModelsManager::m_models { 1, TMdlContainer{} };
|
||||
TModelsManager::stringmodelcontainerindex_map TModelsManager::m_modelsmap;
|
||||
|
||||
// what the loaded models keep in memory, for the debug panel
|
||||
TModelsManager::memory_data
|
||||
TModelsManager::memory() {
|
||||
|
||||
memory_data result;
|
||||
std::vector<TSubModel const *> pending;
|
||||
for( auto const &container : m_models ) {
|
||||
if( container.Model == nullptr ) { continue; }
|
||||
++result.models;
|
||||
pending.assign( 1, container.Model->Root );
|
||||
while( false == pending.empty() ) {
|
||||
auto const *submodel { pending.back() };
|
||||
pending.pop_back();
|
||||
if( submodel == nullptr ) { continue; }
|
||||
++result.submodels.count;
|
||||
result.submodels.bytes += memory_of( submodel->Vertices ) + memory_of( submodel->Userdata ) + memory_of( submodel->Indices );
|
||||
pending.push_back( submodel->Child );
|
||||
pending.push_back( submodel->Next );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// wczytanie modelu do tablicy
|
||||
TModel3d *
|
||||
TModelsManager::LoadModel(std::string const &Name, std::string const &virtualName, bool dynamic) {
|
||||
|
||||
@@ -9,6 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include "utilities/Classes.h"
|
||||
#include "utilities/memorystats.h"
|
||||
|
||||
class TMdlContainer {
|
||||
friend class TModelsManager;
|
||||
@@ -22,6 +23,13 @@ class TModelsManager {
|
||||
public:
|
||||
// McZapkie: dodalem sciezke, notabene Path!=Patch :)
|
||||
static TModel3d *GetModel(std::string const &Name, bool const dynamic = false, bool const Logerrors = true , int uid = 0);
|
||||
// what the loaded models keep in memory, for the debug panel: models, submodels with the bytes of their own copies of the
|
||||
// geometry (vertices, user data, indices; the gpu gets theirs from the geometry banks)
|
||||
struct memory_data {
|
||||
std::uint64_t models { 0 };
|
||||
memory_count submodels;
|
||||
};
|
||||
static memory_data memory();
|
||||
|
||||
private:
|
||||
// types:
|
||||
|
||||
@@ -1484,6 +1484,25 @@ texture_manager::update() {
|
||||
}
|
||||
}
|
||||
|
||||
// what the textures keep in memory, for the debug panel
|
||||
texture_manager::memory_data
|
||||
texture_manager::memory() const {
|
||||
|
||||
memory_data result;
|
||||
for( auto const &texture : m_textures ) {
|
||||
if( texture.first == nullptr ) { continue; }
|
||||
if( false == texture.first->data.empty() ) {
|
||||
++result.cpu.count;
|
||||
result.cpu.bytes += memory_of( texture.first->data );
|
||||
}
|
||||
if( texture.first->id != opengl_texture::invalid_id ) {
|
||||
++result.gpu.count;
|
||||
result.gpu.bytes += static_cast<std::uint64_t>( texture.first->size ) * 1024;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// debug performance string
|
||||
std::string
|
||||
texture_manager::info() const {
|
||||
|
||||
@@ -12,6 +12,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <istream>
|
||||
#include <limits>
|
||||
#include "winheaders.h"
|
||||
#include "utilities/memorystats.h"
|
||||
#include <string>
|
||||
#include "model/ResourceManager.h"
|
||||
#include "gl/ubo.h"
|
||||
@@ -180,6 +181,14 @@ public:
|
||||
// debug performance string
|
||||
std::string
|
||||
info() const;
|
||||
// what the textures keep in memory, for the debug panel: copies of the data kept in the process (count, bytes), and the
|
||||
// textures made on the gpu with the size of their data (count, bytes)
|
||||
struct memory_data {
|
||||
memory_count cpu;
|
||||
memory_count gpu;
|
||||
};
|
||||
memory_data
|
||||
memory() const;
|
||||
|
||||
private:
|
||||
// types:
|
||||
|
||||
Reference in New Issue
Block a user