From 08d287433176c2a0a58123ae3a22c29cc89428fb Mon Sep 17 00:00:00 2001
From: Fabian Maurer <dark.shadow4@web.de>
Date: Tue, 15 Nov 2022 21:35:06 +0100
Subject: [PATCH] tests

---
 dll/directx/wine/ddraw/ddraw.c       | 10 +++-------
 dll/directx/wine/wined3d/context.c   |  3 +++
 dll/directx/wine/wined3d/swapchain.c |  2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/dll/directx/wine/ddraw/ddraw.c b/dll/directx/wine/ddraw/ddraw.c
index e5acf2caff5..2005298671a 100644
--- a/dll/directx/wine/ddraw/ddraw.c
+++ b/dll/directx/wine/ddraw/ddraw.c
@@ -634,6 +634,7 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win
     swapchain_desc.backbuffer_height = mode.height;
     swapchain_desc.backbuffer_format = mode.format_id;
     swapchain_desc.backbuffer_usage = WINED3DUSAGE_RENDERTARGET;
+    swapchain_desc.backbuffer_count = 1;
     swapchain_desc.swap_effect = WINED3D_SWAP_EFFECT_COPY;
     swapchain_desc.device_window = window;
     swapchain_desc.windowed = windowed;
@@ -4995,12 +4996,6 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic
     TRACE("device_parent %p, container_parent %p, desc %p, texture flags %#x, texture %p.\n",
             device_parent, container_parent, desc, texture_flags, texture);
 
-    if (ddraw->wined3d_frontbuffer)
-    {
-        ERR("Frontbuffer already created.\n");
-        return E_FAIL;
-    }
-
     if (FAILED(hr = wined3d_texture_create(ddraw->wined3d_device, desc, 1, 1,
             texture_flags | WINED3D_TEXTURE_CREATE_MAPPABLE, NULL, ddraw, &ddraw_frontbuffer_parent_ops, texture)))
     {
@@ -5008,7 +5003,8 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic
         return hr;
     }
 
-    ddraw->wined3d_frontbuffer = *texture;
+    if (!ddraw->wined3d_frontbuffer)
+        ddraw->wined3d_frontbuffer = *texture;
 
     return hr;
 }
diff --git a/dll/directx/wine/wined3d/context.c b/dll/directx/wine/wined3d/context.c
index 8a8d952c3ff..43e97b58853 100644
--- a/dll/directx/wine/wined3d/context.c
+++ b/dll/directx/wine/wined3d/context.c
@@ -2027,6 +2027,9 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
      * Using the same format regardless of the color/depth/stencil targets
      * makes it much less likely that different wined3d instances will set
      * conflicting pixel formats. */
+    
+    // ds_format is null here, will crash later. No idea why.
+    
     if (wined3d_settings.offscreen_rendering_mode != ORM_BACKBUFFER)
     {
         color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
diff --git a/dll/directx/wine/wined3d/swapchain.c b/dll/directx/wine/wined3d/swapchain.c
index 8c67a0d42be..b4e05f38b5d 100644
--- a/dll/directx/wine/wined3d/swapchain.c
+++ b/dll/directx/wine/wined3d/swapchain.c
@@ -931,7 +931,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
             goto err;
         }
 
-        texture_desc.usage = swapchain->desc.backbuffer_usage;
+        texture_desc.usage = 0;
         for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
         {
             TRACE("Creating back buffer %u.\n", i);
-- 
2.38.1

