gallium: Fix the ->set_damage_region() implementation

BACK_LEFT attachment can be outdated when the user calls
KHR_partial_update() (->lastStamp != ->texture_stamp), leading to a
damage region update on the wrong pipe_resource object.
Let's delay the ->set_damage_region() call until the attachments are
updated when we're in that case.

Reported-by: Carsten Haitzler <raster@rasterman.com>
Fixes: 492ffbed63 ("st/dri2: Implement DRI2bufferDamageExtension")
Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Boris Brezillon 2019-11-09 00:02:54 +01:00
parent 5fcb503c73
commit b196e1a8cf
3 changed files with 35 additions and 4 deletions

View file

@ -1879,8 +1879,6 @@ static void
dri2_set_damage_region(__DRIdrawable *dPriv, unsigned int nrects, int *rects)
{
struct dri_drawable *drawable = dri_drawable(dPriv);
struct pipe_resource *resource = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
struct pipe_screen *screen = resource->screen;
struct pipe_box *boxes = NULL;
if (nrects) {
@ -1894,8 +1892,25 @@ dri2_set_damage_region(__DRIdrawable *dPriv, unsigned int nrects, int *rects)
}
}
screen->set_damage_region(screen, resource, nrects, boxes);
FREE(boxes);
FREE(drawable->damage_rects);
drawable->damage_rects = boxes;
drawable->num_damage_rects = nrects;
/* Only apply the damage region if the BACK_LEFT texture is up-to-date. */
if (drawable->texture_stamp == drawable->dPriv->lastStamp &&
(drawable->texture_mask & (1 << ST_ATTACHMENT_BACK_LEFT))) {
struct pipe_screen *screen = drawable->screen->base.screen;
struct pipe_resource *resource;
if (drawable->stvis.samples > 1)
resource = drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT];
else
resource = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
screen->set_damage_region(screen, resource,
drawable->num_damage_rects,
drawable->damage_rects);
}
}
static __DRI2bufferDamageExtension dri2BufferDamageExtension = {

View file

@ -92,6 +92,18 @@ dri_st_framebuffer_validate(struct st_context_iface *stctx,
}
} while (lastStamp != drawable->dPriv->lastStamp);
/* Flush the pending set_damage_region request. */
struct pipe_screen *pscreen = screen->base.screen;
if (new_mask & (1 << ST_ATTACHMENT_BACK_LEFT) &&
pscreen->set_damage_region) {
struct pipe_resource *resource = textures[ST_ATTACHMENT_BACK_LEFT];
pscreen->set_damage_region(pscreen, resource,
drawable->num_damage_rects,
drawable->damage_rects);
}
if (!out)
return true;
@ -197,6 +209,7 @@ dri_destroy_buffer(__DRIdrawable * dPriv)
/* Notify the st manager that this drawable is no longer valid */
stapi->destroy_drawable(stapi, &drawable->base);
FREE(drawable->damage_rects);
FREE(drawable);
}

View file

@ -52,6 +52,9 @@ struct dri_drawable
unsigned old_w;
unsigned old_h;
struct pipe_box *damage_rects;
unsigned int num_damage_rects;
struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
struct pipe_resource *msaa_textures[ST_ATTACHMENT_COUNT];
unsigned int texture_mask, texture_stamp;