[PATCH] It fixes IWineGDISwapChainImpl_Present which now behaves as the

Pavel Prochazka prochapa at inf.upol.cz
Tue May 26 11:11:11 CDT 2009


windows one. I added possbibility to create 32 backbuffers to
create really long swapchain.
---
 dlls/wined3d/device.c        |    2 +-
 dlls/wined3d/swapchain_gdi.c |   59 ++++++++++++++++++++++++++++-------------
 include/wine/wined3d.idl     |    2 +-
 3 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 83af654..d958723 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1845,7 +1845,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface,
         ERR("App requested %d back buffers, this is not supported for now\n", pPresentationParameters->BackBufferCount);
         return WINED3DERR_INVALIDCALL;
     } else if (pPresentationParameters->BackBufferCount > 1) {
-        FIXME("The app requests more than one back buffer, this can't be supported properly. Please configure the application to use double buffering(=1 back buffer) if possible\n");
+        FIXME("The app requests more than one back buffer, this can't be supported properly yet. Please configure the application to use double buffering(=1 back buffer) if possible\n");
     }
 
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
diff --git a/dlls/wined3d/swapchain_gdi.c b/dlls/wined3d/swapchain_gdi.c
index 5968201..0d108b2 100644
--- a/dlls/wined3d/swapchain_gdi.c
+++ b/dlls/wined3d/swapchain_gdi.c
@@ -166,7 +166,7 @@ static HRESULT WINAPI IWineGDISwapChainImpl_SetDestWindowOverride(IWineD3DSwapCh
 
 static HRESULT WINAPI IWineGDISwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *) iface;
-    IWineD3DSurfaceImpl *front, *back;
+    IWineD3DSurfaceImpl *front, *back,*hlp1,*hlp2;;
 
     if(!This->backBuffer) {
         WARN("Swapchain doesn't have a backbuffer, returning WINED3DERR_INVALIDCALL\n");
@@ -175,34 +175,58 @@ static HRESULT WINAPI IWineGDISwapChainImpl_Present(IWineD3DSwapChain *iface, CO
     front = (IWineD3DSurfaceImpl *) This->frontBuffer;
     back = (IWineD3DSurfaceImpl *) This->backBuffer[0];
 
+	int i=1;
+
+	/*it moves all backbuffers by 1 to left form id = 1,
+	the backbuffer swap to frontbuffer and frontbuffer swaps to the end of chain
+	Something like this:
+											------------^		
+											|			|
+	|FrontBuffer|        |BackBuffer0|BackBuffer1|Backbuffer2|....|BackbufferN|
+	           															^
+		|---------------------------------------------------------------|
+		^
+		|---------------------|
+
+											
+	*/
+
+	for(;i<This->presentParms.BackBufferCount-1;i++) 
+	{
+		hlp1 = (IWineD3DSurfaceImpl *)This->backBuffer[i];
+		hlp2 = (IWineD3DSurfaceImpl *)This->backBuffer[i+1];
+		hlp1->hDC = hlp2->hDC;
+		hlp1->dib.DIBsection = hlp2->dib.DIBsection;
+		hlp1->dib.bitmap_data = hlp2->dib.bitmap_data;
+		hlp1->resource.allocatedMemory = hlp2->resource.allocatedMemory;
+		hlp1->dib.client_memory = hlp2->dib.client_memory;
+	}
+
+	hlp1 = (IWineD3DSurfaceImpl *)This->backBuffer[i];
+	hlp1->hDC = front->hDC;
+	hlp1 = (IWineD3DSurfaceImpl *)This->backBuffer[i];
+	hlp1->dib.DIBsection = front->dib.DIBsection;
+	hlp1->dib.bitmap_data = front->dib.bitmap_data;
+	hlp1->resource.allocatedMemory = front->resource.allocatedMemory;
+	hlp1->dib.client_memory = front->dib.client_memory;
+	
+   
     /* Flip the DC */
-    {
-        HDC tmp;
-        tmp = front->hDC;
+    {        
         front->hDC = back->hDC;
-        back->hDC = tmp;
     }
 
     /* Flip the DIBsection */
     {
-        HBITMAP tmp;
-        tmp = front->dib.DIBsection;
         front->dib.DIBsection = back->dib.DIBsection;
-        back->dib.DIBsection = tmp;
     }
 
     /* Flip the surface data */
     {
-        void* tmp;
-
-        tmp = front->dib.bitmap_data;
         front->dib.bitmap_data = back->dib.bitmap_data;
-        back->dib.bitmap_data = tmp;
-
-        tmp = front->resource.allocatedMemory;
+        
         front->resource.allocatedMemory = back->resource.allocatedMemory;
-        back->resource.allocatedMemory = tmp;
-
+       
         if(front->resource.heapMemory) {
             ERR("GDI Surface %p has heap memory allocated\n", front);
         }
@@ -213,10 +237,7 @@ static HRESULT WINAPI IWineGDISwapChainImpl_Present(IWineD3DSwapChain *iface, CO
 
     /* client_memory should not be different, but just in case */
     {
-        BOOL tmp;
-        tmp = front->dib.client_memory;
         front->dib.client_memory = back->dib.client_memory;
-        back->dib.client_memory = tmp;
     }
 
     /* FPS support */
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl
index 7a476e8..11abb5c 100644
--- a/include/wine/wined3d.idl
+++ b/include/wine/wined3d.idl
@@ -868,7 +868,7 @@ const UINT WINED3DCOLORWRITEENABLE_ALPHA                        = (1<<3);
 
 const UINT WINED3DADAPTER_DEFAULT                               = 0;
 const UINT WINED3DENUM_NO_WHQL_LEVEL                            = 2;
-const UINT WINED3DPRESENT_BACK_BUFFER_MAX                       = 3;
+const UINT WINED3DPRESENT_BACK_BUFFER_MAX                       = 32;
 
 const UINT WINED3DTSS_TCI_PASSTHRU                              = 0x00000;
 const UINT WINED3DTSS_TCI_CAMERASPACENORMAL                     = 0x10000;
-- 
1.6.0.4


--------------040301050303090000060609--



More information about the wine-patches mailing list