From 706ce05aa84117ac04d262dbbeeccd27acd98730 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 17 Mar 2006 00:31:09 +0000 Subject: [PATCH] fix minor ordering issues --- panda/src/display/graphicsStateGuardian.cxx | 2 +- .../glstuff/glGraphicsStateGuardian_src.cxx | 33 ++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 5931a3e680..4c37882ec3 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -988,7 +988,6 @@ begin_frame() { //////////////////////////////////////////////////////////////////// bool GraphicsStateGuardian:: begin_scene() { - _prepared_objects->end_frame(); return true; } @@ -1058,6 +1057,7 @@ end_scene() { //////////////////////////////////////////////////////////////////// void GraphicsStateGuardian:: end_frame() { + _prepared_objects->end_frame(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 6a772689cb..140d49da69 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1207,6 +1207,24 @@ begin_frame() { //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: end_frame() { +#ifdef DO_PSTATS + // Check for textures, etc., that are no longer resident. These + // calls might be measurably expensive, and they don't have any + // benefit unless we are actually viewing PStats, so don't do them + // unless we're connected. That will just mean that we'll count + // everything as resident until the user connects PStats, at which + // point it will then correct the assessment. No harm done. + if (PStatClient::is_connected()) { + check_nonresident_texture(_prepared_objects->_texture_residency.get_inactive_resident()); + check_nonresident_texture(_prepared_objects->_texture_residency.get_active_resident()); + + // OpenGL provides no methods for querying whether a buffer object + // (vertex buffer) is resident. In fact, the API appears geared + // towards the assumption that such buffers are always resident. + // OK. + } +#endif + GraphicsStateGuardian::end_frame(); // Now is a good time to delete any pending display lists. @@ -1236,17 +1254,6 @@ end_frame() { GLP(Flush)(); } -#ifdef DO_PSTATS - // Check for textures, etc., that are no longer resident. - check_nonresident_texture(_prepared_objects->_texture_residency.get_inactive_resident()); - check_nonresident_texture(_prepared_objects->_texture_residency.get_active_resident()); - - // OpenGL provides no methods for querying whether a buffer object - // (vertex buffer) is resident. In fact, the API appears geared - // towards the assumption that such buffers are always resident. - // OK. -#endif - report_my_gl_errors(); } @@ -6751,6 +6758,10 @@ get_texture_memory_size(Texture *tex) const { void CLP(GraphicsStateGuardian):: check_nonresident_texture(BufferContextChain &chain) { size_t num_textures = chain.get_count(); + if (num_textures == 0) { + return; + } + CLP(TextureContext) **gtc_list = (CLP(TextureContext) **)alloca(num_textures * sizeof(CLP(TextureContext) *)); GLuint *texture_list = (GLuint *)alloca(num_textures * sizeof(GLuint)); size_t ti = 0;