From b3f25daed71ac01bcdc2816654e07dbd05e68008 Mon Sep 17 00:00:00 2001 From: aignacio_sf <> Date: Thu, 8 Jan 2009 22:30:14 +0000 Subject: [PATCH] Fix graphics buffer tracking. --- panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx | 5 +++-- panda/src/dxgsg8/dxGraphicsStateGuardian8.h | 2 +- panda/src/dxgsg8/wdxGraphicsBuffer8.cxx | 13 +++++++++++-- panda/src/dxgsg8/wdxGraphicsBuffer8.h | 2 ++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index e4b10dd315..f1dbbdddaa 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -3749,11 +3749,11 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, // release graphics buffer surfaces { wdxGraphicsBuffer8 *graphics_buffer; - list ::iterator graphics_buffer_iterator; + list ::iterator graphics_buffer_iterator; for (graphics_buffer_iterator = _graphics_buffer_list.begin( ); graphics_buffer_iterator != _graphics_buffer_list.end( ); graphics_buffer_iterator++) { - graphics_buffer = (*graphics_buffer_iterator); + graphics_buffer = **graphics_buffer_iterator; if (graphics_buffer -> _color_backing_store) { graphics_buffer -> _color_backing_store -> Release ( ); @@ -4341,6 +4341,7 @@ void dx_set_stencil_functions (StencilRenderStates *stencil_render_states) { //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian8:: do_issue_stencil() { + if (!_supports_stencil) { return; } diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.h b/panda/src/dxgsg8/dxGraphicsStateGuardian8.h index 8fb3224a0f..a4794c1f80 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.h +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.h @@ -269,7 +269,7 @@ protected: static unsigned char *_temp_buffer; static unsigned char *_safe_buffer_start; - list _graphics_buffer_list; + list _graphics_buffer_list; public: virtual TypeHandle get_type() const { diff --git a/panda/src/dxgsg8/wdxGraphicsBuffer8.cxx b/panda/src/dxgsg8/wdxGraphicsBuffer8.cxx index 09a24bbb6a..3f1980c06d 100644 --- a/panda/src/dxgsg8/wdxGraphicsBuffer8.cxx +++ b/panda/src/dxgsg8/wdxGraphicsBuffer8.cxx @@ -58,12 +58,16 @@ wdxGraphicsBuffer8(GraphicsPipe *pipe, // same buffer we draw into. _screenshot_buffer_type = _draw_buffer_type; + _this = 0; + if (_gsg) { // save to GSG list to handle device lost issues DXGraphicsStateGuardian8 *dxgsg; dxgsg = DCAST (DXGraphicsStateGuardian8, _gsg); - dxgsg -> _graphics_buffer_list.push_back(this); + _this = new (wdxGraphicsBuffer8 *); + *_this = this; + dxgsg -> _graphics_buffer_list.push_back(_this); } } @@ -81,7 +85,12 @@ wdxGraphicsBuffer8:: DXGraphicsStateGuardian8 *dxgsg; dxgsg = DCAST (DXGraphicsStateGuardian8, _gsg); - dxgsg -> _graphics_buffer_list.remove(this); + if (_this) { + dxgsg -> _graphics_buffer_list.remove(_this); + } + _this = 0; + _gsg.clear(); + _gsg = 0; } } diff --git a/panda/src/dxgsg8/wdxGraphicsBuffer8.h b/panda/src/dxgsg8/wdxGraphicsBuffer8.h index c5e2382da3..d4b99f2524 100644 --- a/panda/src/dxgsg8/wdxGraphicsBuffer8.h +++ b/panda/src/dxgsg8/wdxGraphicsBuffer8.h @@ -69,6 +69,8 @@ private: int _backing_sizex; int _backing_sizey; + wdxGraphicsBuffer8 **_this; + public: static TypeHandle get_class_type() { return _type_handle;