Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/context.c | 8 +++----- dlls/wined3d/surface.c | 20 +++++++++++--------- dlls/wined3d/wined3d_private.h | 3 ++- 3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 60bf52ba129..6c635f5b0d2 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1585,14 +1585,12 @@ void context_release(struct wined3d_context *context) /* This is used when a context for render target A is active, but a separate context is * needed to access the WGL framebuffer for render target B. Re-acquire a context for rt * A to avoid breaking caller code. */ -void context_restore(struct wined3d_context *context, struct wined3d_surface *restore) +void context_restore(struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx) { - if (context->current_rt.texture != restore->container - || context->current_rt.sub_resource_idx != surface_get_sub_resource_idx(restore)) + if (context->current_rt.texture != texture || context->current_rt.sub_resource_idx != sub_resource_idx) { context_release(context); - context = context_acquire(restore->container->resource.device, - restore->container, surface_get_sub_resource_idx(restore)); + context = context_acquire(texture->resource.device, texture, sub_resource_idx); }
context_release(context); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index e98541c429f..b830447578b 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -507,7 +507,7 @@ static void texture2d_blt_fbo(const struct wined3d_device *device, struct wined3 gl_info->gl_ops.gl.p_glFlush();
if (restore_texture) - context_restore(context, restore_texture->sub_resources[restore_idx].u.surface); + context_restore(context, restore_texture, restore_idx); }
static BOOL fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct wined3d_gl_info *gl_info, @@ -1471,7 +1471,7 @@ error: }
if (restore_texture) - context_restore(context, restore_texture->sub_resources[restore_idx].u.surface); + context_restore(context, restore_texture, restore_idx); }
/* Read the framebuffer contents into a texture. Note that this function @@ -1518,7 +1518,7 @@ void texture2d_load_fb_texture(struct wined3d_texture *texture, checkGLcall("glCopyTexSubImage2D");
if (restore_texture) - context_restore(context, restore_texture->sub_resources[restore_idx].u.surface); + context_restore(context, restore_texture, restore_idx); }
/* Does a direct frame buffer -> texture copy. Stretching is done with single @@ -2106,9 +2106,10 @@ BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_res BOOL texture2d_load_drawable(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context) { - struct wined3d_surface *restore_rt = NULL; + struct wined3d_texture *restore_texture; struct wined3d_surface *surface; struct wined3d_device *device; + unsigned int restore_idx; unsigned int level; RECT r;
@@ -2129,11 +2130,12 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture,
device = texture->resource.device; surface = texture->sub_resources[sub_resource_idx].u.surface; - restore_rt = context_get_rt_surface(context); - if (restore_rt != surface) + restore_texture = context->current_rt.texture; + restore_idx = context->current_rt.sub_resource_idx; + if (restore_texture != texture || restore_idx != sub_resource_idx) context = context_acquire(device, texture, sub_resource_idx); else - restore_rt = NULL; + restore_texture = NULL;
level = sub_resource_idx % texture->level_count; SetRect(&r, 0, 0, wined3d_texture_get_level_width(texture, level), @@ -2144,8 +2146,8 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture, surface, WINED3D_LOCATION_DRAWABLE, &r, NULL, WINED3D_TEXF_POINT);
- if (restore_rt) - context_restore(context, restore_rt); + if (restore_texture) + context_restore(context, restore_texture, restore_idx);
return TRUE; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index e3d669aba08..76a809cf40a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2170,7 +2170,8 @@ struct wined3d_context *context_reacquire(const struct wined3d_device *device, void context_release(struct wined3d_context *context) DECLSPEC_HIDDEN; void context_resource_released(const struct wined3d_device *device, struct wined3d_resource *resource, enum wined3d_resource_type type) DECLSPEC_HIDDEN; -void context_restore(struct wined3d_context *context, struct wined3d_surface *restore) DECLSPEC_HIDDEN; +void context_restore(struct wined3d_context *context, struct wined3d_texture *texture, + unsigned int sub_resource_idx) DECLSPEC_HIDDEN; BOOL context_set_current(struct wined3d_context *ctx) DECLSPEC_HIDDEN; void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer) DECLSPEC_HIDDEN; void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;