[PATCH] wined3d: take into account video ram that pixel buffers use.

Jérôme Gardou jerome.gardou at laposte.net
Sun Jan 25 05:52:45 CST 2009


---
 dlls/wined3d/context.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index da3053a..86d9db4 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -635,6 +635,7 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
     HGLRC ctx = NULL, oldCtx;
     WineD3DContext *ret = NULL;
     int s;
+    long size = 0 ;
 
     TRACE("(%p): Creating a %s context for render target %p\n", This, create_pbuffer ? "offscreen" : "onscreen", target);
 
@@ -679,6 +680,9 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
             goto out;
         }
         ReleaseDC(win_handle, hdc_parent);
+        size = target->currentDesc.Width * target->currentDesc.Height * target->bytesPerPixel ;
+        if(This->adapter->cfgs[iPixelFormat].doubleBuffer)
+            size *= 2 ;
     } else {
         PIXELFORMATDESCRIPTOR pfd;
         int iPixelFormat;
@@ -898,6 +902,8 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
     }
     This->frag_pipe->enable_extension((IWineD3DDevice *) This, TRUE);
 
+    WineD3DAdapterChangeGLRam(This, size) ;
+
     return ret;
 
 out:
@@ -958,6 +964,7 @@ static void RemoveContextFromArray(IWineD3DDeviceImpl *This, WineD3DContext *con
  *****************************************************************************/
 void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context) {
     struct fbo_entry *entry, *entry2;
+    long size = 0 ;
 
     TRACE("Destroying ctx %p\n", context);
 
@@ -986,11 +993,18 @@ void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context) {
     /* Cleanup the GL context */
     pwglMakeCurrent(NULL, NULL);
     if(context->isPBuffer) {
+        int iPixelFormat = GetPixelFormat(context->hdc) ;
+        IWineD3DSurfaceImpl* surf = (IWineD3DSurfaceImpl*) context->surface ;
         GL_EXTCALL(wglReleasePbufferDCARB(context->pbuffer, context->hdc));
         GL_EXTCALL(wglDestroyPbufferARB(context->pbuffer));
+        size = surf->currentDesc.Width * surf->currentDesc.Height * surf->bytesPerPixel ;
+        if(This->adapter->cfgs[iPixelFormat].doubleBuffer)
+            size *= 2 ;
     } else ReleaseDC(context->win_handle, context->hdc);
     pwglDeleteContext(context->glCtx);
 
+    WineD3DAdapterChangeGLRam(This, (-1)*size) ;
+
     HeapFree(GetProcessHeap(), 0, context->vshader_const_dirty);
     HeapFree(GetProcessHeap(), 0, context->pshader_const_dirty);
     RemoveContextFromArray(This, context);
-- 
1.6.0.6


--------------020900080606080604010501--



More information about the wine-devel mailing list