[Glamor] [PATCH 2/2] Use CLAMP_TO_BORDER in copy_n_to_n so we can sample outside of the source

Zhigang Gong zhigang.gong at linux.intel.com
Sun Jan 29 01:09:26 PST 2012



> -----Original Message-----
> From:
> glamor-bounces+zhigang.gong=linux.intel.com at lists.freedesktop.org
> [mailto:glamor-bounces+zhigang.gong=linux.intel.com at lists.freedesktop.o
> rg] On Behalf Of Chris Wilson
> Sent: Friday, January 27, 2012 9:22 PM
> To: glamor at lists.freedesktop.org
> Cc: Chris Wilson
> Subject: [Glamor] [PATCH 2/2] Use CLAMP_TO_BORDER in copy_n_to_n so
> we can sample outside of the source
> 
> In order to reduce a composite operation to a source, we need to provide
> Render semantics for the pixel values of samples outside of the source
> pixmap, i.e. they need to be rgba(0, 0, 0, 0). This is provided by using
the
> CLAMP_TO_BORDER repeat mode, but only if the texture has an alpha
> channel.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  src/glamor_copyarea.c |    6 ++++++
>  src/glamor_render.c   |   28 +++++++++++++++-------------
>  2 files changed, 21 insertions(+), 13 deletions(-)
> 
> diff --git a/src/glamor_copyarea.c b/src/glamor_copyarea.c index
> a39c970..f2d710a 100644
> --- a/src/glamor_copyarea.c
> +++ b/src/glamor_copyarea.c
> @@ -226,6 +226,12 @@ glamor_copy_n_to_n_textured(DrawablePtr
> src,
>  		dispatch->glTexParameteri(GL_TEXTURE_2D,
>  					  GL_TEXTURE_MAG_FILTER,
>  					  GL_NEAREST);
> +		dispatch->glTexParameteri(GL_TEXTURE_2D,
> +					  GL_TEXTURE_WRAP_S,
> +					  GL_CLAMP_TO_BORDER);
> +		dispatch->glTexParameteri(GL_TEXTURE_2D,
> +					  GL_TEXTURE_WRAP_T,
> +					  GL_CLAMP_TO_BORDER);
> 
>  		dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
>  						GL_FLOAT, GL_FALSE,
> diff --git a/src/glamor_render.c b/src/glamor_render.c index
> b70ace2..04eb0b2 100644
> --- a/src/glamor_render.c
> +++ b/src/glamor_render.c
> @@ -622,19 +622,21 @@ glamor_composite_with_copy(CARD8 op,
>  				      x_source, y_source,
>  				      0, 0, x_dest, y_dest, width, height))
>  		return TRUE;
> -	/* Fallback if we sample outside the source so that we swizzle the
> -	 * clear color appropriately. If the source has an alpha channel,
> -	 * we could rely on CLAMP_TO_BORDER working as required...
> -	 */
> -	if (region.extents.x1 + x_source - x_dest < 0)
> -		goto cleanup_region;
> -	if (region.extents.x2 + x_source - x_dest >
> source->pDrawable->width)
> -		goto cleanup_region;
> -
> -	if (region.extents.y1 + y_source - y_dest < 0)
> -		goto cleanup_region;
> -	if (region.extents.y2 + y_source - y_dest >
> source->pDrawable->height)
> -		goto cleanup_region;
> +
> +	if (PICT_FORMAT_A(source->format) == 0) {
> +		/* Fallback if we sample outside the source so that we
> +		 * swizzle the correct clear color for out-of-bounds texels.
> +		 */
> +		if (region.extents.x1 + x_source - x_dest < 0)
> +			goto cleanup_region;
> +		if (region.extents.x2 + x_source - x_dest >
> source->pDrawable->width)
> +			goto cleanup_region;
> +
> +		if (region.extents.y1 + y_source - y_dest < 0)
> +			goto cleanup_region;
> +		if (region.extents.y2 + y_source - y_dest >
> source->pDrawable->height)
> +			goto cleanup_region;
> +	}
> 
>  	ret = glamor_copy_n_to_n_nf(source->pDrawable,
>  				    dest->pDrawable, NULL,
> --
> 1.7.8.3
> 
Reviewed-by: Zhigang Gong <zhigang.gong at linux.intel.com>

Applied, thanks.
> _______________________________________________
> Glamor mailing list
> Glamor at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/glamor



More information about the Glamor mailing list