Stefan Dösinger : wined3d: Create multiple contexts for onscreen render targets.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 3 08:01:25 CDT 2007


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

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Sat Jun  2 20:21:57 2007 +0000

wined3d: Create multiple contexts for onscreen render targets.

---

 dlls/wined3d/context.c         |    4 ++--
 dlls/wined3d/swapchain.c       |   30 ++++++++++++++++++++++++++++++
 dlls/wined3d/wined3d_private.h |    2 ++
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 0f2529a..f51cc1d 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -668,8 +668,8 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
             }
 
             if(!context) {
-                /* TODO: Create a new context for the thread */
-                FIXME("Context creation for a new thread not implemented yet\n");
+                /* Create a new context for the thread */
+                context = IWineD3DSwapChainImpl_CreateContextForThread(swapchain);
             }
             This->render_offscreen = FALSE;
             /* The context != This->activeContext will catch a NOP context change. This can occur
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index b449856..d776b4e 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -555,3 +555,33 @@ const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
     IWineD3DSwapChainImpl_SetGammaRamp,
     IWineD3DSwapChainImpl_GetGammaRamp
 };
+
+WineD3DContext *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain *iface) {
+    WineD3DContext *ctx;
+    IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *) iface;
+    WineD3DContext **newArray;
+
+    TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());
+
+    ctx = CreateContext(This->wineD3DDevice, (IWineD3DSurfaceImpl *) This->frontBuffer,
+                        This->context[0]->display, This->win);
+    if(!ctx) {
+        ERR("Failed to create a new context for the swapchain\n");
+        return NULL;
+    }
+
+    newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * This->num_contexts + 1);
+    if(!newArray) {
+        ERR("Out of memory when trying to allocate a new context array\n");
+        DestroyContext(This->wineD3DDevice, ctx);
+        return NULL;
+    }
+    memcpy(newArray, This->context, sizeof(*newArray) * This->num_contexts);
+    HeapFree(GetProcessHeap(), 0, This->context);
+    newArray[This->num_contexts] = ctx;
+    This->context = newArray;
+    This->num_contexts++;
+
+    TRACE("Returning context %p\n", ctx);
+    return ctx;
+}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 89f207e..558773c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1412,6 +1412,8 @@ typedef struct IWineD3DSwapChainImpl
 
 extern const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
 
+WineD3DContext *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain *iface);
+
 /*****************************************************************************
  * Utility function prototypes 
  */




More information about the wine-cvs mailing list