[PATCH 7/8] wined3d: Rotate through swapchain buffers.

Stefan Dösinger stefandoesinger at gmx.at
Sun Feb 14 14:33:58 CST 2016


Going back to square one and moving around texture resources. Anything
that's based on reassigning client library resources will make d3d11
deferred contexts very difficult.

So far I'm only moving around RGB textures and invalidating everything
else for simplicity.
---
 dlls/d3d8/tests/visual.c | 10 +++++-----
 dlls/d3d9/tests/visual.c | 10 +++++-----
 dlls/wined3d/swapchain.c | 32 +++++++++++++++++++++++++++++++-
 3 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index db2e0db..b0ce232 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -8044,9 +8044,9 @@ static void test_flip(void)
 
     /* Contents were changed. */
     color = get_surface_color(back_buffers[0], 1, 1);
-    todo_wine ok(color == 0xff00ff00, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff00ff00, "Got unexpected color 0x%08x.\n", color);
     color = get_surface_color(back_buffers[1], 1, 1);
-    todo_wine ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff808080, 0.0f, 0);
     ok(SUCCEEDED(hr), "Failed to clear, hr %#x\n", hr);
@@ -8055,15 +8055,15 @@ static void test_flip(void)
     ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
 
     color = get_surface_color(back_buffers[0], 1, 1);
-    todo_wine ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
     color = get_surface_color(back_buffers[1], 1, 1);
-    todo_wine ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
     ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
 
     color = get_surface_color(back_buffers[0], 1, 1);
-    todo_wine ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
 
     for (i = 0; i < sizeof(back_buffers) / sizeof(*back_buffers); ++i)
         IDirect3DSurface8_Release(back_buffers[i]);
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 8b56dbe..1887541 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -20199,9 +20199,9 @@ static void test_flip(void)
 
     /* Contents were changed. */
     color = getPixelColorFromSurface(back_buffers[0], 1, 1);
-    todo_wine ok(color == 0xff00ff00, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff00ff00, "Got unexpected color 0x%08x.\n", color);
     color = getPixelColorFromSurface(back_buffers[1], 1, 1);
-    todo_wine ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff808080, 0.0f, 0);
     ok(SUCCEEDED(hr), "Failed to clear, hr %#x\n", hr);
@@ -20210,15 +20210,15 @@ static void test_flip(void)
     ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
 
     color = getPixelColorFromSurface(back_buffers[0], 1, 1);
-    todo_wine ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff0000ff, "Got unexpected color 0x%08x.\n", color);
     color = getPixelColorFromSurface(back_buffers[1], 1, 1);
-    todo_wine ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
 
     hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
     ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
 
     color = getPixelColorFromSurface(back_buffers[0], 1, 1);
-    todo_wine ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
+    ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
 
     for (i = 0; i < sizeof(back_buffers) / sizeof(*back_buffers); ++i)
         IDirect3DSurface9_Release(back_buffers[i]);
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 7728cdc..71a607b 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -422,6 +422,34 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
     }
 }
 
+/* Context activation is done by the caller. */
+static void wined3d_swapchain_rotate(struct wined3d_swapchain *swapchain, struct wined3d_context *context)
+{
+    struct gl_texture tex0;
+    struct wined3d_surface *surface;
+    unsigned int i;
+
+    if (swapchain->desc.backbuffer_count < 2 || !swapchain->render_to_fbo)
+        return;
+
+    /* Back buffer 0 is already in texture. */
+    tex0 = swapchain->back_buffers[0]->texture_rgb;
+
+    for (i = 1; i < swapchain->desc.backbuffer_count; ++i)
+    {
+        surface = surface_from_resource(swapchain->back_buffers[i]->sub_resources[0]);
+        surface_load_location(surface, context, WINED3D_LOCATION_TEXTURE_RGB);
+        swapchain->back_buffers[i - 1]->texture_rgb = swapchain->back_buffers[i]->texture_rgb;
+        surface_invalidate_location(surface, ~WINED3D_LOCATION_TEXTURE_RGB);
+    }
+
+    swapchain->back_buffers[i - 1]->texture_rgb = tex0;
+    surface = surface_from_resource(swapchain->back_buffers[0]->sub_resources[0]);
+    surface_invalidate_location(surface, ~WINED3D_LOCATION_TEXTURE_RGB);
+
+    device_invalidate_state(swapchain->device, STATE_FRAMEBUFFER);
+}
+
 static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT *src_rect_in,
         const RECT *dst_rect_in, const RGNDATA *dirty_region, DWORD flags)
 {
@@ -549,7 +577,9 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT
         gl_info->gl_ops.gl.p_glFinish();
 
     /* call wglSwapBuffers through the gl table to avoid confusing the Steam overlay */
-    gl_info->gl_ops.wgl.p_wglSwapBuffers(context->hdc); /* TODO: cycle through the swapchain buffers */
+    gl_info->gl_ops.wgl.p_wglSwapBuffers(context->hdc);
+
+    wined3d_swapchain_rotate(swapchain, context);
 
     TRACE("SwapBuffers called, Starting new frame\n");
     /* FPS support */
-- 
2.4.10




More information about the wine-patches mailing list