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

wined3d: Pass a context to read_from_framebuffer.

parent 79361d3b
......@@ -1194,6 +1194,20 @@ 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)
{
if (context->current_rt != restore)
{
context_release(context);
context = context_acquire(restore->resource.device, restore);
}
context_release(context);
}
static void context_enter(struct wined3d_context *context)
{
TRACE("Entering context %p, level %u.\n", context, context->level + 1);
......
......@@ -2681,11 +2681,13 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc)
return WINED3D_OK;
}
static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_location)
static void read_from_framebuffer(struct wined3d_surface *surface,
struct wined3d_context *old_ctx, DWORD dst_location)
{
struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
struct wined3d_context *context = old_ctx;
struct wined3d_surface *restore_rt = NULL;
BYTE *mem;
BYTE *row, *top, *bottom;
int i;
......@@ -2694,7 +2696,12 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc
surface_get_memory(surface, &data, dst_location);
context = context_acquire(device, surface);
if (surface != old_ctx->current_rt)
{
restore_rt = old_ctx->current_rt;
context = context_acquire(device, surface);
}
context_apply_blit_state(context, device);
gl_info = context->gl_info;
......@@ -2781,7 +2788,8 @@ error:
checkGLcall("glBindBuffer");
}
context_release(context);
if (restore_rt)
context_restore(context, restore_rt);
}
/* Read the framebuffer contents into a texture. Note that this function
......@@ -3824,7 +3832,7 @@ static void surface_load_sysmem(struct wined3d_surface *surface,
if (surface->locations & WINED3D_LOCATION_DRAWABLE)
{
read_from_framebuffer(surface, dst_location);
read_from_framebuffer(surface, context, dst_location);
return;
}
......
......@@ -1423,6 +1423,7 @@ void context_resource_released(const struct wined3d_device *device,
struct wined3d_resource *resource, enum wined3d_resource_type type) DECLSPEC_HIDDEN;
void context_resource_unloaded(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;
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;
......
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