diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 3000aca8e1..cde94080cd 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -3008,15 +3008,8 @@ close_gsg() { // will be responsible for cleaning up anything we don't clean up // explicitly. We'll just let them drop. - // However, if any objects have recently been released, we have to - // ensure they are actually deleted properly. - 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. + // Make sure that all the contexts belonging to the GSG are deleted. + _prepared_objects.clear(); #ifdef DO_PSTATS _pending_timer_queries.clear(); #endif diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 639e13a54a..8d375e9dc4 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -4689,6 +4689,13 @@ void CLP(GraphicsStateGuardian):: release_texture(TextureContext *tc) { CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); +#ifndef OPENGLES + _textures_needing_fetch_barrier.erase(gtc); + _textures_needing_image_access_barrier.erase(gtc); + _textures_needing_update_barrier.erase(gtc); + _textures_needing_framebuffer_barrier.erase(gtc); +#endif + glDeleteTextures(1, >c->_index); if (gtc->_buffer != 0) { diff --git a/panda/src/glstuff/glTextureContext_src.cxx b/panda/src/glstuff/glTextureContext_src.cxx index 470692d6bb..3238ae5a30 100644 --- a/panda/src/glstuff/glTextureContext_src.cxx +++ b/panda/src/glstuff/glTextureContext_src.cxx @@ -23,15 +23,6 @@ TypeHandle CLP(TextureContext)::_type_handle; //////////////////////////////////////////////////////////////////// CLP(TextureContext):: ~CLP(TextureContext)() { -#ifndef OPENGLES - if (gl_enable_memory_barriers) { - _glgsg->_textures_needing_fetch_barrier.erase(this); - _glgsg->_textures_needing_image_access_barrier.erase(this); - _glgsg->_textures_needing_update_barrier.erase(this); - _glgsg->_textures_needing_framebuffer_barrier.erase(this); - } -#endif - // Don't call glDeleteTextures; we may not have an active context. }