Stefan Dösinger : wined3d: Make the context array dynamic.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Feb 13 11:07:45 CST 2007


Module: wine
Branch: master
Commit: 7253fae31fbea07f11c35f05d1b38750d0c34477
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7253fae31fbea07f11c35f05d1b38750d0c34477

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Mon Feb 12 19:35:45 2007 +0100

wined3d: Make the context array dynamic.

---

 dlls/wined3d/context.c         |    2 +-
 dlls/wined3d/device.c          |   13 +++++++++----
 dlls/wined3d/directx.c         |    6 ++++++
 dlls/wined3d/wined3d_private.h |    2 +-
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 1f6d693..6dc88fb 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -207,7 +207,7 @@ void ActivateContext(IWineD3DDeviceImpl
     /* TODO: Thread selection */
 
     /* TODO: Activate the opengl context */
-    context = &This->contexts[This->activeContext];
+    context = This->contexts[This->activeContext];
 
     switch(usage) {
         case CTXUSAGE_RESOURCELOAD:
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 1f27916..1771e63 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -350,10 +350,16 @@ static ULONG WINAPI IWineD3DDeviceImpl_R
     TRACE("(%p) : Releasing from %d\n", This, refCount + 1);
 
     if (!refCount) {
+        UINT i;
         if (This->fbo) {
             GL_EXTCALL(glDeleteFramebuffersEXT(1, &This->fbo));
         }
 
+        for(i = 0; i < This->numContexts; i++) {
+            HeapFree(GetProcessHeap(), 0, This->contexts[i]);
+        }
+        HeapFree(GetProcessHeap(), 0, This->contexts);
+
         HeapFree(GetProcessHeap(), 0, This->render_targets);
 
         HeapFree(GetProcessHeap(), 0, This->draw_buffers);
@@ -2007,8 +2013,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
 
     /* Initialize the current view state */
     This->view_ident = 1;
-    This->numContexts = 1;
-    This->contexts[0].last_was_rhw = 0;
+    This->contexts[0]->last_was_rhw = 0;
     glGetIntegerv(GL_MAX_LIGHTS, &This->maxConcurrentLights);
     TRACE("(%p) All defaults now set up, leaving Init3D with %p\n", This, This);
 
@@ -5948,7 +5953,7 @@ static void device_render_to_texture(IWi
     if (This->depth_copy_state != WINED3D_DCS_NO_COPY) {
         This->depth_copy_state = WINED3D_DCS_COPY;
     }
-    This->contexts[0].last_was_rhw = FALSE;
+    This->contexts[0]->last_was_rhw = FALSE;
     /* Viewport state will reapply the projection matrix for now */
     IWineD3DDeviceImpl_MarkStateDirty(This, WINED3DRS_CULLMODE);
 
@@ -6985,7 +6990,7 @@ void IWineD3DDeviceImpl_MarkStateDirty(I
     if(!rep) return;
 
     for(i = 0; i < This->numContexts; i++) {
-        context = &This->contexts[i];
+        context = This->contexts[i];
         if(isStateDirty(context, rep)) continue;
 
         context->dirtyArray[context->numDirtyEntries++] = rep;
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 7bd04bb..e711b10 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -2444,6 +2444,12 @@ static HRESULT  WINAPI IWineD3DImpl_Crea
     object->ddraw_format = pixelformat_for_depth(GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES));
     ReleaseDC(0, hDC);
 
+    /* Allocate one context for now */
+    object->contexts = HeapAlloc(GetProcessHeap(), 0, sizeof(WineD3DContext *));
+    object->contexts[0] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineD3DContext));
+    object->numContexts = 1;
+    object->activeContext = 0;
+
     return WINED3D_OK;
 create_device_error:
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 03d5759..7be34ac 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -695,7 +695,7 @@ struct IWineD3DDeviceImpl
     BOOL                      useDrawStridedSlow;
 
     /* Context management */
-    WineD3DContext          contexts[1];   /* Dynamic array later */
+    WineD3DContext          **contexts;   /* Dynamic array containing pointers to context structures */
     UINT                    activeContext; /* Only 0 for now      */
     UINT                    numContexts;   /* Always 1 for now    */
 };




More information about the wine-cvs mailing list