sna/gen2: Check reused source for validity
Be sure the mask picture has a valid format even though it points to the same pixels as the valid source. And also be wary if the source was converted to a solid, but the mask is not. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
1d55b42fbd
commit
007da2f978
|
|
@ -198,6 +198,24 @@ gen2_get_card_format(struct sna *sna, uint32_t format)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
gen2_check_format(struct sna *sna, PicturePtr p)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(i8xx_tex_formats); i++)
|
||||
if (i8xx_tex_formats[i].fmt == p->format)
|
||||
return true;
|
||||
|
||||
if (sna->kgem.gen > 21) {
|
||||
for (i = 0; i < ARRAY_SIZE(i85x_tex_formats); i++)
|
||||
if (i85x_tex_formats[i].fmt == p->format)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
gen2_sampler_tiling_bits(uint32_t tiling)
|
||||
{
|
||||
|
|
@ -1578,14 +1596,29 @@ reuse_source(struct sna *sna,
|
|||
PicturePtr src, struct sna_composite_channel *sc, int src_x, int src_y,
|
||||
PicturePtr mask, struct sna_composite_channel *mc, int msk_x, int msk_y)
|
||||
{
|
||||
uint32_t color;
|
||||
|
||||
if (src_x != msk_x || src_y != msk_y)
|
||||
return FALSE;
|
||||
|
||||
if (src == mask) {
|
||||
DBG(("%s: mask is source\n", __FUNCTION__));
|
||||
*mc = *sc;
|
||||
mc->bo = kgem_bo_reference(mc->bo);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (sna_picture_is_solid(mask, &color))
|
||||
return gen2_composite_solid_init(sna, mc, color);
|
||||
|
||||
if (sc->is_solid)
|
||||
return FALSE;
|
||||
|
||||
if (src->pDrawable == NULL || mask->pDrawable != src->pDrawable)
|
||||
return FALSE;
|
||||
|
||||
DBG(("%s: mask reuses source drawable\n", __FUNCTION__));
|
||||
|
||||
if (src_x != msk_x || src_y != msk_y)
|
||||
return FALSE;
|
||||
|
||||
if (!sna_transform_equal(src->transform, mask->transform))
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -1598,6 +1631,9 @@ reuse_source(struct sna *sna,
|
|||
if (!gen2_check_filter(mask))
|
||||
return FALSE;
|
||||
|
||||
if (!gen2_check_format(sna, mask))
|
||||
return FALSE;
|
||||
|
||||
DBG(("%s: reusing source channel for mask with a twist\n",
|
||||
__FUNCTION__));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue