Module: wine Branch: master Commit: 14f024048b301cd6ccc7e15e731d069cd68b13c0 URL: http://source.winehq.org/git/wine.git/?a=commit;h=14f024048b301cd6ccc7e15e73...
Author: Stefan Dösinger stefan@codeweavers.com Date: Thu Oct 15 22:41:11 2015 +0200
wined3d: Pass a context to surface_load_fb_texture.
Signed-off-by: Stefan Dösinger stefan@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/arb_program_shader.c | 2 +- dlls/wined3d/surface.c | 22 ++++++++++++++++------ dlls/wined3d/wined3d_private.h | 3 ++- 3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 3d65fe0..9ac6666 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7859,7 +7859,7 @@ static void arbfp_blit_surface(struct wined3d_device *device, DWORD filter, * flip in the blitter, we don't actually need that flip anyway. So we * use the surface's texture as scratch texture, and flip the source * rectangle instead. */ - surface_load_fb_texture(src_surface, FALSE); + surface_load_fb_texture(src_surface, FALSE, context);
src_rect.top = src_surface->resource.height - src_rect.top; src_rect.bottom = src_surface->resource.height - src_rect.bottom; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 1b78712..1f92d1e 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -2803,14 +2803,23 @@ error:
/* Read the framebuffer contents into a texture. Note that this function * doesn't do any kind of flipping. Using this on an onscreen surface will - * result in a flipped D3D texture. */ -void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb) + * result in a flipped D3D texture. + * + * Context activation is done by the caller. This function may temporarily + * switch to a different context and restore the original one before return. */ +void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct wined3d_context *old_ctx) { struct wined3d_device *device = surface->resource.device; const struct wined3d_gl_info *gl_info; - struct wined3d_context *context; + struct wined3d_context *context = old_ctx; + struct wined3d_surface *restore_rt = NULL; + + if (old_ctx->current_rt != surface) + { + restore_rt = old_ctx->current_rt; + context = context_acquire(device, surface); + }
- context = context_acquire(device, surface); gl_info = context->gl_info; device_invalidate_state(device, STATE_FRAMEBUFFER);
@@ -2829,7 +2838,8 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb) 0, 0, 0, 0, surface->resource.width, surface->resource.height); checkGLcall("glCopyTexSubImage2D");
- context_release(context); + if (restore_rt) + context_restore(context, restore_rt); }
void surface_prepare_rb(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, BOOL multisample) @@ -3898,7 +3908,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, && wined3d_resource_is_offscreen(&texture->resource) && (surface->locations & WINED3D_LOCATION_DRAWABLE)) { - surface_load_fb_texture(surface, srgb); + surface_load_fb_texture(surface, srgb, context);
return WINED3D_OK; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 75c16ef..68d420b 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2448,7 +2448,8 @@ void surface_invalidate_location(struct wined3d_surface *surface, DWORD location void surface_load(struct wined3d_surface *surface, BOOL srgb) DECLSPEC_HIDDEN; void surface_load_ds_location(struct wined3d_surface *surface, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; -void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb) DECLSPEC_HIDDEN; +void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, + struct wined3d_context *context) DECLSPEC_HIDDEN; HRESULT surface_load_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN; void surface_modify_ds_location(struct wined3d_surface *surface, DWORD location, UINT w, UINT h) DECLSPEC_HIDDEN; void surface_prepare_rb(struct wined3d_surface *surface,