mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
SceneGraphAnalyzer: Use smarter units for byte sizes in write()
Values above 10 MiB are displayed in MiB and values above 4 GiB are displayed in GiB. Closes #881
This commit is contained in:
parent
a01711148b
commit
46dc9444d3
@ -32,6 +32,22 @@
|
||||
#include "pta_ushort.h"
|
||||
#include "geomVertexReader.h"
|
||||
|
||||
static std::string smart_mem_string(size_t bytes) {
|
||||
std::ostringstream out;
|
||||
float fbytes = static_cast<float>(bytes);
|
||||
if (bytes > 4294967296) { // 4 GiB
|
||||
out << std::setprecision(3) << fbytes / 1024.0 / 1024.0 / 1024.0 << " GiB";
|
||||
}
|
||||
else if (bytes > 10485760) { // 10 MiB
|
||||
out << std::setprecision(3) << fbytes / 1024.0 / 1024.0 << " MiB";
|
||||
}
|
||||
else {
|
||||
out << std::setprecision(3) << fbytes / 1024.0 << " KiB";
|
||||
}
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -153,12 +169,12 @@ write(std::ostream &out, int indent_level) const {
|
||||
}
|
||||
|
||||
indent(out, indent_level)
|
||||
<< "GeomVertexData arrays occupy " << (_vertex_data_size + 1023) / 1024
|
||||
<< "K memory.\n";
|
||||
<< "GeomVertexData arrays occupy " << smart_mem_string(_vertex_data_size)
|
||||
<< " memory.\n";
|
||||
|
||||
indent(out, indent_level)
|
||||
<< "GeomPrimitive arrays occupy " << (_prim_data_size + 1023) / 1024
|
||||
<< "K memory.\n";
|
||||
<< "GeomPrimitive arrays occupy " << smart_mem_string(_prim_data_size)
|
||||
<< " memory.\n";
|
||||
|
||||
int unreferenced_vertices = 0;
|
||||
VDatas::const_iterator vdi;
|
||||
@ -257,7 +273,7 @@ write(std::ostream &out, int indent_level) const {
|
||||
|
||||
indent(out, indent_level)
|
||||
<< _textures.size() << " textures, estimated minimum "
|
||||
<< (_texture_bytes + 1023) / 1024 << "K texture memory required.\n";
|
||||
<< smart_mem_string(_texture_bytes) << " texture memory required.\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user