Fix tinydisplay texture errors on shutdown

This commit is contained in:
rdb 2016-09-27 22:37:13 +02:00
parent aa74caacbe
commit 2e9394eba7
5 changed files with 23 additions and 27 deletions

View File

@ -38,6 +38,7 @@ This issue fixes several bugs that were still found in 1.9.2.
* Fix is_playing() check when playing an animation backwards
* Windows installer no longer clears %PATH% if longer than 1024 chars
* Fix inoperative -tbn/-tbnall/-tbnauto options in egg-optchar
* Fix tinydisplay texture errors on shutdown
------------------------ RELEASE 1.9.2 ------------------------

View File

@ -1800,24 +1800,9 @@ update_texture(TextureContext *tc, bool force, int stage_index, bool uses_mipmap
////////////////////////////////////////////////////////////////////
void TinyGraphicsStateGuardian::
release_texture(TextureContext *tc) {
TinyTextureContext *gtc = DCAST(TinyTextureContext, tc);
_texturing_state = 0; // just in case
GLTexture *gltex = &gtc->_gltex;
if (gltex->allocated_buffer != NULL) {
nassertv(gltex->num_levels != 0);
TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount);
PANDA_FREE_ARRAY(gltex->allocated_buffer);
gltex->allocated_buffer = NULL;
gltex->total_bytecount = 0;
gltex->num_levels = 0;
} else {
nassertv(gltex->num_levels == 0);
}
gtc->dequeue_lru();
TinyTextureContext *gtc = DCAST(TinyTextureContext, tc);
delete gtc;
}

View File

@ -26,13 +26,3 @@ TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) :
_gltex.allocated_buffer = NULL;
_gltex.total_bytecount = 0;
}
////////////////////////////////////////////////////////////////////
// Function: TinyTextureContext::Destructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE TinyTextureContext::
~TinyTextureContext() {
nassertv(_gltex.num_levels == 0 && _gltex.allocated_buffer == NULL && _gltex.total_bytecount == 0);
}

View File

@ -17,6 +17,26 @@
TypeHandle TinyTextureContext::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: TinyTextureContext::Destructor
// Access: Public
// Description: Releases the memory associated with the texture.
////////////////////////////////////////////////////////////////////
TinyTextureContext::
~TinyTextureContext() {
GLTexture *gltex = &_gltex;
if (gltex->allocated_buffer != NULL) {
nassertv(gltex->num_levels != 0);
TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount);
PANDA_FREE_ARRAY(gltex->allocated_buffer);
gltex->allocated_buffer = NULL;
gltex->total_bytecount = 0;
gltex->num_levels = 0;
} else {
nassertv(gltex->num_levels == 0);
}
}
////////////////////////////////////////////////////////////////////
// Function: TinyTextureContext::evict_lru
// Access: Public, Virtual

View File

@ -29,7 +29,7 @@ public:
INLINE TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view);
ALLOC_DELETED_CHAIN(TinyTextureContext);
INLINE ~TinyTextureContext();
~TinyTextureContext();
virtual void evict_lru();