mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
bracket a few more low-level things with pstats
This commit is contained in:
parent
82385a51d0
commit
be6354f9ef
@ -39,7 +39,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CPPPARSER
|
#ifndef CPPPARSER
|
||||||
PStatCollector GraphicsEngine::_show_code_pcollector("App:Show Code");
|
PStatCollector GraphicsEngine::_app_pcollector("App");
|
||||||
|
PStatCollector GraphicsEngine::_yield_pcollector("App:Yield");
|
||||||
PStatCollector GraphicsEngine::_cull_pcollector("Cull");
|
PStatCollector GraphicsEngine::_cull_pcollector("Cull");
|
||||||
PStatCollector GraphicsEngine::_draw_pcollector("Draw");
|
PStatCollector GraphicsEngine::_draw_pcollector("Draw");
|
||||||
PStatCollector GraphicsEngine::_sync_pcollector("Draw:Sync");
|
PStatCollector GraphicsEngine::_sync_pcollector("Draw:Sync");
|
||||||
@ -91,8 +92,8 @@ GraphicsEngine(Pipeline *pipeline) :
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
GraphicsEngine::
|
GraphicsEngine::
|
||||||
~GraphicsEngine() {
|
~GraphicsEngine() {
|
||||||
if (_show_code_pcollector.is_active()) {
|
if (_app_pcollector.is_started()) {
|
||||||
_show_code_pcollector.stop();
|
_app_pcollector.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_all_windows();
|
remove_all_windows();
|
||||||
@ -347,9 +348,9 @@ is_empty() const {
|
|||||||
void GraphicsEngine::
|
void GraphicsEngine::
|
||||||
render_frame() {
|
render_frame() {
|
||||||
// Anything that happens outside of GraphicsEngine::render_frame()
|
// Anything that happens outside of GraphicsEngine::render_frame()
|
||||||
// is deemed to be show code.
|
// is deemed to be App.
|
||||||
if (_show_code_pcollector.is_active()) {
|
if (_app_pcollector.is_started()) {
|
||||||
_show_code_pcollector.stop();
|
_app_pcollector.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We hold the GraphicsEngine mutex while we wait for all of the
|
// We hold the GraphicsEngine mutex while we wait for all of the
|
||||||
@ -384,7 +385,7 @@ render_frame() {
|
|||||||
_transform_states_unused_pcollector.set_level(TransformState::get_num_unused_states());
|
_transform_states_unused_pcollector.set_level(TransformState::get_num_unused_states());
|
||||||
_render_states_unused_pcollector.set_level(RenderState::get_num_unused_states());
|
_render_states_unused_pcollector.set_level(RenderState::get_num_unused_states());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now signal all of our threads to begin their next frame.
|
// Now signal all of our threads to begin their next frame.
|
||||||
_app.do_frame(this);
|
_app.do_frame(this);
|
||||||
for (ti = _threads.begin(); ti != _threads.end(); ++ti) {
|
for (ti = _threads.begin(); ti != _threads.end(); ++ti) {
|
||||||
@ -409,6 +410,7 @@ render_frame() {
|
|||||||
if (yield_timeslice) {
|
if (yield_timeslice) {
|
||||||
// Nap for a moment to yield the timeslice, to be polite to other
|
// Nap for a moment to yield the timeslice, to be polite to other
|
||||||
// running applications.
|
// running applications.
|
||||||
|
PStatTimer timer(_yield_pcollector);
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
@ -416,8 +418,8 @@ render_frame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Anything that happens outside of GraphicsEngine::render_frame()
|
// Anything that happens outside of GraphicsEngine::render_frame()
|
||||||
// is deemed to be show code.
|
// is deemed to be App.
|
||||||
_show_code_pcollector.start();
|
_app_pcollector.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -192,7 +192,8 @@ private:
|
|||||||
FlipState _flip_state;
|
FlipState _flip_state;
|
||||||
Mutex _lock;
|
Mutex _lock;
|
||||||
|
|
||||||
static PStatCollector _show_code_pcollector;
|
static PStatCollector _app_pcollector;
|
||||||
|
static PStatCollector _yield_pcollector;
|
||||||
static PStatCollector _cull_pcollector;
|
static PStatCollector _cull_pcollector;
|
||||||
static PStatCollector _draw_pcollector;
|
static PStatCollector _draw_pcollector;
|
||||||
static PStatCollector _sync_pcollector;
|
static PStatCollector _sync_pcollector;
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
|
|
||||||
TypeHandle GraphicsOutput::_type_handle;
|
TypeHandle GraphicsOutput::_type_handle;
|
||||||
|
|
||||||
|
#ifndef CPPPARSER
|
||||||
|
PStatCollector GraphicsOutput::_make_current_pcollector("Draw:Make current");
|
||||||
|
#endif // CPPPARSER
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsOutput::Constructor
|
// Function: GraphicsOutput::Constructor
|
||||||
// Access: Protected
|
// Access: Protected
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "clearableRegion.h"
|
#include "clearableRegion.h"
|
||||||
|
|
||||||
#include "typedWritableReferenceCount.h"
|
#include "typedWritableReferenceCount.h"
|
||||||
|
#include "pStatCollector.h"
|
||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
#include "pmutex.h"
|
#include "pmutex.h"
|
||||||
#include "filename.h"
|
#include "filename.h"
|
||||||
@ -153,6 +154,8 @@ protected:
|
|||||||
int _y_size;
|
int _y_size;
|
||||||
bool _has_size;
|
bool _has_size;
|
||||||
bool _is_valid;
|
bool _is_valid;
|
||||||
|
|
||||||
|
static PStatCollector _make_current_pcollector;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
|
@ -59,6 +59,7 @@ PStatCollector GraphicsStateGuardian::_transform_state_pcollector("State changes
|
|||||||
PStatCollector GraphicsStateGuardian::_texture_state_pcollector("State changes:Textures");
|
PStatCollector GraphicsStateGuardian::_texture_state_pcollector("State changes:Textures");
|
||||||
PStatCollector GraphicsStateGuardian::_other_state_pcollector("State changes:Other");
|
PStatCollector GraphicsStateGuardian::_other_state_pcollector("State changes:Other");
|
||||||
PStatCollector GraphicsStateGuardian::_draw_primitive_pcollector("Draw:Primitive");
|
PStatCollector GraphicsStateGuardian::_draw_primitive_pcollector("Draw:Primitive");
|
||||||
|
PStatCollector GraphicsStateGuardian::_clear_pcollector("Draw:Clear");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -346,6 +347,8 @@ set_depth_clear_value(const float value) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void GraphicsStateGuardian::
|
void GraphicsStateGuardian::
|
||||||
clear(ClearableRegion *clearable) {
|
clear(ClearableRegion *clearable) {
|
||||||
|
PStatTimer timer(_clear_pcollector);
|
||||||
|
|
||||||
int clear_buffer_type = 0;
|
int clear_buffer_type = 0;
|
||||||
if (clearable->get_clear_color_active()) {
|
if (clearable->get_clear_color_active()) {
|
||||||
clear_buffer_type |= RenderBuffer::T_back;
|
clear_buffer_type |= RenderBuffer::T_back;
|
||||||
|
@ -295,6 +295,7 @@ public:
|
|||||||
static PStatCollector _texture_state_pcollector;
|
static PStatCollector _texture_state_pcollector;
|
||||||
static PStatCollector _other_state_pcollector;
|
static PStatCollector _other_state_pcollector;
|
||||||
static PStatCollector _draw_primitive_pcollector;
|
static PStatCollector _draw_primitive_pcollector;
|
||||||
|
static PStatCollector _clear_pcollector;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class LightInfo {
|
class LightInfo {
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "graphicsPipe.h"
|
#include "graphicsPipe.h"
|
||||||
#include "glgsg.h"
|
#include "glgsg.h"
|
||||||
|
#include "pStatTimer.h"
|
||||||
|
|
||||||
TypeHandle glxGraphicsBuffer::_type_handle;
|
TypeHandle glxGraphicsBuffer::_type_handle;
|
||||||
|
|
||||||
@ -60,7 +61,9 @@ glxGraphicsBuffer::
|
|||||||
// is ready for drawing.
|
// is ready for drawing.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void glxGraphicsBuffer::
|
void glxGraphicsBuffer::
|
||||||
make_current() {
|
make_current() {
|
||||||
|
PStatTimer timer(_make_current_pcollector);
|
||||||
|
|
||||||
glxGraphicsStateGuardian *glxgsg;
|
glxGraphicsStateGuardian *glxgsg;
|
||||||
DCAST_INTO_V(glxgsg, _gsg);
|
DCAST_INTO_V(glxgsg, _gsg);
|
||||||
glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
|
glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "mouseButton.h"
|
#include "mouseButton.h"
|
||||||
#include "glgsg.h"
|
#include "glgsg.h"
|
||||||
#include "clockObject.h"
|
#include "clockObject.h"
|
||||||
|
#include "pStatTimer.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -75,6 +76,8 @@ glxGraphicsWindow::
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void glxGraphicsWindow::
|
void glxGraphicsWindow::
|
||||||
make_current() {
|
make_current() {
|
||||||
|
PStatTimer timer(_make_current_pcollector);
|
||||||
|
|
||||||
glxGraphicsStateGuardian *glxgsg;
|
glxGraphicsStateGuardian *glxgsg;
|
||||||
DCAST_INTO_V(glxgsg, _gsg);
|
DCAST_INTO_V(glxgsg, _gsg);
|
||||||
glXMakeCurrent(_display, _xwindow, glxgsg->_context);
|
glXMakeCurrent(_display, _xwindow, glxgsg->_context);
|
||||||
|
@ -43,6 +43,7 @@ PStatClient *PStatClient::_global_pstats = NULL;
|
|||||||
PStatCollector _total_size_pcollector("Memory usage");
|
PStatCollector _total_size_pcollector("Memory usage");
|
||||||
PStatCollector _cpp_size_pcollector("Memory usage:C++");
|
PStatCollector _cpp_size_pcollector("Memory usage:C++");
|
||||||
PStatCollector _interpreter_size_pcollector("Memory usage:Interpreter");
|
PStatCollector _interpreter_size_pcollector("Memory usage:Interpreter");
|
||||||
|
PStatCollector _pstats_pcollector("App:PStats");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -557,6 +558,25 @@ is_active(int collector_index, int thread_index) const {
|
|||||||
_threads[thread_index]._is_active);
|
_threads[thread_index]._is_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PStatClient::is_started
|
||||||
|
// Access: Private
|
||||||
|
// Description: Returns true if the indicated collector/thread
|
||||||
|
// combination has been started, or false otherwise.
|
||||||
|
//
|
||||||
|
// Normally you would not use this interface directly;
|
||||||
|
// instead, call PStatCollector::is_started().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool PStatClient::
|
||||||
|
is_started(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 (_collectors[collector_index]._def->_is_active &&
|
||||||
|
_threads[thread_index]._is_active &&
|
||||||
|
_collectors[collector_index]._per_thread[thread_index]._nested_count != 0);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PStatClient::start
|
// Function: PStatClient::start
|
||||||
// Access: Private
|
// Access: Private
|
||||||
@ -798,6 +818,10 @@ new_frame(int thread_index) {
|
|||||||
thread._frame_data.clear();
|
thread._frame_data.clear();
|
||||||
thread._frame_number++;
|
thread._frame_number++;
|
||||||
start(0, thread_index, frame_start);
|
start(0, thread_index, frame_start);
|
||||||
|
|
||||||
|
// Also record the time for the PStats operation itself.
|
||||||
|
start(_pstats_pcollector.get_index(), thread_index, frame_start);
|
||||||
|
stop(_pstats_pcollector.get_index(), thread_index, _clock.get_real_time());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -104,6 +104,7 @@ private:
|
|||||||
PStatThread make_thread(const string &name);
|
PStatThread make_thread(const string &name);
|
||||||
|
|
||||||
bool is_active(int collector_index, int thread_index) const;
|
bool is_active(int collector_index, int thread_index) const;
|
||||||
|
bool is_started(int collector_index, int thread_index) const;
|
||||||
|
|
||||||
void start(int collector_index, int thread_index);
|
void start(int collector_index, int thread_index);
|
||||||
void start(int collector_index, int thread_index, float as_of);
|
void start(int collector_index, int thread_index, float as_of);
|
||||||
|
@ -137,6 +137,17 @@ is_active() {
|
|||||||
return _client->is_active(_index, 0);
|
return _client->is_active(_index, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PStatCollector::is_started
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns true if this particular collector has been
|
||||||
|
// started on the default thread, or false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool PStatCollector::
|
||||||
|
is_started() {
|
||||||
|
return _client->is_started(_index, 0);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PStatCollector::start
|
// Function: PStatCollector::start
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -234,6 +245,17 @@ is_active(const PStatThread &thread) {
|
|||||||
return _client->is_active(_index, thread._index);
|
return _client->is_active(_index, thread._index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PStatCollector::is_started
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns true if this particular collector has been
|
||||||
|
// started on the indicated thread, or false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool PStatCollector::
|
||||||
|
is_started(const PStatThread &thread) {
|
||||||
|
return _client->is_started(_index, thread._index);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PStatCollector::start
|
// Function: PStatCollector::start
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -345,6 +367,17 @@ get_level(const PStatThread &thread) {
|
|||||||
return _client->get_level(_index, thread._index);
|
return _client->get_level(_index, thread._index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PStatCollector::get_index
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns the index number of this particular collector
|
||||||
|
// within the PStatClient.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE int PStatCollector::
|
||||||
|
get_index() const {
|
||||||
|
return _index;
|
||||||
|
}
|
||||||
|
|
||||||
#else // DO_PSTATS
|
#else // DO_PSTATS
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -67,6 +67,7 @@ PUBLISHED:
|
|||||||
INLINE void operator = (const PStatCollector ©);
|
INLINE void operator = (const PStatCollector ©);
|
||||||
|
|
||||||
INLINE bool is_active();
|
INLINE bool is_active();
|
||||||
|
INLINE bool is_started();
|
||||||
INLINE void start();
|
INLINE void start();
|
||||||
INLINE void stop();
|
INLINE void stop();
|
||||||
|
|
||||||
@ -76,8 +77,11 @@ PUBLISHED:
|
|||||||
INLINE void sub_level(float decrement);
|
INLINE void sub_level(float decrement);
|
||||||
INLINE float get_level();
|
INLINE float get_level();
|
||||||
|
|
||||||
|
INLINE int get_index() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
INLINE bool is_active(const PStatThread &thread);
|
INLINE bool is_active(const PStatThread &thread);
|
||||||
|
INLINE bool is_started(const PStatThread &thread);
|
||||||
INLINE void start(const PStatThread &thread);
|
INLINE void start(const PStatThread &thread);
|
||||||
INLINE void start(const PStatThread &thread, float as_of);
|
INLINE void start(const PStatThread &thread, float as_of);
|
||||||
INLINE void stop(const PStatThread &thread);
|
INLINE void stop(const PStatThread &thread);
|
||||||
|
@ -104,7 +104,6 @@ struct LevelCollectorProperties {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static TimeCollectorProperties time_properties[] = {
|
static TimeCollectorProperties time_properties[] = {
|
||||||
{ 1, "Swap buffers", { 0.5, 1.0, 0.8 } },
|
|
||||||
{ 1, "App", { 0.0, 0.8, 0.4 }, 1.0 / 30.0 },
|
{ 1, "App", { 0.0, 0.8, 0.4 }, 1.0 / 30.0 },
|
||||||
{ 1, "App:Animation", { 1.0, 0.0, 1.0 } },
|
{ 1, "App:Animation", { 1.0, 0.0, 1.0 } },
|
||||||
{ 1, "App:Collisions", { 1.0, 0.5, 0.0 } },
|
{ 1, "App:Collisions", { 1.0, 0.5, 0.0 } },
|
||||||
@ -122,9 +121,11 @@ static TimeCollectorProperties time_properties[] = {
|
|||||||
{ 1, "Cull:Show fps", { 0.5, 0.8, 1.0 } },
|
{ 1, "Cull:Show fps", { 0.5, 0.8, 1.0 } },
|
||||||
{ 1, "Cull:Bins", { 0.3, 0.6, 0.3 } },
|
{ 1, "Cull:Bins", { 0.3, 0.6, 0.3 } },
|
||||||
{ 1, "Draw", { 1.0, 0.0, 0.0 }, 1.0 / 30.0 },
|
{ 1, "Draw", { 1.0, 0.0, 0.0 }, 1.0 / 30.0 },
|
||||||
|
{ 1, "Draw:Make current", { 0.4, 0.2, 0.6 } },
|
||||||
|
{ 1, "Draw:Clear", { 0.0, 0.8, 0.6 } },
|
||||||
{ 1, "Draw:Sync", { 0.5, 0.7, 0.7 } },
|
{ 1, "Draw:Sync", { 0.5, 0.7, 0.7 } },
|
||||||
{ 1, "Draw:Flip", { 1.0, 0.6, 0.3 } },
|
{ 1, "Draw:Flip", { 1.0, 0.6, 0.3 } },
|
||||||
{ 1, "Draw:Bins", { 0.3, 0.6, 0.3 } },
|
{ 1, "Draw:Bins", { 0.3, 0.6, 0.0 } },
|
||||||
{ 0, "Draw:Primitive", { 0.0, 0.0, 0.5 } },
|
{ 0, "Draw:Primitive", { 0.0, 0.0, 0.5 } },
|
||||||
{ 0, NULL }
|
{ 0, NULL }
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user