Improved pstats support for texmem
This commit is contained in:
parent
866507bb17
commit
d7ed6d3cbd
|
|
@ -19,6 +19,8 @@ PStatCollector GraphicsStateGuardian::_total_texusage_pcollector("Texture usage"
|
|||
PStatCollector GraphicsStateGuardian::_active_texusage_pcollector("Texture usage:Active");
|
||||
PStatCollector GraphicsStateGuardian::_total_texmem_pcollector("Texture memory");
|
||||
PStatCollector GraphicsStateGuardian::_used_texmem_pcollector("Texture memory:In use");
|
||||
PStatCollector GraphicsStateGuardian::_texmgrmem_total_pcollector("Texture manager");
|
||||
PStatCollector GraphicsStateGuardian::_texmgrmem_resident_pcollector("Texture manager:Resident");
|
||||
PStatCollector GraphicsStateGuardian::_vertices_pcollector("Vertices");
|
||||
PStatCollector GraphicsStateGuardian::_vertices_tristrip_pcollector("Vertices:Triangle strips");
|
||||
PStatCollector GraphicsStateGuardian::_vertices_trifan_pcollector("Vertices:Triangle fans");
|
||||
|
|
|
|||
|
|
@ -180,6 +180,8 @@ public:
|
|||
static PStatCollector _active_texusage_pcollector;
|
||||
static PStatCollector _total_texmem_pcollector;
|
||||
static PStatCollector _used_texmem_pcollector;
|
||||
static PStatCollector _texmgrmem_total_pcollector;
|
||||
static PStatCollector _texmgrmem_resident_pcollector;
|
||||
static PStatCollector _vertices_pcollector;
|
||||
static PStatCollector _vertices_tristrip_pcollector;
|
||||
static PStatCollector _vertices_trifan_pcollector;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ estimate_texture_memory() {
|
|||
|
||||
size_t pixels = pb->get_xsize() * pb->get_ysize();
|
||||
|
||||
size_t bpp = 4;
|
||||
|
||||
/*
|
||||
size_t bpp = 1;
|
||||
switch (pb->get_format()) {
|
||||
case PixelBuffer::F_rgb332:
|
||||
|
|
@ -60,6 +63,7 @@ estimate_texture_memory() {
|
|||
bpp = 6;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
size_t bytes = pixels * bpp;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@
|
|||
#include <throw_event.h>
|
||||
#include <mmsystem.h>
|
||||
#include <pStatTimer.h>
|
||||
#include <pStatCollector.h>
|
||||
|
||||
#define DISABLE_POLYGON_OFFSET_DECALING
|
||||
// currently doesnt work well enough in toontown models for us to use
|
||||
|
|
@ -777,6 +778,12 @@ render_frame(const AllAttributesWrapper &initial_state) {
|
|||
|
||||
show_frame();
|
||||
|
||||
#ifdef DO_PSTATS
|
||||
if (_texmgrmem_total_pcollector.is_active()) {
|
||||
report_texmgr_stats();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PRINT_TEXSTATS
|
||||
{
|
||||
|
||||
|
|
@ -840,6 +847,28 @@ render_frame(const AllAttributesWrapper &initial_state) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef DO_PSTATS
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::report_texmgr_stats
|
||||
// Access: Protected
|
||||
// Description: Reports the DX texture manager's activity to PStats.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DXGraphicsStateGuardian::
|
||||
report_texmgr_stats() {
|
||||
HRESULT hr;
|
||||
|
||||
D3DDEVINFO_TEXTUREMANAGER tminfo;
|
||||
ZeroMemory(&tminfo, sizeof(tminfo));
|
||||
hr = _d3dDevice->GetInfo(D3DDEVINFOID_TEXTUREMANAGER,
|
||||
&tminfo, sizeof(tminfo));
|
||||
|
||||
// Quietly ignore an error in GetInfo().
|
||||
if (hr == D3D_OK) {
|
||||
_texmgrmem_total_pcollector.set_level(tminfo.dwTotalBytes);
|
||||
_texmgrmem_resident_pcollector.set_level(tminfo.dwWorkingSetBytes);
|
||||
}
|
||||
}
|
||||
#endif // DO_PSTATS
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::render_scene
|
||||
|
|
|
|||
|
|
@ -265,6 +265,10 @@ protected:
|
|||
size_t draw_prim_setup(const Geom *geom) ;
|
||||
void draw_multitri(const Geom *geom, D3DPRIMITIVETYPE tri_id);
|
||||
|
||||
#ifdef DO_PSTATS
|
||||
void report_texmgr_stats();
|
||||
#endif
|
||||
|
||||
// for drawing primitives
|
||||
Colorf p_color;
|
||||
Normalf p_normal;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ const float pstats_target_frame_rate = config_pstats.GetFloat("pstats-target-fra
|
|||
// not the client.
|
||||
const bool pstats_scroll_mode = config_pstats.GetBool("pstats-scroll-mode", true);
|
||||
const float pstats_history = config_pstats.GetFloat("pstats-history", 30.0);
|
||||
const bool pstats_threaded_write = config_pstats.GetBool("pstats-threaded-write", false);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: init_libpstatclient
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ extern EXPCL_PANDA const float pstats_target_frame_rate;
|
|||
extern EXPCL_PANDA const bool pstats_scroll_mode;
|
||||
extern EXPCL_PANDA const float pstats_history;
|
||||
|
||||
extern EXPCL_PANDA const bool pstats_threaded_write;
|
||||
|
||||
extern EXPCL_PANDA void init_libpstatclient();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ get_max_rate() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool PStatClient::
|
||||
connect(const string &hostname, int port) {
|
||||
return get_global_pstats()->ns_connect(hostname, port);
|
||||
return get_global_pstats()->client_connect(hostname, port);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -77,7 +77,7 @@ connect(const string &hostname, int port) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PStatClient::
|
||||
disconnect() {
|
||||
get_global_pstats()->ns_disconnect();
|
||||
get_global_pstats()->client_disconnect();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -88,5 +88,5 @@ disconnect() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool PStatClient::
|
||||
is_connected() {
|
||||
return get_global_pstats()->ns_is_connected();
|
||||
return get_global_pstats()->client_is_connected();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ PerThreadData() {
|
|||
PStatClient::
|
||||
PStatClient() :
|
||||
_reader(this, 0),
|
||||
_writer(this, 0)
|
||||
_writer(this, pstats_threaded_write ? 1 : 0)
|
||||
{
|
||||
_is_connected = false;
|
||||
_got_udp_port = false;
|
||||
|
|
@ -369,13 +369,13 @@ get_global_pstats() {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatClient::ns_connect
|
||||
// Function: PStatClient::client_connect
|
||||
// Access: Private
|
||||
// Description: The nonstatic implementation of connect().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PStatClient::
|
||||
ns_connect(string hostname, int port) {
|
||||
ns_disconnect();
|
||||
client_connect(string hostname, int port) {
|
||||
client_disconnect();
|
||||
|
||||
if (hostname.empty()) {
|
||||
hostname = pstats_host;
|
||||
|
|
@ -410,12 +410,12 @@ ns_connect(string hostname, int port) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatClient::ns_disconnect
|
||||
// Function: PStatClient::client_disconnect
|
||||
// Access: Private
|
||||
// Description: The nonstatic implementation of disconnect().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PStatClient::
|
||||
ns_disconnect() {
|
||||
client_disconnect() {
|
||||
if (_is_connected) {
|
||||
_reader.remove_connection(_tcp_connection);
|
||||
close_connection(_tcp_connection);
|
||||
|
|
@ -451,15 +451,35 @@ ns_disconnect() {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatClient::ns_is_connected
|
||||
// Function: PStatClient::client_is_connected
|
||||
// Access: Public
|
||||
// Description: The nonstatic implementation of is_connected().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PStatClient::
|
||||
ns_is_connected() const {
|
||||
client_is_connected() const {
|
||||
return _is_connected;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatClient::is_active
|
||||
// Access: Private
|
||||
// Description: Returns true if the indicated collector/thread
|
||||
// combination is active, and we are transmitting stats
|
||||
// data, or false otherwise.
|
||||
//
|
||||
// Normally you would not use this interface directly;
|
||||
// instead, call PStatCollector::is_active().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PStatClient::
|
||||
is_active(int collector_index, int thread_index) const {
|
||||
nassertr(collector_index >= 0 && collector_index < (int)_collectors.size(), false);
|
||||
nassertr(thread_index >= 0 && thread_index < (int)_threads.size(), false);
|
||||
|
||||
return (_is_connected &&
|
||||
_collectors[collector_index]._def->_is_active &&
|
||||
_threads[thread_index]._is_active);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatClient::start_collector
|
||||
// Access: Private
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@ class PStatThread;
|
|||
// Description : Manages the communications to report statistics via a
|
||||
// network connection to a remote PStatServer.
|
||||
//
|
||||
// Normally, there is only one PStatClient in the world,
|
||||
// although it is possible to have multiple PStatClients
|
||||
// if extraordinary circumstances require in. Since
|
||||
// each PStatCollector registers itself with the
|
||||
// PStatClient when it is created, having multiple
|
||||
// PStatClients requires special care when constructing
|
||||
// the various PStatCollectors.
|
||||
//
|
||||
// If DO_PSTATS is not defined, we don't want to use
|
||||
// stats at all. This class is therefore defined as a
|
||||
// stub class.
|
||||
|
|
@ -59,23 +67,26 @@ public:
|
|||
const ClockObject &get_clock() const;
|
||||
PStatThread get_main_thread() const;
|
||||
|
||||
static void main_tick();
|
||||
static PStatClient *get_global_pstats();
|
||||
|
||||
PUBLISHED:
|
||||
INLINE static bool connect(const string &hostname = string(), int port = -1);
|
||||
INLINE static void disconnect();
|
||||
INLINE static bool is_connected();
|
||||
|
||||
private:
|
||||
bool ns_connect(string hostname, int port);
|
||||
void ns_disconnect();
|
||||
bool ns_is_connected() const;
|
||||
public:
|
||||
static void main_tick();
|
||||
static PStatClient *get_global_pstats();
|
||||
|
||||
bool client_connect(string hostname, int port);
|
||||
void client_disconnect();
|
||||
bool client_is_connected() const;
|
||||
|
||||
private:
|
||||
PStatCollector make_collector_with_relname(int parent_index, string relname);
|
||||
PStatCollector make_collector_with_name(int parent_index, const string &name);
|
||||
PStatThread make_thread(const string &name);
|
||||
|
||||
bool is_active(int collector_index, int thread_index) const;
|
||||
|
||||
void start(int collector_index, int thread_index, float as_of);
|
||||
void stop(int collector_index, int thread_index, float as_of);
|
||||
|
||||
|
|
|
|||
|
|
@ -112,6 +112,30 @@ operator = (const PStatCollector ©) {
|
|||
_index = copy._index;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatCollector::is_active
|
||||
// Access: Public
|
||||
// Description: Returns true if this particular collector is active
|
||||
// on the default thread, and we are currently
|
||||
// transmitting PStats data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool PStatCollector::
|
||||
is_active() {
|
||||
return _client->is_active(_index, 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatCollector::is_active
|
||||
// Access: Public
|
||||
// Description: Returns true if this particular collector is active
|
||||
// on the indicated thread, and we are currently
|
||||
// transmitting PStats data.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool PStatCollector::
|
||||
is_active(const PStatThread &thread) {
|
||||
return _client->is_active(_index, thread._index);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PStatCollector::start
|
||||
// Access: Public
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ public:
|
|||
INLINE PStatCollector(const PStatCollector ©);
|
||||
INLINE void operator = (const PStatCollector ©);
|
||||
|
||||
INLINE bool is_active();
|
||||
INLINE bool is_active(const PStatThread &thread);
|
||||
|
||||
INLINE void start();
|
||||
INLINE void start(const PStatThread &thread);
|
||||
INLINE void start(const PStatThread &thread, float as_of);
|
||||
|
|
@ -87,6 +90,9 @@ public:
|
|||
const RGBColorf & = RGBColorf::zero(),
|
||||
int = -1) { }
|
||||
|
||||
INLINE bool is_active() { return false; }
|
||||
INLINE bool is_active(const PStatThread &) { return false; }
|
||||
|
||||
INLINE void start() { }
|
||||
INLINE void start(const PStatThread &) { }
|
||||
INLINE void start(const PStatThread &, float) { }
|
||||
|
|
|
|||
|
|
@ -108,10 +108,12 @@ static TimeCollectorProperties time_properties[] = {
|
|||
};
|
||||
|
||||
static LevelCollectorProperties level_properties[] = {
|
||||
{ 1, "Texture usage", { 1.0, 0.0, 0.0 }, "MB", 12, 1048576 },
|
||||
{ 1, "Texture usage:Active", { 1.0, 1.0, 0.0 } },
|
||||
{ 1, "Texture usage", { 1.0, 0.0, 0.5 }, "MB", 12, 1048576 },
|
||||
{ 1, "Texture usage:Active", { 0.5, 1.0, 0.8 } },
|
||||
{ 1, "Texture memory", { 0.0, 0.0, 1.0 }, "MB", 12, 1048576 },
|
||||
{ 1, "Texture memory:In use", { 0.0, 1.0, 1.0 } },
|
||||
{ 1, "Texture manager", { 1.0, 0.0, 0.0 }, "MB", 12, 1048576 },
|
||||
{ 1, "Texture manager:Resident", { 1.0, 1.0, 0.0 } },
|
||||
{ 1, "Vertices", { 0.5, 0.2, 0.0 }, "K", 10, 1000 },
|
||||
{ 1, "Vertices:Other", { 0.2, 0.2, 0.2 } },
|
||||
{ 1, "Vertices:Triangles", { 0.8, 0.8, 0.8 } },
|
||||
|
|
|
|||
Loading…
Reference in New Issue