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

wined3d: Pass a context to surface_load_location.

parent 14f02404
......@@ -2277,7 +2277,7 @@ static BOOL match_depth_stencil_format(const struct wined3d_format *existing,
return TRUE;
}
/* The caller provides a context */
/* Context activation is done by the caller. */
static void context_validate_onscreen_formats(struct wined3d_context *context,
const struct wined3d_rendertarget_view *depth_stencil)
{
......@@ -2293,7 +2293,7 @@ static void context_validate_onscreen_formats(struct wined3d_context *context,
WARN("Depth stencil format is not supported by WGL, rendering the backbuffer in an FBO\n");
/* The currently active context is the necessary context to access the swapchain's onscreen buffers */
surface_load_location(context->current_rt, WINED3D_LOCATION_TEXTURE_RGB);
surface_load_location(context->current_rt, context, WINED3D_LOCATION_TEXTURE_RGB);
swapchain->render_to_fbo = TRUE;
swapchain_update_draw_bindings(swapchain);
context_set_render_offscreen(context, TRUE);
......
......@@ -300,6 +300,15 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
unsigned int i;
RECT ds_rect;
context = context_acquire(device, target);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping clear.\n");
return;
}
gl_info = context->gl_info;
/* When we're clearing parts of the drawable, make sure that the target surface is well up to date in the
* drawable. After the clear we'll mark the drawable up to date, so we have to make sure that this is true
* for the cleared parts, and the untouched parts.
......@@ -314,19 +323,10 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
{
struct wined3d_surface *rt = wined3d_rendertarget_view_get_surface(fb->render_targets[i]);
if (rt)
surface_load_location(rt, rt->container->resource.draw_binding);
surface_load_location(rt, context, rt->container->resource.draw_binding);
}
}
context = context_acquire(device, target);
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping clear.\n");
return;
}
gl_info = context->gl_info;
if (target)
{
render_offscreen = context->render_offscreen;
......@@ -4015,7 +4015,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
&& src_rect.bottom == sub_resource->height)
wined3d_texture_prepare_texture(texture, context, FALSE);
else
surface_load_location(surface, WINED3D_LOCATION_TEXTURE_RGB);
surface_load_location(surface, context, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_bind_and_dirtify(texture, context, FALSE);
wined3d_surface_upload_data(surface, gl_info, resource->format,
......
......@@ -611,6 +611,15 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co
if (!index_count) return;
context = context_acquire(device, wined3d_rendertarget_view_get_surface(device->fb.render_targets[0]));
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping draw.\n");
return;
}
gl_info = context->gl_info;
if (state->render_states[WINED3D_RS_COLORWRITEENABLE])
{
/* Invalidate the back buffer memory so LockRect will read it the next time */
......@@ -619,21 +628,12 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co
struct wined3d_surface *target = wined3d_rendertarget_view_get_surface(device->fb.render_targets[i]);
if (target)
{
surface_load_location(target, target->container->resource.draw_binding);
surface_load_location(target, context, target->container->resource.draw_binding);
surface_invalidate_location(target, ~target->container->resource.draw_binding);
}
}
}
context = context_acquire(device, wined3d_rendertarget_view_get_surface(device->fb.render_targets[0]));
if (!context->valid)
{
context_release(context);
WARN("Invalid context, skipping draw.\n");
return;
}
gl_info = context->gl_info;
if (device->fb.depth_stencil)
{
/* Note that this depends on the context_acquire() call above to set
......
......@@ -309,7 +309,7 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
if (backbuffer->resource.multisample_type)
{
location = WINED3D_LOCATION_RB_RESOLVED;
surface_load_location(backbuffer, location);
surface_load_location(backbuffer, context, location);
}
context_apply_fbo_state_blit(context, GL_READ_FRAMEBUFFER, backbuffer, NULL, location);
......@@ -511,14 +511,14 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT
*/
if (!swapchain->render_to_fbo && render_to_fbo && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
surface_load_location(back_buffer, WINED3D_LOCATION_TEXTURE_RGB);
surface_load_location(back_buffer, context, WINED3D_LOCATION_TEXTURE_RGB);
surface_invalidate_location(back_buffer, WINED3D_LOCATION_DRAWABLE);
swapchain->render_to_fbo = TRUE;
swapchain_update_draw_bindings(swapchain);
}
else
{
surface_load_location(back_buffer, back_buffer->container->resource.draw_binding);
surface_load_location(back_buffer, context, back_buffer->container->resource.draw_binding);
}
if (swapchain->render_to_fbo)
......@@ -611,7 +611,7 @@ void x11_copy_to_screen(const struct wined3d_swapchain *swapchain, const RECT *r
TRACE("Copying surface %p to screen.\n", front);
surface_load_location(front, WINED3D_LOCATION_DIB);
surface_load_location(front, NULL, WINED3D_LOCATION_DIB);
src_dc = front->hDC;
window = swapchain->win_handle;
......
......@@ -762,16 +762,19 @@ static HRESULT wined3d_texture_upload_data(struct wined3d_texture *texture,
static void texture2d_sub_resource_load(struct wined3d_resource *sub_resource,
struct wined3d_context *context, BOOL srgb)
{
surface_load(surface_from_resource(sub_resource), srgb);
surface_load(surface_from_resource(sub_resource), context, srgb);
}
static void texture2d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource,
const struct wined3d_box *dirty_region)
{
struct wined3d_surface *surface = surface_from_resource(sub_resource);
struct wined3d_context *context;
surface_prepare_map_memory(surface);
surface_load_location(surface, surface->resource.map_binding);
context = context_acquire(surface->resource.device, NULL);
surface_load_location(surface, context, surface->resource.map_binding);
context_release(context);
surface_invalidate_location(surface, ~surface->resource.map_binding);
}
......
......@@ -2445,12 +2445,13 @@ GLenum surface_get_gl_buffer(const struct wined3d_surface *surface) DECLSPEC_HID
void surface_get_drawable_size(const struct wined3d_surface *surface, const struct wined3d_context *context,
unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
void surface_invalidate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
void surface_load(struct wined3d_surface *surface, BOOL srgb) DECLSPEC_HIDDEN;
void surface_load(struct wined3d_surface *surface, struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void surface_load_ds_location(struct wined3d_surface *surface,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb,
struct wined3d_context *context) DECLSPEC_HIDDEN;
HRESULT surface_load_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
HRESULT surface_load_location(struct wined3d_surface *surface,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
void surface_modify_ds_location(struct wined3d_surface *surface, DWORD location, UINT w, UINT h) DECLSPEC_HIDDEN;
void surface_prepare_rb(struct wined3d_surface *surface,
const struct wined3d_gl_info *gl_info, BOOL multisample) 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