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

wined3d: Introduce wined3d_texture_invalidate_location().

parent 2f0a1214
...@@ -7937,7 +7937,7 @@ static void arbfp_blit_surface(struct wined3d_device *device, enum wined3d_blit_ ...@@ -7937,7 +7937,7 @@ static void arbfp_blit_surface(struct wined3d_device *device, enum wined3d_blit_
context_release(context); 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);
surface_invalidate_location(dst_surface, ~dst_texture->resource.draw_binding); wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~dst_texture->resource.draw_binding);
} }
static HRESULT arbfp_blit_color_fill(struct wined3d_device *device, struct wined3d_rendertarget_view *view, static HRESULT arbfp_blit_color_fill(struct wined3d_device *device, struct wined3d_rendertarget_view *view,
......
...@@ -3481,14 +3481,12 @@ static void context_setup_target(struct wined3d_context *context, ...@@ -3481,14 +3481,12 @@ static void context_setup_target(struct wined3d_context *context,
{ {
unsigned int prev_sub_resource_idx = context->current_rt.sub_resource_idx; unsigned int prev_sub_resource_idx = context->current_rt.sub_resource_idx;
struct wined3d_texture *prev_texture = context->current_rt.texture; struct wined3d_texture *prev_texture = context->current_rt.texture;
struct wined3d_surface *prev_surface;
/* 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 (prev_texture->texture_srgb.name) if (prev_texture->texture_srgb.name)
wined3d_texture_load(prev_texture, context, TRUE); wined3d_texture_load(prev_texture, context, TRUE);
wined3d_texture_load(prev_texture, context, FALSE); wined3d_texture_load(prev_texture, context, FALSE);
prev_surface = prev_texture->sub_resources[prev_sub_resource_idx].u.surface; wined3d_texture_invalidate_location(prev_texture, prev_sub_resource_idx, WINED3D_LOCATION_DRAWABLE);
surface_invalidate_location(prev_surface, WINED3D_LOCATION_DRAWABLE);
} }
} }
......
...@@ -399,13 +399,20 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c ...@@ -399,13 +399,20 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
for (i = 0; i < rt_count; ++i) for (i = 0; i < rt_count; ++i)
{ {
struct wined3d_rendertarget_view *rtv = fb->render_targets[i]; struct wined3d_rendertarget_view *rtv = fb->render_targets[i];
struct wined3d_surface *rt = wined3d_rendertarget_view_get_surface(rtv); struct wined3d_texture *texture;
if (rt) if (!rtv)
continue;
if (rtv->resource->type == WINED3D_RTYPE_BUFFER)
{ {
wined3d_texture_validate_location(rt->container, rtv->sub_resource_idx, rtv->resource->draw_binding); FIXME("Not supported on buffer resources.\n");
surface_invalidate_location(rt, ~rtv->resource->draw_binding); continue;
} }
texture = wined3d_texture_from_resource(rtv->resource);
wined3d_texture_validate_location(texture, rtv->sub_resource_idx, rtv->resource->draw_binding);
wined3d_texture_invalidate_location(texture, rtv->sub_resource_idx, ~rtv->resource->draw_binding);
} }
if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB] && needs_srgb_write(context, &device->state, fb)) if (!gl_info->supported[ARB_FRAMEBUFFER_SRGB] && needs_srgb_write(context, &device->state, fb))
...@@ -3570,7 +3577,7 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device, ...@@ -3570,7 +3577,7 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,
data.buffer_object = 0; data.buffer_object = 0;
data.addr = src.data; data.addr = src.data;
wined3d_volume_upload_data(dst_texture->sub_resources[i].u.volume, context, &data); wined3d_volume_upload_data(dst_texture->sub_resources[i].u.volume, context, &data);
wined3d_volume_invalidate_location(dst_texture->sub_resources[i].u.volume, ~WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_invalidate_location(dst_texture, i, ~WINED3D_LOCATION_TEXTURE_RGB);
if (FAILED(hr = wined3d_resource_unmap(&src_texture->resource, src_level + i))) if (FAILED(hr = wined3d_resource_unmap(&src_texture->resource, src_level + i)))
goto done; goto done;
...@@ -4120,7 +4127,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str ...@@ -4120,7 +4127,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
context_release(context); context_release(context);
wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
surface_invalidate_location(surface, ~WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_invalidate_location(texture, sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
} }
HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device, HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
......
...@@ -625,7 +625,8 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co ...@@ -625,7 +625,8 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co
if (state->render_states[WINED3D_RS_COLORWRITEENABLE]) if (state->render_states[WINED3D_RS_COLORWRITEENABLE])
{ {
surface_load_location(target, context, rtv->resource->draw_binding); surface_load_location(target, context, rtv->resource->draw_binding);
surface_invalidate_location(target, ~rtv->resource->draw_binding); wined3d_texture_invalidate_location(target->container,
rtv->sub_resource_idx, ~rtv->resource->draw_binding);
} }
else else
{ {
......
...@@ -505,6 +505,7 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface) ...@@ -505,6 +505,7 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface)
static void surface_evict_sysmem(struct wined3d_surface *surface) static void surface_evict_sysmem(struct wined3d_surface *surface)
{ {
unsigned int sub_resource_idx = surface_get_sub_resource_idx(surface);
struct wined3d_texture *texture = surface->container; struct wined3d_texture *texture = surface->container;
if (surface->resource.map_count || texture->download_count > MAXLOCKCOUNT if (surface->resource.map_count || texture->download_count > MAXLOCKCOUNT
...@@ -512,7 +513,7 @@ static void surface_evict_sysmem(struct wined3d_surface *surface) ...@@ -512,7 +513,7 @@ static void surface_evict_sysmem(struct wined3d_surface *surface)
return; return;
wined3d_resource_free_sysmem(&surface->resource); wined3d_resource_free_sysmem(&surface->resource);
surface_invalidate_location(surface, WINED3D_LOCATION_SYSMEM); wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_SYSMEM);
} }
static BOOL surface_is_full_rect(const struct wined3d_surface *surface, const RECT *r) static BOOL surface_is_full_rect(const struct wined3d_surface *surface, const RECT *r)
...@@ -925,20 +926,20 @@ static void surface_unload(struct wined3d_resource *resource) ...@@ -925,20 +926,20 @@ static void surface_unload(struct wined3d_resource *resource)
if (resource->usage & WINED3DUSAGE_DEPTHSTENCIL) if (resource->usage & WINED3DUSAGE_DEPTHSTENCIL)
{ {
wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_DISCARDED); wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_DISCARDED);
surface_invalidate_location(surface, ~WINED3D_LOCATION_DISCARDED); wined3d_texture_invalidate_location(texture, sub_resource_idx, ~WINED3D_LOCATION_DISCARDED);
} }
else else
{ {
surface_prepare_system_memory(surface); surface_prepare_system_memory(surface);
memset(surface->resource.heap_memory, 0, surface->resource.size); memset(surface->resource.heap_memory, 0, surface->resource.size);
wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_SYSMEM); wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_SYSMEM);
surface_invalidate_location(surface, ~WINED3D_LOCATION_SYSMEM); wined3d_texture_invalidate_location(texture, sub_resource_idx, ~WINED3D_LOCATION_SYSMEM);
} }
} }
else else
{ {
surface_load_location(surface, context, surface->resource.map_binding); surface_load_location(surface, context, surface->resource.map_binding);
surface_invalidate_location(surface, ~surface->resource.map_binding); wined3d_texture_invalidate_location(texture, sub_resource_idx, ~surface->resource.map_binding);
} }
/* Destroy fbo render buffers. This is needed for implicit render targets, for /* Destroy fbo render buffers. This is needed for implicit render targets, for
...@@ -1372,7 +1373,7 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P ...@@ -1372,7 +1373,7 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P
context_release(context); context_release(context);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
surface_invalidate_location(dst_surface, ~WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
return WINED3D_OK; return WINED3D_OK;
} }
...@@ -2166,7 +2167,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc ...@@ -2166,7 +2167,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc
/* The texture is now most up to date - If the surface is a render target /* The texture is now most up to date - If the surface is a render target
* and has a drawable, this path is never entered. */ * and has a drawable, this path is never entered. */
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
surface_invalidate_location(dst_surface, ~WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
} }
/* Uses the hardware to stretch and flip the image */ /* Uses the hardware to stretch and flip the image */
...@@ -2444,7 +2445,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st ...@@ -2444,7 +2445,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
/* The texture is now most up to date - If the surface is a render target /* The texture is now most up to date - If the surface is a render target
* and has a drawable, this path is never entered. */ * and has a drawable, this path is never entered. */
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
surface_invalidate_location(dst_surface, ~WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
} }
/* Front buffer coordinates are always full screen coordinates, but our GL /* Front buffer coordinates are always full screen coordinates, but our GL
...@@ -2917,21 +2918,6 @@ static void surface_load_ds_location(struct wined3d_surface *surface, struct win ...@@ -2917,21 +2918,6 @@ static void surface_load_ds_location(struct wined3d_surface *surface, struct win
} }
} }
void surface_invalidate_location(struct wined3d_surface *surface, DWORD location)
{
struct wined3d_texture_sub_resource *sub_resource;
TRACE("surface %p, location %s.\n", surface, wined3d_debug_location(location));
sub_resource = surface_get_sub_resource(surface);
if (location & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
wined3d_texture_set_dirty(surface->container);
sub_resource->locations &= ~location;
if (!sub_resource->locations)
ERR("Surface %p does not have any up to date location.\n", surface);
}
static DWORD resource_access_from_location(DWORD location) static DWORD resource_access_from_location(DWORD location)
{ {
switch (location) switch (location)
...@@ -3274,7 +3260,7 @@ HRESULT surface_load_location(struct wined3d_surface *surface, struct wined3d_co ...@@ -3274,7 +3260,7 @@ HRESULT surface_load_location(struct wined3d_surface *surface, struct wined3d_co
TRACE("Surface previously discarded, nothing to do.\n"); TRACE("Surface previously discarded, nothing to do.\n");
wined3d_surface_prepare(surface, context, location); wined3d_surface_prepare(surface, context, location);
wined3d_texture_validate_location(texture, sub_resource_idx, location); wined3d_texture_validate_location(texture, sub_resource_idx, location);
surface_invalidate_location(surface, WINED3D_LOCATION_DISCARDED); wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_DISCARDED);
goto done; goto done;
} }
...@@ -3506,7 +3492,7 @@ static void ffp_blit_blit_surface(struct wined3d_device *device, enum wined3d_bl ...@@ -3506,7 +3492,7 @@ static void ffp_blit_blit_surface(struct wined3d_device *device, enum wined3d_bl
(old_color_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL); (old_color_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL);
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);
surface_invalidate_location(dst_surface, ~dst_texture->resource.draw_binding); wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~dst_texture->resource.draw_binding);
} }
const struct blit_shader ffp_blit = { const struct blit_shader ffp_blit = {
...@@ -4475,7 +4461,8 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst ...@@ -4475,7 +4461,8 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx,
dst_texture->resource.draw_binding); dst_texture->resource.draw_binding);
surface_invalidate_location(dst_surface, ~dst_texture->resource.draw_binding); wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx,
~dst_texture->resource.draw_binding);
return WINED3D_OK; return WINED3D_OK;
} }
...@@ -4614,7 +4601,7 @@ HRESULT wined3d_surface_init(struct wined3d_surface *surface, struct wined3d_tex ...@@ -4614,7 +4601,7 @@ HRESULT wined3d_surface_init(struct wined3d_surface *surface, struct wined3d_tex
{ {
wined3d_resource_free_sysmem(&surface->resource); wined3d_resource_free_sysmem(&surface->resource);
wined3d_texture_validate_location(container, sub_resource_idx, WINED3D_LOCATION_DIB); wined3d_texture_validate_location(container, sub_resource_idx, WINED3D_LOCATION_DIB);
surface_invalidate_location(surface, WINED3D_LOCATION_SYSMEM); wined3d_texture_invalidate_location(container, sub_resource_idx, WINED3D_LOCATION_SYSMEM);
} }
return hr; return hr;
......
...@@ -430,6 +430,7 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain, ...@@ -430,6 +430,7 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
static void wined3d_swapchain_rotate(struct wined3d_swapchain *swapchain, struct wined3d_context *context) static void wined3d_swapchain_rotate(struct wined3d_swapchain *swapchain, struct wined3d_context *context)
{ {
struct wined3d_texture_sub_resource *sub_resource; struct wined3d_texture_sub_resource *sub_resource;
struct wined3d_texture *texture, *texture_prev;
struct gl_texture tex0; struct gl_texture tex0;
GLuint rb0; GLuint rb0;
DWORD locations0; DWORD locations0;
...@@ -440,36 +441,38 @@ static void wined3d_swapchain_rotate(struct wined3d_swapchain *swapchain, struct ...@@ -440,36 +441,38 @@ static void wined3d_swapchain_rotate(struct wined3d_swapchain *swapchain, struct
if (swapchain->desc.backbuffer_count < 2 || !swapchain->render_to_fbo) if (swapchain->desc.backbuffer_count < 2 || !swapchain->render_to_fbo)
return; return;
surface_prev = swapchain->back_buffers[0]->sub_resources[0].u.surface; texture_prev = swapchain->back_buffers[0];
surface_prev = texture_prev->sub_resources[0].u.surface;
/* Back buffer 0 is already in the draw binding. */ /* Back buffer 0 is already in the draw binding. */
tex0 = swapchain->back_buffers[0]->texture_rgb; tex0 = texture_prev->texture_rgb;
rb0 = surface_prev->rb_multisample; rb0 = surface_prev->rb_multisample;
locations0 = surface_get_sub_resource(surface_prev)->locations; locations0 = texture_prev->sub_resources[0].locations;
for (i = 1; i < swapchain->desc.backbuffer_count; ++i) for (i = 1; i < swapchain->desc.backbuffer_count; ++i)
{ {
sub_resource = &swapchain->back_buffers[i]->sub_resources[0]; texture = swapchain->back_buffers[i];
sub_resource = &texture->sub_resources[0];
surface = sub_resource->u.surface; surface = sub_resource->u.surface;
if (!(sub_resource->locations & supported_locations)) if (!(sub_resource->locations & supported_locations))
surface_load_location(surface, context, swapchain->back_buffers[i]->resource.draw_binding); surface_load_location(surface, context, texture->resource.draw_binding);
swapchain->back_buffers[i - 1]->texture_rgb = swapchain->back_buffers[i]->texture_rgb; texture_prev->texture_rgb = texture->texture_rgb;
surface_prev->rb_multisample = surface->rb_multisample; surface_prev->rb_multisample = surface->rb_multisample;
wined3d_texture_validate_location(swapchain->back_buffers[i - 1], 0, wined3d_texture_validate_location(texture_prev, 0, sub_resource->locations & supported_locations);
sub_resource->locations & supported_locations); wined3d_texture_invalidate_location(texture_prev, 0, ~(sub_resource->locations & supported_locations));
surface_invalidate_location(surface_prev, ~(sub_resource->locations & supported_locations));
texture_prev = texture;
surface_prev = surface; surface_prev = surface;
} }
swapchain->back_buffers[i - 1]->texture_rgb = tex0; texture_prev->texture_rgb = tex0;
surface_prev->rb_multisample = rb0; surface_prev->rb_multisample = rb0;
wined3d_texture_validate_location(swapchain->back_buffers[i - 1], 0, locations0 & supported_locations); wined3d_texture_validate_location(texture_prev, 0, locations0 & supported_locations);
surface_invalidate_location(surface_prev, ~(locations0 & supported_locations)); wined3d_texture_invalidate_location(texture_prev, 0, ~(locations0 & supported_locations));
device_invalidate_state(swapchain->device, STATE_FRAMEBUFFER); device_invalidate_state(swapchain->device, STATE_FRAMEBUFFER);
} }
...@@ -555,7 +558,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, ...@@ -555,7 +558,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
if (!swapchain->render_to_fbo && render_to_fbo && wined3d_settings.offscreen_rendering_mode == ORM_FBO) if (!swapchain->render_to_fbo && render_to_fbo && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{ {
surface_load_location(back_buffer, context, WINED3D_LOCATION_TEXTURE_RGB); surface_load_location(back_buffer, context, WINED3D_LOCATION_TEXTURE_RGB);
surface_invalidate_location(back_buffer, WINED3D_LOCATION_DRAWABLE); wined3d_texture_invalidate_location(back_buffer->container, 0, WINED3D_LOCATION_DRAWABLE);
swapchain->render_to_fbo = TRUE; swapchain->render_to_fbo = TRUE;
swapchain_update_draw_bindings(swapchain); swapchain_update_draw_bindings(swapchain);
} }
...@@ -600,7 +603,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, ...@@ -600,7 +603,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
} }
wined3d_texture_validate_location(swapchain->front_buffer, 0, WINED3D_LOCATION_DRAWABLE); wined3d_texture_validate_location(swapchain->front_buffer, 0, WINED3D_LOCATION_DRAWABLE);
surface_invalidate_location(swapchain->front_buffer->sub_resources[0].u.surface, ~WINED3D_LOCATION_DRAWABLE); wined3d_texture_invalidate_location(swapchain->front_buffer, 0, ~WINED3D_LOCATION_DRAWABLE);
/* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM /* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM
* and INTEXTURE copies can keep their old content if they have any defined content. * and INTEXTURE copies can keep their old content if they have any defined content.
* If the swapeffect is COPY, the content remains the same. * If the swapeffect is COPY, the content remains the same.
...@@ -911,7 +914,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3 ...@@ -911,7 +914,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
if (!(device->wined3d->flags & WINED3D_NO3D)) if (!(device->wined3d->flags & WINED3D_NO3D))
{ {
wined3d_texture_validate_location(swapchain->front_buffer, 0, WINED3D_LOCATION_DRAWABLE); wined3d_texture_validate_location(swapchain->front_buffer, 0, WINED3D_LOCATION_DRAWABLE);
surface_invalidate_location(swapchain->front_buffer->sub_resources[0].u.surface, ~WINED3D_LOCATION_DRAWABLE); wined3d_texture_invalidate_location(swapchain->front_buffer, 0, ~WINED3D_LOCATION_DRAWABLE);
} }
/* MSDN says we're only allowed a single fullscreen swapchain per device, /* MSDN says we're only allowed a single fullscreen swapchain per device,
......
...@@ -83,6 +83,27 @@ void wined3d_texture_validate_location(struct wined3d_texture *texture, ...@@ -83,6 +83,27 @@ void wined3d_texture_validate_location(struct wined3d_texture *texture,
TRACE("New locations flags are %s.\n", wined3d_debug_location(sub_resource->locations)); TRACE("New locations flags are %s.\n", wined3d_debug_location(sub_resource->locations));
} }
void wined3d_texture_invalidate_location(struct wined3d_texture *texture,
unsigned int sub_resource_idx, DWORD location)
{
struct wined3d_texture_sub_resource *sub_resource;
TRACE("texture %p, sub_resource_idx %u, location %s.\n",
texture, sub_resource_idx, wined3d_debug_location(location));
if (location & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
wined3d_texture_set_dirty(texture);
sub_resource = &texture->sub_resources[sub_resource_idx];
sub_resource->locations &= ~location;
TRACE("New locations flags are %s.\n", wined3d_debug_location(sub_resource->locations));
if (!sub_resource->locations)
ERR("Sub-resource %u of texture %p does not have any up to date location.\n",
sub_resource_idx, texture);
}
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops, static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops,
UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags, UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags,
struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops,
...@@ -141,8 +162,7 @@ void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture, ...@@ -141,8 +162,7 @@ void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture,
buffer_object = &texture->sub_resources[sub_resource_idx].buffer_object; buffer_object = &texture->sub_resources[sub_resource_idx].buffer_object;
GL_EXTCALL(glDeleteBuffers(1, buffer_object)); GL_EXTCALL(glDeleteBuffers(1, buffer_object));
checkGLcall("glDeleteBuffers"); checkGLcall("glDeleteBuffers");
texture->texture_ops->texture_sub_resource_invalidate_location( wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_BUFFER);
texture->sub_resources[sub_resource_idx].resource, WINED3D_LOCATION_BUFFER);
*buffer_object = 0; *buffer_object = 0;
TRACE("Deleted buffer object %u for texture %p, sub-resource %u.\n", TRACE("Deleted buffer object %u for texture %p, sub-resource %u.\n",
...@@ -584,8 +604,7 @@ void wined3d_texture_load(struct wined3d_texture *texture, ...@@ -584,8 +604,7 @@ void wined3d_texture_load(struct wined3d_texture *texture,
if (!texture->texture_ops->texture_load_location(texture, i, context, sub_resource->map_binding)) if (!texture->texture_ops->texture_load_location(texture, i, context, sub_resource->map_binding))
ERR("Failed to load location %s.\n", wined3d_debug_location(sub_resource->map_binding)); ERR("Failed to load location %s.\n", wined3d_debug_location(sub_resource->map_binding));
else else
texture->texture_ops->texture_sub_resource_invalidate_location(sub_resource, wined3d_texture_invalidate_location(texture, i, ~sub_resource->map_binding);
~sub_resource->map_binding);
} }
texture->async.gl_color_key = texture->async.src_blt_color_key; texture->async.gl_color_key = texture->async.src_blt_color_key;
...@@ -907,7 +926,7 @@ static void wined3d_texture_force_reload(struct wined3d_texture *texture) ...@@ -907,7 +926,7 @@ static void wined3d_texture_force_reload(struct wined3d_texture *texture)
texture->async.flags &= ~WINED3D_TEXTURE_ASYNC_COLOR_KEY; texture->async.flags &= ~WINED3D_TEXTURE_ASYNC_COLOR_KEY;
for (i = 0; i < sub_count; ++i) for (i = 0; i < sub_count; ++i)
{ {
texture->texture_ops->texture_sub_resource_invalidate_location(texture->sub_resources[i].resource, wined3d_texture_invalidate_location(texture, i,
WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB); WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB);
} }
} }
...@@ -982,7 +1001,7 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture, ...@@ -982,7 +1001,7 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
context_release(context); context_release(context);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
texture->texture_ops->texture_sub_resource_invalidate_location(sub_resource, ~sub_resource->map_binding); wined3d_texture_invalidate_location(texture, sub_resource_idx, ~sub_resource->map_binding);
context_release(context); context_release(context);
return WINED3D_OK; return WINED3D_OK;
...@@ -1015,7 +1034,7 @@ static HRESULT wined3d_texture_upload_data(struct wined3d_texture *texture, ...@@ -1015,7 +1034,7 @@ static HRESULT wined3d_texture_upload_data(struct wined3d_texture *texture,
texture->texture_ops->texture_sub_resource_upload_data(sub_resource, context, &data[i]); texture->texture_ops->texture_sub_resource_upload_data(sub_resource, context, &data[i]);
wined3d_texture_validate_location(texture, i, WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_validate_location(texture, i, WINED3D_LOCATION_TEXTURE_RGB);
texture->texture_ops->texture_sub_resource_invalidate_location(sub_resource, ~WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_invalidate_location(texture, i, ~WINED3D_LOCATION_TEXTURE_RGB);
} }
context_release(context); context_release(context);
...@@ -1029,13 +1048,6 @@ static void texture2d_sub_resource_load(struct wined3d_resource *sub_resource, ...@@ -1029,13 +1048,6 @@ static void texture2d_sub_resource_load(struct wined3d_resource *sub_resource,
surface_load(surface_from_resource(sub_resource), context, srgb); surface_load(surface_from_resource(sub_resource), context, srgb);
} }
static void texture2d_sub_resource_invalidate_location(struct wined3d_resource *sub_resource, DWORD location)
{
struct wined3d_surface *surface = surface_from_resource(sub_resource);
surface_invalidate_location(surface, location);
}
static void texture2d_sub_resource_upload_data(struct wined3d_resource *sub_resource, static void texture2d_sub_resource_upload_data(struct wined3d_resource *sub_resource,
const struct wined3d_context *context, const struct wined3d_sub_resource_data *data) const struct wined3d_context *context, const struct wined3d_sub_resource_data *data)
{ {
...@@ -1147,7 +1159,6 @@ static void texture2d_cleanup_sub_resources(struct wined3d_texture *texture) ...@@ -1147,7 +1159,6 @@ static void texture2d_cleanup_sub_resources(struct wined3d_texture *texture)
static const struct wined3d_texture_ops texture2d_ops = static const struct wined3d_texture_ops texture2d_ops =
{ {
texture2d_sub_resource_load, texture2d_sub_resource_load,
texture2d_sub_resource_invalidate_location,
texture2d_sub_resource_upload_data, texture2d_sub_resource_upload_data,
texture2d_load_location, texture2d_load_location,
texture2d_prepare_location, texture2d_prepare_location,
...@@ -1277,7 +1288,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour ...@@ -1277,7 +1288,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
} }
if (!(flags & (WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READONLY))) if (!(flags & (WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READONLY)))
texture->texture_ops->texture_sub_resource_invalidate_location(sub_resource, ~sub_resource->map_binding); wined3d_texture_invalidate_location(texture, sub_resource_idx, ~sub_resource->map_binding);
switch (sub_resource->map_binding) switch (sub_resource->map_binding)
{ {
...@@ -1655,13 +1666,6 @@ static void texture3d_sub_resource_load(struct wined3d_resource *sub_resource, ...@@ -1655,13 +1666,6 @@ static void texture3d_sub_resource_load(struct wined3d_resource *sub_resource,
wined3d_volume_load(volume_from_resource(sub_resource), context, srgb); wined3d_volume_load(volume_from_resource(sub_resource), context, srgb);
} }
static void texture3d_sub_resource_invalidate_location(struct wined3d_resource *sub_resource, DWORD location)
{
struct wined3d_volume *volume = volume_from_resource(sub_resource);
wined3d_volume_invalidate_location(volume, location);
}
static void texture3d_sub_resource_upload_data(struct wined3d_resource *sub_resource, static void texture3d_sub_resource_upload_data(struct wined3d_resource *sub_resource,
const struct wined3d_context *context, const struct wined3d_sub_resource_data *data) const struct wined3d_context *context, const struct wined3d_sub_resource_data *data)
{ {
...@@ -1734,7 +1738,6 @@ static void texture3d_cleanup_sub_resources(struct wined3d_texture *texture) ...@@ -1734,7 +1738,6 @@ static void texture3d_cleanup_sub_resources(struct wined3d_texture *texture)
static const struct wined3d_texture_ops texture3d_ops = static const struct wined3d_texture_ops texture3d_ops =
{ {
texture3d_sub_resource_load, texture3d_sub_resource_load,
texture3d_sub_resource_invalidate_location,
texture3d_sub_resource_upload_data, texture3d_sub_resource_upload_data,
texture3d_load_location, texture3d_load_location,
texture3d_prepare_location, texture3d_prepare_location,
...@@ -2239,7 +2242,7 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i ...@@ -2239,7 +2242,7 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
} }
surface_load_location(surface, context, WINED3D_LOCATION_DIB); surface_load_location(surface, context, WINED3D_LOCATION_DIB);
surface_invalidate_location(surface, ~WINED3D_LOCATION_DIB); wined3d_texture_invalidate_location(texture, sub_resource_idx, ~WINED3D_LOCATION_DIB);
if (context) if (context)
context_release(context); context_release(context);
...@@ -2302,7 +2305,7 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign ...@@ -2302,7 +2305,7 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign
context = context_acquire(device, NULL); context = context_acquire(device, NULL);
surface_load_location(surface, context, surface->resource.map_binding); surface_load_location(surface, context, surface->resource.map_binding);
surface_invalidate_location(surface, WINED3D_LOCATION_DIB); wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_DIB);
if (context) if (context)
context_release(context); context_release(context);
} }
......
...@@ -130,20 +130,6 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine ...@@ -130,20 +130,6 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
HeapFree(GetProcessHeap(), 0, converted_mem); HeapFree(GetProcessHeap(), 0, converted_mem);
} }
void wined3d_volume_invalidate_location(struct wined3d_volume *volume, DWORD location)
{
struct wined3d_texture_sub_resource *sub_resource;
TRACE("Volume %p, clearing %s.\n", volume, wined3d_debug_location(location));
sub_resource = &volume->container->sub_resources[volume->texture_level];
if (location & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
wined3d_texture_set_dirty(volume->container);
sub_resource->locations &= ~location;
TRACE("new location flags are %s.\n", wined3d_debug_location(sub_resource->locations));
}
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void wined3d_volume_download_data(struct wined3d_volume *volume, static void wined3d_volume_download_data(struct wined3d_volume *volume,
const struct wined3d_context *context, const struct wined3d_bo_address *data) const struct wined3d_context *context, const struct wined3d_bo_address *data)
...@@ -179,7 +165,7 @@ static void wined3d_volume_download_data(struct wined3d_volume *volume, ...@@ -179,7 +165,7 @@ static void wined3d_volume_download_data(struct wined3d_volume *volume,
static void wined3d_volume_evict_sysmem(struct wined3d_volume *volume) static void wined3d_volume_evict_sysmem(struct wined3d_volume *volume)
{ {
wined3d_resource_free_sysmem(&volume->resource); wined3d_resource_free_sysmem(&volume->resource);
wined3d_volume_invalidate_location(volume, WINED3D_LOCATION_SYSMEM); wined3d_texture_invalidate_location(volume->container, volume->texture_level, WINED3D_LOCATION_SYSMEM);
} }
static DWORD volume_access_from_location(DWORD location) static DWORD volume_access_from_location(DWORD location)
...@@ -275,7 +261,8 @@ BOOL wined3d_volume_load_location(struct wined3d_volume *volume, ...@@ -275,7 +261,8 @@ BOOL wined3d_volume_load_location(struct wined3d_volume *volume,
if (sub_resource->locations & WINED3D_LOCATION_DISCARDED) if (sub_resource->locations & WINED3D_LOCATION_DISCARDED)
{ {
TRACE("Volume previously discarded, nothing to do.\n"); TRACE("Volume previously discarded, nothing to do.\n");
wined3d_volume_invalidate_location(volume, WINED3D_LOCATION_DISCARDED); wined3d_texture_validate_location(texture, sub_resource_idx, location);
wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_DISCARDED);
goto done; goto done;
} }
...@@ -398,13 +385,13 @@ static void volume_unload(struct wined3d_resource *resource) ...@@ -398,13 +385,13 @@ static void volume_unload(struct wined3d_resource *resource)
context = context_acquire(device, NULL); context = context_acquire(device, NULL);
if (wined3d_volume_load_location(volume, context, WINED3D_LOCATION_SYSMEM)) if (wined3d_volume_load_location(volume, context, WINED3D_LOCATION_SYSMEM))
{ {
wined3d_volume_invalidate_location(volume, ~WINED3D_LOCATION_SYSMEM); wined3d_texture_invalidate_location(texture, volume->texture_level, ~WINED3D_LOCATION_SYSMEM);
} }
else else
{ {
ERR("Out of memory when unloading volume %p.\n", volume); ERR("Out of memory when unloading volume %p.\n", volume);
wined3d_texture_validate_location(texture, volume->texture_level, WINED3D_LOCATION_DISCARDED); wined3d_texture_validate_location(texture, volume->texture_level, WINED3D_LOCATION_DISCARDED);
wined3d_volume_invalidate_location(volume, ~WINED3D_LOCATION_DISCARDED); wined3d_texture_invalidate_location(texture, volume->texture_level, ~WINED3D_LOCATION_DISCARDED);
} }
context_release(context); context_release(context);
......
...@@ -2369,7 +2369,6 @@ struct wined3d_texture_ops ...@@ -2369,7 +2369,6 @@ struct wined3d_texture_ops
{ {
void (*texture_sub_resource_load)(struct wined3d_resource *sub_resource, void (*texture_sub_resource_load)(struct wined3d_resource *sub_resource,
struct wined3d_context *context, BOOL srgb); struct wined3d_context *context, BOOL srgb);
void (*texture_sub_resource_invalidate_location)(struct wined3d_resource *sub_resource, DWORD location);
void (*texture_sub_resource_upload_data)(struct wined3d_resource *sub_resource, void (*texture_sub_resource_upload_data)(struct wined3d_resource *sub_resource,
const struct wined3d_context *context, const struct wined3d_sub_resource_data *data); const struct wined3d_context *context, const struct wined3d_sub_resource_data *data);
BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx, BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
...@@ -2483,6 +2482,8 @@ BOOL wined3d_texture_check_block_align(const struct wined3d_texture *texture, ...@@ -2483,6 +2482,8 @@ BOOL wined3d_texture_check_block_align(const struct wined3d_texture *texture,
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN; GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
struct wined3d_resource *wined3d_texture_get_sub_resource(const struct wined3d_texture *texture, struct wined3d_resource *wined3d_texture_get_sub_resource(const struct wined3d_texture *texture,
UINT sub_resource_idx) DECLSPEC_HIDDEN; UINT sub_resource_idx) DECLSPEC_HIDDEN;
void wined3d_texture_invalidate_location(struct wined3d_texture *texture,
unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
void wined3d_texture_load(struct wined3d_texture *texture, void wined3d_texture_load(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_prepare_buffer_object(struct wined3d_texture *texture, void wined3d_texture_prepare_buffer_object(struct wined3d_texture *texture,
...@@ -2647,7 +2648,6 @@ void surface_get_drawable_size(const struct wined3d_surface *surface, const stru ...@@ -2647,7 +2648,6 @@ void surface_get_drawable_size(const struct wined3d_surface *surface, const stru
HRESULT wined3d_surface_init(struct wined3d_surface *surface, HRESULT wined3d_surface_init(struct wined3d_surface *surface,
struct wined3d_texture *container, const struct wined3d_resource_desc *desc, struct wined3d_texture *container, const struct wined3d_resource_desc *desc,
GLenum target, unsigned int level, unsigned int layer, DWORD flags) DECLSPEC_HIDDEN; GLenum target, unsigned int level, unsigned int layer, DWORD flags) DECLSPEC_HIDDEN;
void surface_invalidate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
void surface_load(struct wined3d_surface *surface, struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; void surface_load(struct wined3d_surface *surface, struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb,
struct wined3d_context *context) DECLSPEC_HIDDEN; struct wined3d_context *context) 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