wined3d: Pass a context to blit_shader.blit_surface().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2017-03-17 13:33:17 +01:00 committed by Alexandre Julliard
parent ad46b67674
commit 717225bf9b
3 changed files with 17 additions and 25 deletions

View File

@ -7789,22 +7789,18 @@ static BOOL arbfp_blit_supported(const struct wined3d_gl_info *gl_info,
} }
} }
static void arbfp_blit_surface(struct wined3d_device *device, enum wined3d_blit_op op, DWORD filter, static void arbfp_blit_surface(struct wined3d_device *device, enum wined3d_blit_op op, struct wined3d_context *context,
struct wined3d_surface *src_surface, const RECT *src_rect_in, struct wined3d_surface *src_surface, const RECT *src_rect_in,
struct wined3d_surface *dst_surface, const RECT *dst_rect_in, struct wined3d_surface *dst_surface, const RECT *dst_rect_in,
const struct wined3d_color_key *color_key) const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
{ {
unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface); unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
struct wined3d_texture *src_texture = src_surface->container; struct wined3d_texture *src_texture = src_surface->container;
struct wined3d_texture *dst_texture = dst_surface->container; struct wined3d_texture *dst_texture = dst_surface->container;
struct wined3d_context *context;
RECT src_rect = *src_rect_in; RECT src_rect = *src_rect_in;
RECT dst_rect = *dst_rect_in; RECT dst_rect = *dst_rect_in;
struct wined3d_color_key alpha_test_key; struct wined3d_color_key alpha_test_key;
/* Activate the destination context, set it up for blitting */
context = context_acquire(device, dst_texture, dst_sub_resource_idx);
/* Now load the surface */ /* Now load the surface */
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
&& (surface_get_sub_resource(src_surface)->locations && (surface_get_sub_resource(src_surface)->locations
@ -7850,8 +7846,6 @@ static void arbfp_blit_surface(struct wined3d_device *device, enum wined3d_blit_
|| (dst_texture->swapchain && (dst_texture->swapchain->front_buffer == dst_texture))) || (dst_texture->swapchain && (dst_texture->swapchain->front_buffer == dst_texture)))
context->gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */ context->gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
context_release(context);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, dst_texture->resource.draw_binding); wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, dst_texture->resource.draw_binding);
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~dst_texture->resource.draw_binding); wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~dst_texture->resource.draw_binding);
} }

View File

@ -2780,16 +2780,15 @@ static HRESULT ffp_blit_depth_fill(struct wined3d_device *device,
return WINED3D_OK; return WINED3D_OK;
} }
static void ffp_blit_blit_surface(struct wined3d_device *device, enum wined3d_blit_op op, DWORD filter, static void ffp_blit_blit_surface(struct wined3d_device *device, enum wined3d_blit_op op,
struct wined3d_surface *src_surface, const RECT *src_rect, struct wined3d_context *context, struct wined3d_surface *src_surface, const RECT *src_rect,
struct wined3d_surface *dst_surface, const RECT *dst_rect, struct wined3d_surface *dst_surface, const RECT *dst_rect,
const struct wined3d_color_key *color_key) const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
{ {
unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface); unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
struct wined3d_texture *dst_texture = dst_surface->container; struct wined3d_texture *dst_texture = dst_surface->container;
struct wined3d_texture *src_texture = src_surface->container; struct wined3d_texture *src_texture = src_surface->container;
const struct wined3d_gl_info *gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_context *context;
/* Blit from offscreen surface to render target */ /* Blit from offscreen surface to render target */
struct wined3d_color_key old_blt_key = src_texture->async.src_blt_color_key; struct wined3d_color_key old_blt_key = src_texture->async.src_blt_color_key;
@ -2799,9 +2798,6 @@ static void ffp_blit_blit_surface(struct wined3d_device *device, enum wined3d_bl
wined3d_texture_set_color_key(src_texture, WINED3D_CKEY_SRC_BLT, color_key); wined3d_texture_set_color_key(src_texture, WINED3D_CKEY_SRC_BLT, color_key);
context = context_acquire(device, dst_texture, dst_sub_resource_idx);
gl_info = context->gl_info;
if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST) if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST)
gl_info->gl_ops.gl.p_glEnable(GL_ALPHA_TEST); gl_info->gl_ops.gl.p_glEnable(GL_ALPHA_TEST);
@ -2811,8 +2807,6 @@ static void ffp_blit_blit_surface(struct wined3d_device *device, enum wined3d_bl
if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST) if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST)
gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST); gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST);
context_release(context);
/* Restore the color key parameters */ /* Restore the color key parameters */
wined3d_texture_set_color_key(src_texture, WINED3D_CKEY_SRC_BLT, wined3d_texture_set_color_key(src_texture, WINED3D_CKEY_SRC_BLT,
(old_color_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL); (old_color_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL);
@ -3466,10 +3460,10 @@ static HRESULT cpu_blit_depth_fill(struct wined3d_device *device,
&box, NULL, 0, &src_box, WINED3D_BLT_DEPTH_FILL, &fx, WINED3D_TEXF_POINT); &box, NULL, 0, &src_box, WINED3D_BLT_DEPTH_FILL, &fx, WINED3D_TEXF_POINT);
} }
static void cpu_blit_blit_surface(struct wined3d_device *device, enum wined3d_blit_op op, DWORD filter, static void cpu_blit_blit_surface(struct wined3d_device *device, enum wined3d_blit_op op,
struct wined3d_surface *src_surface, const RECT *src_rect, struct wined3d_context *context, struct wined3d_surface *src_surface, const RECT *src_rect,
struct wined3d_surface *dst_surface, const RECT *dst_rect, struct wined3d_surface *dst_surface, const RECT *dst_rect,
const struct wined3d_color_key *color_key) const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
{ {
/* FIXME: Remove error returns from surface_blt_cpu. */ /* FIXME: Remove error returns from surface_blt_cpu. */
ERR("Blit method not implemented by cpu_blit.\n"); ERR("Blit method not implemented by cpu_blit.\n");
@ -3761,8 +3755,12 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
dst_rect, dst_texture->resource.usage, dst_texture->resource.pool, dst_texture->resource.format); dst_rect, dst_texture->resource.usage, dst_texture->resource.pool, dst_texture->resource.format);
if (blitter) if (blitter)
{ {
blitter->blit_surface(device, blit_op, filter, src_surface, struct wined3d_context *context;
src_rect, dst_surface, dst_rect, color_key);
context = context_acquire(device, dst_texture, dst_sub_resource_idx);
blitter->blit_surface(device, blit_op, context, src_surface,
src_rect, dst_surface, dst_rect, color_key, filter);
context_release(context);
return WINED3D_OK; return WINED3D_OK;
} }
} }

View File

@ -1880,10 +1880,10 @@ struct blit_shader
const RECT *rect, const struct wined3d_color *color); const RECT *rect, const struct wined3d_color *color);
HRESULT (*depth_fill)(struct wined3d_device *device, struct wined3d_rendertarget_view *view, HRESULT (*depth_fill)(struct wined3d_device *device, struct wined3d_rendertarget_view *view,
const RECT *rect, DWORD clear_flags, float depth, DWORD stencil); const RECT *rect, DWORD clear_flags, float depth, DWORD stencil);
void (*blit_surface)(struct wined3d_device *device, enum wined3d_blit_op op, DWORD filter, void (*blit_surface)(struct wined3d_device *device, enum wined3d_blit_op op, struct wined3d_context *context,
struct wined3d_surface *src_surface, const RECT *src_rect, struct wined3d_surface *src_surface, const RECT *src_rect,
struct wined3d_surface *dst_surface, const RECT *dst_rect, struct wined3d_surface *dst_surface, const RECT *dst_rect,
const struct wined3d_color_key *color_key); const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter);
}; };
extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN; extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN;