Commit f29c24f2 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Pass the context to surface_internal_preload.

parent fe44be5f
...@@ -7455,6 +7455,9 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter, ...@@ -7455,6 +7455,9 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter,
RECT src_rect = *src_rect_in; RECT src_rect = *src_rect_in;
RECT dst_rect = *dst_rect_in; RECT dst_rect = *dst_rect_in;
/* Activate the destination context, set it up for blitting */
context = context_acquire(device, dst_surface);
/* Now load the surface */ /* Now load the surface */
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
&& (src_surface->flags & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE)) == SFLAG_INDRAWABLE) && (src_surface->flags & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE)) == SFLAG_INDRAWABLE)
...@@ -7470,10 +7473,8 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter, ...@@ -7470,10 +7473,8 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter,
src_rect.bottom = src_surface->resource.height - src_rect.bottom; src_rect.bottom = src_surface->resource.height - src_rect.bottom;
} }
else else
surface_internal_preload(src_surface, SRGB_RGB); surface_internal_preload(src_surface, context, SRGB_RGB);
/* Activate the destination context, set it up for blitting */
context = context_acquire(device, dst_surface);
context_apply_blit_state(context, device); context_apply_blit_state(context, device);
if (!surface_is_offscreen(dst_surface)) if (!surface_is_offscreen(dst_surface))
......
...@@ -2123,7 +2123,7 @@ void context_apply_blit_state(struct wined3d_context *context, const struct wine ...@@ -2123,7 +2123,7 @@ void context_apply_blit_state(struct wined3d_context *context, const struct wine
if (context->render_offscreen) if (context->render_offscreen)
{ {
surface_internal_preload(rt, SRGB_RGB); surface_internal_preload(rt, context, SRGB_RGB);
context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, rt, NULL, rt->draw_binding); context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, rt, NULL, rt->draw_binding);
if (rt->resource.format->id != WINED3DFMT_NULL) if (rt->resource.format->id != WINED3DFMT_NULL)
...@@ -2662,8 +2662,8 @@ static void context_setup_target(struct wined3d_context *context, struct wined3d ...@@ -2662,8 +2662,8 @@ static void context_setup_target(struct wined3d_context *context, struct wined3d
{ {
/* Read the back buffer of the old drawable into the destination texture. */ /* Read the back buffer of the old drawable into the destination texture. */
if (context->current_rt->texture_name_srgb) if (context->current_rt->texture_name_srgb)
surface_internal_preload(context->current_rt, SRGB_SRGB); surface_internal_preload(context->current_rt, context, SRGB_SRGB);
surface_internal_preload(context->current_rt, SRGB_RGB); surface_internal_preload(context->current_rt, context, SRGB_RGB);
surface_invalidate_location(context->current_rt, SFLAG_INDRAWABLE); surface_invalidate_location(context->current_rt, SFLAG_INDRAWABLE);
} }
} }
......
...@@ -2647,6 +2647,7 @@ DWORD CDECL wined3d_surface_get_priority(const struct wined3d_surface *surface) ...@@ -2647,6 +2647,7 @@ DWORD CDECL wined3d_surface_get_priority(const struct wined3d_surface *surface)
void CDECL wined3d_surface_preload(struct wined3d_surface *surface) void CDECL wined3d_surface_preload(struct wined3d_surface *surface)
{ {
struct wined3d_context *context;
TRACE("surface %p.\n", surface); TRACE("surface %p.\n", surface);
if (!surface->resource.device->d3d_initialized) if (!surface->resource.device->d3d_initialized)
...@@ -2655,7 +2656,9 @@ void CDECL wined3d_surface_preload(struct wined3d_surface *surface) ...@@ -2655,7 +2656,9 @@ void CDECL wined3d_surface_preload(struct wined3d_surface *surface)
return; return;
} }
surface_internal_preload(surface, SRGB_ANY); context = context_acquire(surface->resource.device, NULL);
surface_internal_preload(surface, context, SRGB_ANY);
context_release(context);
} }
void * CDECL wined3d_surface_get_parent(const struct wined3d_surface *surface) void * CDECL wined3d_surface_get_parent(const struct wined3d_surface *surface)
...@@ -3687,16 +3690,12 @@ HRESULT CDECL wined3d_surface_flip(struct wined3d_surface *surface, struct wined ...@@ -3687,16 +3690,12 @@ HRESULT CDECL wined3d_surface_flip(struct wined3d_surface *surface, struct wined
return WINED3D_OK; return WINED3D_OK;
} }
void surface_internal_preload(struct wined3d_surface *surface, enum WINED3DSRGB srgb) /* Context activation is done by the caller */
void surface_internal_preload(struct wined3d_surface *surface,
struct wined3d_context *context, enum WINED3DSRGB srgb)
{ {
struct wined3d_device *device = surface->resource.device;
struct wined3d_context *context;
TRACE("iface %p, srgb %#x.\n", surface, srgb); TRACE("iface %p, srgb %#x.\n", surface, srgb);
/* TODO: Use already acquired context when possible. */
context = context_acquire(device, NULL);
if (surface->container) if (surface->container)
{ {
struct wined3d_texture *texture = surface->container; struct wined3d_texture *texture = surface->container;
...@@ -3718,7 +3717,6 @@ void surface_internal_preload(struct wined3d_surface *surface, enum WINED3DSRGB ...@@ -3718,7 +3717,6 @@ void surface_internal_preload(struct wined3d_surface *surface, enum WINED3DSRGB
context->gl_info->gl_ops.gl.p_glPrioritizeTextures(1, &surface->texture_name, &tmp); context->gl_info->gl_ops.gl.p_glPrioritizeTextures(1, &surface->texture_name, &tmp);
} }
} }
context_release(context);
} }
/* Read the framebuffer back into the surface */ /* Read the framebuffer back into the surface */
...@@ -4393,7 +4391,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc ...@@ -4393,7 +4391,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc
context = context_acquire(device, src_surface); context = context_acquire(device, src_surface);
gl_info = context->gl_info; gl_info = context->gl_info;
context_apply_blit_state(context, device); context_apply_blit_state(context, device);
surface_internal_preload(dst_surface, SRGB_RGB); surface_internal_preload(dst_surface, context, SRGB_RGB);
/* Bind the target texture */ /* Bind the target texture */
context_bind_texture(context, dst_target, dst_surface->texture_name); context_bind_texture(context, dst_target, dst_surface->texture_name);
...@@ -4501,14 +4499,14 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st ...@@ -4501,14 +4499,14 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
context = context_acquire(device, src_surface); context = context_acquire(device, src_surface);
gl_info = context->gl_info; gl_info = context->gl_info;
context_apply_blit_state(context, device); context_apply_blit_state(context, device);
surface_internal_preload(dst_surface, SRGB_RGB); surface_internal_preload(dst_surface, context, SRGB_RGB);
src_offscreen = surface_is_offscreen(src_surface); src_offscreen = surface_is_offscreen(src_surface);
noBackBufferBackup = src_offscreen && wined3d_settings.offscreen_rendering_mode == ORM_FBO; noBackBufferBackup = src_offscreen && wined3d_settings.offscreen_rendering_mode == ORM_FBO;
if (!noBackBufferBackup && !src_surface->texture_name) if (!noBackBufferBackup && !src_surface->texture_name)
{ {
/* Get it a description */ /* Get it a description */
surface_internal_preload(src_surface, SRGB_RGB); surface_internal_preload(src_surface, context, SRGB_RGB);
} }
/* Try to use an aux buffer for drawing the rectangle. This way it doesn't need restoring. /* Try to use an aux buffer for drawing the rectangle. This way it doesn't need restoring.
...@@ -4791,14 +4789,15 @@ static void surface_blt_to_drawable(const struct wined3d_device *device, ...@@ -4791,14 +4789,15 @@ static void surface_blt_to_drawable(const struct wined3d_device *device,
src_rect = *src_rect_in; src_rect = *src_rect_in;
dst_rect = *dst_rect_in; dst_rect = *dst_rect_in;
context = context_acquire(device, dst_surface);
gl_info = context->gl_info;
/* Make sure the surface is up-to-date. This should probably use /* Make sure the surface is up-to-date. This should probably use
* surface_load_location() and worry about the destination surface too, * surface_load_location() and worry about the destination surface too,
* unless we're overwriting it completely. */ * unless we're overwriting it completely. */
surface_internal_preload(src_surface, SRGB_RGB); surface_internal_preload(src_surface, context, SRGB_RGB);
/* Activate the destination context, set it up for blitting */ /* Activate the destination context, set it up for blitting */
context = context_acquire(device, dst_surface);
gl_info = context->gl_info;
context_apply_blit_state(context, device); context_apply_blit_state(context, device);
if (!surface_is_offscreen(dst_surface)) if (!surface_is_offscreen(dst_surface))
......
...@@ -2252,7 +2252,8 @@ void surface_add_dirty_rect(struct wined3d_surface *surface, const struct wined3 ...@@ -2252,7 +2252,8 @@ void surface_add_dirty_rect(struct wined3d_surface *surface, const struct wined3
HRESULT surface_color_fill(struct wined3d_surface *s, HRESULT surface_color_fill(struct wined3d_surface *s,
const RECT *rect, const struct wined3d_color *color) DECLSPEC_HIDDEN; const RECT *rect, const struct wined3d_color *color) DECLSPEC_HIDDEN;
GLenum surface_get_gl_buffer(const struct wined3d_surface *surface) DECLSPEC_HIDDEN; GLenum surface_get_gl_buffer(const struct wined3d_surface *surface) DECLSPEC_HIDDEN;
void surface_internal_preload(struct wined3d_surface *surface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN; void surface_internal_preload(struct wined3d_surface *surface,
struct wined3d_context *context, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
void surface_invalidate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN; void surface_invalidate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
BOOL surface_is_offscreen(const struct wined3d_surface *surface) DECLSPEC_HIDDEN; BOOL surface_is_offscreen(const struct wined3d_surface *surface) DECLSPEC_HIDDEN;
HRESULT surface_load(struct wined3d_surface *surface, BOOL srgb) DECLSPEC_HIDDEN; HRESULT surface_load(struct wined3d_surface *surface, BOOL srgb) 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