Browse Source

Fix graphics buffer tracking.

aignacio_sf 17 years ago
parent
commit
b3f25daed7

+ 3 - 2
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

@@ -3749,11 +3749,11 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params,
     // release graphics buffer surfaces
     {
       wdxGraphicsBuffer8 *graphics_buffer;
-      list <wdxGraphicsBuffer8 *>::iterator graphics_buffer_iterator;
+      list <wdxGraphicsBuffer8 **>::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;
   }

+ 1 - 1
panda/src/dxgsg8/dxGraphicsStateGuardian8.h

@@ -269,7 +269,7 @@ protected:
   static unsigned char *_temp_buffer;
   static unsigned char *_safe_buffer_start;
 
-  list <wdxGraphicsBuffer8 *> _graphics_buffer_list;
+  list <wdxGraphicsBuffer8 **> _graphics_buffer_list;
 
 public:
   virtual TypeHandle get_type() const {

+ 11 - 2
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;
   }
 }
 

+ 2 - 0
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;