wined3d: Pass a texture and sub-resource index to context_restore().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Henri Verbeet 2018-03-12 12:36:47 +03:30 committed by Alexandre Julliard
parent 7cc82c1ea6
commit 21257be2a9
3 changed files with 16 additions and 15 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;