wined3d: Invalidate all layers locations for render target views.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-04-18 11:24:14 +02:00 committed by Alexandre Julliard
parent 6920164824
commit a912c95d96
3 changed files with 31 additions and 23 deletions

View File

@ -499,16 +499,13 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
for (i = 0; i < gl_info->limits.buffers; ++i) for (i = 0; i < gl_info->limits.buffers; ++i)
{ {
struct wined3d_texture *rt;
if (!(rtv = fb->render_targets[i]) || rtv->format->id == WINED3DFMT_NULL) if (!(rtv = fb->render_targets[i]) || rtv->format->id == WINED3DFMT_NULL)
continue; continue;
rt = wined3d_texture_from_resource(rtv->resource);
if (state->render_states[WINED3D_RS_COLORWRITEENABLE]) if (state->render_states[WINED3D_RS_COLORWRITEENABLE])
{ {
wined3d_rendertarget_view_load_location(rtv, context, rtv->resource->draw_binding); wined3d_rendertarget_view_load_location(rtv, context, rtv->resource->draw_binding);
wined3d_texture_invalidate_location(rt, rtv->sub_resource_idx, ~rtv->resource->draw_binding); wined3d_rendertarget_view_invalidate_location(rtv, ~rtv->resource->draw_binding);
} }
else else
{ {
@ -540,11 +537,10 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
if (dsv && state->render_states[WINED3D_RS_ZWRITEENABLE]) if (dsv && state->render_states[WINED3D_RS_ZWRITEENABLE])
{ {
struct wined3d_surface *ds = wined3d_rendertarget_view_get_surface(dsv); DWORD location = context->render_offscreen ? dsv->resource->draw_binding : WINED3D_LOCATION_DRAWABLE;
DWORD location = context->render_offscreen ? ds->container->resource.draw_binding : WINED3D_LOCATION_DRAWABLE;
wined3d_rendertarget_view_validate_location(dsv, location); wined3d_rendertarget_view_validate_location(dsv, location);
wined3d_texture_invalidate_location(ds->container, dsv->sub_resource_idx, ~location); wined3d_rendertarget_view_invalidate_location(dsv, ~location);
} }
stream_info = &context->stream_info; stream_info = &context->stream_info;

View File

@ -270,6 +270,26 @@ static void create_buffer_view(struct wined3d_gl_view *view, struct wined3d_cont
create_buffer_texture(view, context, buffer, view_format, offset, size); create_buffer_texture(view, context, buffer, view_format, offset, size);
} }
static void wined3d_view_invalidate_location(struct wined3d_resource *resource,
const struct wined3d_view_desc *desc, DWORD location)
{
unsigned int i, sub_resource_idx, layer_count;
struct wined3d_texture *texture;
if (resource->type == WINED3D_RTYPE_BUFFER)
{
wined3d_buffer_invalidate_location(buffer_from_resource(resource), location);
return;
}
texture = texture_from_resource(resource);
sub_resource_idx = desc->u.texture.layer_idx * texture->level_count + desc->u.texture.level_idx;
layer_count = resource->type != WINED3D_RTYPE_TEXTURE_3D ? desc->u.texture.layer_count : 1;
for (i = 0; i < layer_count; ++i, sub_resource_idx += texture->level_count)
wined3d_texture_invalidate_location(texture, sub_resource_idx, location);
}
ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view) ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view)
{ {
ULONG refcount = InterlockedIncrement(&view->refcount); ULONG refcount = InterlockedIncrement(&view->refcount);
@ -454,6 +474,11 @@ void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_vie
wined3d_texture_validate_location(texture, sub_resource_idx, location); wined3d_texture_validate_location(texture, sub_resource_idx, location);
} }
void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view, DWORD location)
{
wined3d_view_invalidate_location(view->resource, &view->desc, location);
}
static void wined3d_render_target_view_cs_init(void *object) static void wined3d_render_target_view_cs_init(void *object)
{ {
struct wined3d_rendertarget_view *view = object; struct wined3d_rendertarget_view *view = object;
@ -819,22 +844,7 @@ void * CDECL wined3d_unordered_access_view_get_parent(const struct wined3d_unord
void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view, void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view,
DWORD location) DWORD location)
{ {
struct wined3d_resource *resource = view->resource; wined3d_view_invalidate_location(view->resource, &view->desc, location);
unsigned int i, sub_resource_idx, layer_count;
struct wined3d_texture *texture;
if (resource->type == WINED3D_RTYPE_BUFFER)
{
wined3d_buffer_invalidate_location(buffer_from_resource(resource), location);
return;
}
texture = texture_from_resource(resource);
sub_resource_idx = view->desc.u.texture.layer_idx * texture->level_count + view->desc.u.texture.level_idx;
layer_count = (resource->type != WINED3D_RTYPE_TEXTURE_3D) ? view->desc.u.texture.layer_count : 1;
for (i = 0; i < layer_count; ++i, sub_resource_idx += texture->level_count)
wined3d_texture_invalidate_location(texture, sub_resource_idx, location);
} }
static void wined3d_unordered_access_view_cs_init(void *object) static void wined3d_unordered_access_view_cs_init(void *object)

View File

@ -3458,6 +3458,8 @@ static inline struct wined3d_surface *wined3d_rendertarget_view_get_surface(
void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view, void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view,
const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN; const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view,
DWORD location) DECLSPEC_HIDDEN;
void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view, void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view, void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view,