Commit 21257be2 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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

parent 7cc82c1e
...@@ -1585,14 +1585,12 @@ void context_release(struct wined3d_context *context) ...@@ -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 /* 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 * needed to access the WGL framebuffer for render target B. Re-acquire a context for rt
* A to avoid breaking caller code. */ * 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 if (context->current_rt.texture != texture || context->current_rt.sub_resource_idx != sub_resource_idx)
|| context->current_rt.sub_resource_idx != surface_get_sub_resource_idx(restore))
{ {
context_release(context); context_release(context);
context = context_acquire(restore->container->resource.device, context = context_acquire(texture->resource.device, texture, sub_resource_idx);
restore->container, surface_get_sub_resource_idx(restore));
} }
context_release(context); context_release(context);
......
...@@ -507,7 +507,7 @@ static void texture2d_blt_fbo(const struct wined3d_device *device, struct wined3 ...@@ -507,7 +507,7 @@ static void texture2d_blt_fbo(const struct wined3d_device *device, struct wined3
gl_info->gl_ops.gl.p_glFlush(); gl_info->gl_ops.gl.p_glFlush();
if (restore_texture) 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, static BOOL fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct wined3d_gl_info *gl_info,
...@@ -1471,7 +1471,7 @@ error: ...@@ -1471,7 +1471,7 @@ error:
} }
if (restore_texture) 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 /* Read the framebuffer contents into a texture. Note that this function
...@@ -1518,7 +1518,7 @@ void texture2d_load_fb_texture(struct wined3d_texture *texture, ...@@ -1518,7 +1518,7 @@ void texture2d_load_fb_texture(struct wined3d_texture *texture,
checkGLcall("glCopyTexSubImage2D"); checkGLcall("glCopyTexSubImage2D");
if (restore_texture) 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 /* 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 ...@@ -2106,9 +2106,10 @@ BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_res
BOOL texture2d_load_drawable(struct wined3d_texture *texture, BOOL texture2d_load_drawable(struct wined3d_texture *texture,
unsigned int sub_resource_idx, struct wined3d_context *context) 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_surface *surface;
struct wined3d_device *device; struct wined3d_device *device;
unsigned int restore_idx;
unsigned int level; unsigned int level;
RECT r; RECT r;
...@@ -2129,11 +2130,12 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture, ...@@ -2129,11 +2130,12 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture,
device = texture->resource.device; device = texture->resource.device;
surface = texture->sub_resources[sub_resource_idx].u.surface; surface = texture->sub_resources[sub_resource_idx].u.surface;
restore_rt = context_get_rt_surface(context); restore_texture = context->current_rt.texture;
if (restore_rt != surface) 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); context = context_acquire(device, texture, sub_resource_idx);
else else
restore_rt = NULL; restore_texture = NULL;
level = sub_resource_idx % texture->level_count; level = sub_resource_idx % texture->level_count;
SetRect(&r, 0, 0, wined3d_texture_get_level_width(texture, level), SetRect(&r, 0, 0, wined3d_texture_get_level_width(texture, level),
...@@ -2144,8 +2146,8 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture, ...@@ -2144,8 +2146,8 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture,
surface, WINED3D_LOCATION_DRAWABLE, &r, surface, WINED3D_LOCATION_DRAWABLE, &r,
NULL, WINED3D_TEXF_POINT); NULL, WINED3D_TEXF_POINT);
if (restore_rt) if (restore_texture)
context_restore(context, restore_rt); context_restore(context, restore_texture, restore_idx);
return TRUE; return TRUE;
} }
......
...@@ -2170,7 +2170,8 @@ struct wined3d_context *context_reacquire(const struct wined3d_device *device, ...@@ -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_release(struct wined3d_context *context) DECLSPEC_HIDDEN;
void context_resource_released(const struct wined3d_device *device, void context_resource_released(const struct wined3d_device *device,
struct wined3d_resource *resource, enum wined3d_resource_type type) DECLSPEC_HIDDEN; 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; 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_draw_buffer(struct wined3d_context *context, GLenum buffer) DECLSPEC_HIDDEN;
void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN; void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment