mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
Fix glObjectLabel error, fix crash on shutdown with pstats-gpu-timing
This commit is contained in:
parent
c5dd6c69dd
commit
c2aa6991d6
@ -2732,6 +2732,13 @@ close_gsg() {
|
||||
Thread *current_thread = Thread::get_current_thread();
|
||||
_prepared_objects->begin_frame(this, current_thread);
|
||||
_prepared_objects->end_frame(current_thread);
|
||||
|
||||
// We have to clear the list of timer queries, though, otherwise
|
||||
// their destructors will cause a crash when they try to access
|
||||
// the GSG object.
|
||||
#ifdef DO_PSTATS
|
||||
_pending_timer_queries.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -445,18 +445,6 @@ rebuild_bitplanes() {
|
||||
if (_fbo[layer] == 0) {
|
||||
glgsg->_glGenFramebuffers(1, &_fbo[layer]);
|
||||
|
||||
#ifndef OPENGLES
|
||||
if (glgsg->_use_object_labels) {
|
||||
if (num_fbos > 1) {
|
||||
GLchar name[128];
|
||||
GLsizei len = snprintf(name, 128, "%s[%d]", _name.c_str(), layer);
|
||||
glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], len, name);
|
||||
} else {
|
||||
glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], _name.size(), _name.data());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_fbo[layer] == 0) {
|
||||
report_my_gl_errors();
|
||||
return;
|
||||
@ -464,6 +452,19 @@ rebuild_bitplanes() {
|
||||
}
|
||||
glgsg->bind_fbo(_fbo[layer]);
|
||||
|
||||
#ifndef OPENGLES
|
||||
if (glgsg->_use_object_labels) {
|
||||
// Assign a label for OpenGL to use when displaying debug messages.
|
||||
if (num_fbos > 1) {
|
||||
GLchar name[128];
|
||||
GLsizei len = snprintf(name, 128, "%s[%d]", _name.c_str(), layer);
|
||||
glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], len, name);
|
||||
} else {
|
||||
glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], _name.size(), _name.data());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// For all slots, update the slot.
|
||||
if (_use_depth_stencil) {
|
||||
bind_slot(layer, rb_resize, attach, RTP_depth_stencil, GL_DEPTH_ATTACHMENT_EXT);
|
||||
|
@ -5122,6 +5122,9 @@ issue_timer_query(int pstats_index) {
|
||||
}
|
||||
}
|
||||
|
||||
// Issue the timestamp query.
|
||||
_glQueryCounter(query->_index, GL_TIMESTAMP);
|
||||
|
||||
if (_use_object_labels) {
|
||||
// Assign a label to it based on the PStatCollector name.
|
||||
const PStatClient *client = PStatClient::get_global_pstats();
|
||||
@ -5129,9 +5132,6 @@ issue_timer_query(int pstats_index) {
|
||||
_glObjectLabel(GL_QUERY, query->_index, name.size(), name.data());
|
||||
}
|
||||
|
||||
// Issue the timestamp query.
|
||||
_glQueryCounter(query->_index, GL_TIMESTAMP);
|
||||
|
||||
_pending_timer_queries.push_back((TimerQueryContext *)query);
|
||||
|
||||
return (TimerQueryContext *)query;
|
||||
|
@ -30,9 +30,14 @@ CLP(TimerQueryContext)::
|
||||
~CLP(TimerQueryContext)() {
|
||||
if (_index != 0) {
|
||||
// Tell the GSG to recycle this index when it gets around to it.
|
||||
LightMutexHolder holder(_glgsg->_lock);
|
||||
_glgsg->_deleted_queries.push_back(_index);
|
||||
_index = 0;
|
||||
// If it has already shut down, though, too bad. This means we
|
||||
// never get to free this index, but presumably the app is
|
||||
// already shutting down anyway.
|
||||
if (!_glgsg.was_deleted()) {
|
||||
LightMutexHolder holder(_glgsg->_lock);
|
||||
_glgsg->_deleted_queries.push_back(_index);
|
||||
_index = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
virtual double get_timestamp() const;
|
||||
|
||||
GLuint _index;
|
||||
CLP(GraphicsStateGuardian) *_glgsg;
|
||||
WPT(CLP(GraphicsStateGuardian)) _glgsg;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user