You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-09-12 18:50:20 -07:00
Rebase against bf4493404cee43a345fe853b5c11b053cdd22322.
This commit is contained in:
@@ -1,81 +0,0 @@
|
||||
From fb2ae897035c342f2d78590928eaa62f8bb2b47e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
|
||||
Date: Sun, 17 Nov 2013 19:16:40 +0100
|
||||
Subject: wined3d: Pass a context to read_from_framebuffer.
|
||||
|
||||
In the average case the function will not be able to reuse it, because
|
||||
it requires a specific context to access the WGL framebuffer. It will
|
||||
restore the original context afterwards to hide the context change from
|
||||
load_location / preload callers. This is related to bug 34574.
|
||||
---
|
||||
dlls/wined3d/surface.c | 29 +++++++++++++++++++++++++----
|
||||
1 file changed, 25 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
|
||||
index 534a152..534d4bd 100644
|
||||
--- a/dlls/wined3d/surface.c
|
||||
+++ b/dlls/wined3d/surface.c
|
||||
@@ -2935,11 +2935,13 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc)
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
-static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_location)
|
||||
+static void read_from_framebuffer(struct wined3d_surface *surface,
|
||||
+ struct wined3d_context *old_ctx, DWORD dst_location)
|
||||
{
|
||||
struct wined3d_device *device = surface->resource.device;
|
||||
const struct wined3d_gl_info *gl_info;
|
||||
struct wined3d_context *context;
|
||||
+ struct wined3d_surface *restore_rt;
|
||||
BYTE *mem;
|
||||
BYTE *row, *top, *bottom;
|
||||
int i;
|
||||
@@ -2948,7 +2950,21 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc
|
||||
|
||||
surface_get_memory(surface, &data, dst_location);
|
||||
|
||||
- context = context_acquire(device, surface);
|
||||
+ /* Context_release does not restore the original context in case of
|
||||
+ * nested context_acquire calls. Only read_from_framebuffer and
|
||||
+ * surface_blt_to_drawable use nested context_acquire calls. Manually
|
||||
+ * restore the original context at the end of the function if needed. */
|
||||
+ if (old_ctx->current_rt == surface)
|
||||
+ {
|
||||
+ restore_rt = NULL;
|
||||
+ context = old_ctx;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ restore_rt = old_ctx->current_rt;
|
||||
+ context = context_acquire(device, surface);
|
||||
+ }
|
||||
+
|
||||
context_apply_blit_state(context, device);
|
||||
gl_info = context->gl_info;
|
||||
|
||||
@@ -3036,7 +3052,12 @@ error:
|
||||
checkGLcall("glBindBuffer");
|
||||
}
|
||||
|
||||
- context_release(context);
|
||||
+ if (restore_rt)
|
||||
+ {
|
||||
+ context_release(context);
|
||||
+ context = context_acquire(device, restore_rt);
|
||||
+ context_release(context);
|
||||
+ }
|
||||
}
|
||||
|
||||
/* Read the framebuffer contents into a texture. Note that this function
|
||||
@@ -4191,7 +4212,7 @@ static void surface_load_sysmem(struct wined3d_surface *surface,
|
||||
|
||||
if (surface->locations & WINED3D_LOCATION_DRAWABLE)
|
||||
{
|
||||
- read_from_framebuffer(surface, dst_location);
|
||||
+ read_from_framebuffer(surface, context, dst_location);
|
||||
return;
|
||||
}
|
||||
|
||||
--
|
||||
2.2.1
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
From 0f7f57e440a198c31920c7077a6c7b0661945039 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
|
||||
Date: Sun, 17 Nov 2013 19:34:26 +0100
|
||||
Subject: wined3d: Pass a context to surface_load_drawable and
|
||||
surface_blt_to_drawable.
|
||||
|
||||
---
|
||||
dlls/wined3d/surface.c | 41 +++++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 35 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
|
||||
index 9351ab2..1b3def9 100644
|
||||
--- a/dlls/wined3d/surface.c
|
||||
+++ b/dlls/wined3d/surface.c
|
||||
@@ -3536,19 +3536,35 @@ void surface_translate_drawable_coords(const struct wined3d_surface *surface, HW
|
||||
rect->bottom = drawable_height - rect->bottom;
|
||||
}
|
||||
|
||||
+/* Context activation is done by the caller. */
|
||||
static void surface_blt_to_drawable(const struct wined3d_device *device,
|
||||
+ struct wined3d_context *old_ctx,
|
||||
enum wined3d_texture_filter_type filter, BOOL alpha_test,
|
||||
struct wined3d_surface *src_surface, const RECT *src_rect_in,
|
||||
struct wined3d_surface *dst_surface, const RECT *dst_rect_in)
|
||||
{
|
||||
const struct wined3d_gl_info *gl_info;
|
||||
struct wined3d_context *context;
|
||||
+ struct wined3d_surface *restore_rt;
|
||||
RECT src_rect, dst_rect;
|
||||
|
||||
src_rect = *src_rect_in;
|
||||
dst_rect = *dst_rect_in;
|
||||
|
||||
- context = context_acquire(device, dst_surface);
|
||||
+ /* Context_release does not restore the original context in case of
|
||||
+ * nested context_acquire calls. Only read_from_framebuffer and
|
||||
+ * surface_blt_to_drawable use nested context_acquire calls. Manually
|
||||
+ * restore the original context at the end of the function if needed. */
|
||||
+ if (old_ctx->current_rt == dst_surface)
|
||||
+ {
|
||||
+ restore_rt = NULL;
|
||||
+ context = old_ctx;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ restore_rt = old_ctx->current_rt;
|
||||
+ context = context_acquire(device, dst_surface);
|
||||
+ }
|
||||
gl_info = context->gl_info;
|
||||
|
||||
/* Make sure the surface is up-to-date. This should probably use
|
||||
@@ -3601,7 +3617,12 @@ static void surface_blt_to_drawable(const struct wined3d_device *device,
|
||||
&& dst_surface->container->swapchain->front_buffer == dst_surface->container))
|
||||
gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
|
||||
|
||||
- context_release(context);
|
||||
+ if (restore_rt)
|
||||
+ {
|
||||
+ context_release(context);
|
||||
+ context = context_acquire(device, restore_rt);
|
||||
+ context_release(context);
|
||||
+ }
|
||||
}
|
||||
|
||||
HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const struct wined3d_color *color)
|
||||
@@ -4101,8 +4122,9 @@ static void surface_load_sysmem(struct wined3d_surface *surface,
|
||||
surface, wined3d_debug_location(surface->locations));
|
||||
}
|
||||
|
||||
+/* Context activation is done by the caller. */
|
||||
static HRESULT surface_load_drawable(struct wined3d_surface *surface,
|
||||
- const struct wined3d_gl_info *gl_info)
|
||||
+ struct wined3d_context *context)
|
||||
{
|
||||
RECT r;
|
||||
|
||||
@@ -4115,7 +4137,7 @@ static HRESULT surface_load_drawable(struct wined3d_surface *surface,
|
||||
|
||||
surface_get_rect(surface, NULL, &r);
|
||||
surface_load_location(surface, WINED3D_LOCATION_TEXTURE_RGB);
|
||||
- surface_blt_to_drawable(surface->resource.device,
|
||||
+ surface_blt_to_drawable(surface->resource.device, context,
|
||||
WINED3D_TEXF_POINT, FALSE, surface, &r, surface, &r);
|
||||
|
||||
return WINED3D_OK;
|
||||
@@ -4373,7 +4395,10 @@ HRESULT surface_load_location(struct wined3d_surface *surface, DWORD location)
|
||||
break;
|
||||
|
||||
case WINED3D_LOCATION_DRAWABLE:
|
||||
- if (FAILED(hr = surface_load_drawable(surface, gl_info)))
|
||||
+ context = context_acquire(device, NULL);
|
||||
+ hr = surface_load_drawable(surface, context);
|
||||
+ context_release(context);
|
||||
+ if (FAILED(hr))
|
||||
return hr;
|
||||
break;
|
||||
|
||||
@@ -4547,6 +4572,8 @@ static void ffp_blit_blit_surface(struct wined3d_device *device, DWORD filter,
|
||||
struct wined3d_surface *dst_surface, const RECT *dst_rect,
|
||||
const struct wined3d_color_key *color_key)
|
||||
{
|
||||
+ struct wined3d_context *context;
|
||||
+
|
||||
/* Blit from offscreen surface to render target */
|
||||
struct wined3d_color_key old_blt_key = src_surface->container->async.src_blt_color_key;
|
||||
DWORD old_color_key_flags = src_surface->container->async.color_key_flags;
|
||||
@@ -4555,8 +4582,10 @@ static void ffp_blit_blit_surface(struct wined3d_device *device, DWORD filter,
|
||||
|
||||
wined3d_texture_set_color_key(src_surface->container, WINED3D_CKEY_SRC_BLT, color_key);
|
||||
|
||||
- surface_blt_to_drawable(device, filter,
|
||||
+ context = context_acquire(device, dst_surface);
|
||||
+ surface_blt_to_drawable(device, context, filter,
|
||||
!!color_key, src_surface, src_rect, dst_surface, dst_rect);
|
||||
+ context_release(context);
|
||||
|
||||
/* Restore the color key parameters */
|
||||
wined3d_texture_set_color_key(src_surface->container, WINED3D_CKEY_SRC_BLT,
|
||||
--
|
||||
2.5.1
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
From 0d11e8c92575dae298bcf9b830ef155689823c04 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
|
||||
Date: Sun, 17 Nov 2013 19:49:38 +0100
|
||||
Subject: wined3d: Pass a context to surface_blt_fbo.
|
||||
|
||||
---
|
||||
dlls/wined3d/surface.c | 53 +++++++++++++++++++++++++++++++++++++++-----------
|
||||
1 file changed, 42 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
|
||||
index f4b9071..8ca5bda 100644
|
||||
--- a/dlls/wined3d/surface.c
|
||||
+++ b/dlls/wined3d/surface.c
|
||||
@@ -860,13 +860,15 @@ static void surface_depth_blt_fbo(const struct wined3d_device *device,
|
||||
}
|
||||
|
||||
/* Blit between surface locations. Onscreen on different swapchains is not supported.
|
||||
- * Depth / stencil is not supported. */
|
||||
-static void surface_blt_fbo(const struct wined3d_device *device, enum wined3d_texture_filter_type filter,
|
||||
+ * Depth / stencil is not supported. Context activation is done by the caller. */
|
||||
+static void surface_blt_fbo(const struct wined3d_device *device,
|
||||
+ struct wined3d_context *old_ctx, enum wined3d_texture_filter_type filter,
|
||||
struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect_in,
|
||||
struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect_in)
|
||||
{
|
||||
const struct wined3d_gl_info *gl_info;
|
||||
struct wined3d_context *context;
|
||||
+ struct wined3d_surface *required_rt, *restore_rt;
|
||||
RECT src_rect, dst_rect;
|
||||
GLenum gl_filter;
|
||||
GLenum buffer;
|
||||
@@ -909,9 +911,20 @@ static void surface_blt_fbo(const struct wined3d_device *device, enum wined3d_te
|
||||
if (!surface_is_full_rect(dst_surface, &dst_rect))
|
||||
surface_load_location(dst_surface, dst_location);
|
||||
|
||||
- if (src_location == WINED3D_LOCATION_DRAWABLE) context = context_acquire(device, src_surface);
|
||||
- else if (dst_location == WINED3D_LOCATION_DRAWABLE) context = context_acquire(device, dst_surface);
|
||||
- else context = context_acquire(device, NULL);
|
||||
+ if (src_location == WINED3D_LOCATION_DRAWABLE) required_rt = src_surface;
|
||||
+ else if (dst_location == WINED3D_LOCATION_DRAWABLE) required_rt = dst_surface;
|
||||
+ else required_rt = NULL;
|
||||
+
|
||||
+ if (required_rt && required_rt != old_ctx->current_rt)
|
||||
+ {
|
||||
+ restore_rt = old_ctx->current_rt;
|
||||
+ context = context_acquire(device, required_rt);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ restore_rt = NULL;
|
||||
+ context = old_ctx;
|
||||
+ }
|
||||
|
||||
if (!context->valid)
|
||||
{
|
||||
@@ -974,7 +987,12 @@ static void surface_blt_fbo(const struct wined3d_device *device, enum wined3d_te
|
||||
&& dst_surface->container->swapchain->front_buffer == dst_surface->container))
|
||||
gl_info->gl_ops.gl.p_glFlush();
|
||||
|
||||
- context_release(context);
|
||||
+ if (restore_rt)
|
||||
+ {
|
||||
+ context_release(context);
|
||||
+ context = context_acquire(device, restore_rt);
|
||||
+ context_release(context);
|
||||
+ }
|
||||
}
|
||||
|
||||
static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum wined3d_blit_op blit_op,
|
||||
@@ -4294,13 +4312,17 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
|
||||
NULL, surface->resource.usage, surface->resource.pool, surface->resource.format,
|
||||
NULL, surface->resource.usage, surface->resource.pool, surface->resource.format))
|
||||
{
|
||||
+ context = context_acquire(device, NULL);
|
||||
+
|
||||
if (srgb)
|
||||
- surface_blt_fbo(device, WINED3D_TEXF_POINT, surface, WINED3D_LOCATION_TEXTURE_RGB,
|
||||
+ surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, WINED3D_LOCATION_TEXTURE_RGB,
|
||||
&src_rect, surface, WINED3D_LOCATION_TEXTURE_SRGB, &src_rect);
|
||||
else
|
||||
- surface_blt_fbo(device, WINED3D_TEXF_POINT, surface, WINED3D_LOCATION_TEXTURE_SRGB,
|
||||
+ surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, WINED3D_LOCATION_TEXTURE_SRGB,
|
||||
&src_rect, surface, WINED3D_LOCATION_TEXTURE_RGB, &src_rect);
|
||||
|
||||
+ context_release(context);
|
||||
+
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
@@ -4315,8 +4337,10 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
|
||||
DWORD dst_location = srgb ? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB;
|
||||
RECT rect = {0, 0, surface->resource.width, surface->resource.height};
|
||||
|
||||
- surface_blt_fbo(device, WINED3D_TEXF_POINT, surface, src_location,
|
||||
+ context = context_acquire(device, NULL);
|
||||
+ surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, src_location,
|
||||
&rect, surface, dst_location, &rect);
|
||||
+ context_release(context);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
@@ -4447,14 +4471,17 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
|
||||
|
||||
static void surface_multisample_resolve(struct wined3d_surface *surface)
|
||||
{
|
||||
+ struct wined3d_context *context;
|
||||
RECT rect = {0, 0, surface->resource.width, surface->resource.height};
|
||||
|
||||
if (!(surface->locations & WINED3D_LOCATION_RB_MULTISAMPLE))
|
||||
ERR("Trying to resolve multisampled surface %p, but location WINED3D_LOCATION_RB_MULTISAMPLE not current.\n",
|
||||
surface);
|
||||
|
||||
- surface_blt_fbo(surface->resource.device, WINED3D_TEXF_POINT,
|
||||
+ context = context_acquire(surface->resource.device, NULL);
|
||||
+ surface_blt_fbo(surface->resource.device, context, WINED3D_TEXF_POINT,
|
||||
surface, WINED3D_LOCATION_RB_MULTISAMPLE, &rect, surface, WINED3D_LOCATION_RB_RESOLVED, &rect);
|
||||
+ context_release(context);
|
||||
}
|
||||
|
||||
HRESULT surface_load_location(struct wined3d_surface *surface, DWORD location)
|
||||
@@ -5629,11 +5656,15 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC
|
||||
&src_rect, src_surface->resource.usage, src_surface->resource.pool, src_surface->resource.format,
|
||||
&dst_rect, dst_surface->resource.usage, dst_surface->resource.pool, dst_surface->resource.format))
|
||||
{
|
||||
+ struct wined3d_context *context;
|
||||
TRACE("Using FBO blit.\n");
|
||||
|
||||
- surface_blt_fbo(device, filter,
|
||||
+ context = context_acquire(device, NULL);
|
||||
+ surface_blt_fbo(device, context, filter,
|
||||
src_surface, src_surface->container->resource.draw_binding, &src_rect,
|
||||
dst_surface, dst_surface->container->resource.draw_binding, &dst_rect);
|
||||
+ context_release(context);
|
||||
+
|
||||
surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding);
|
||||
surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding);
|
||||
|
||||
--
|
||||
2.2.1
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user