[PATCH 4/5] glamor: Add in support for the stride parameter when uploading texture data
Eric Anholt
eric at anholt.net
Wed Apr 23 10:45:33 PDT 2014
Michel Dänzer <michel at daenzer.net> writes:
> From: Anthony Waters <awaters1 at gmail.com>
>
> The method __glamor_upload_pixmap_to_texture was updated to support a
> stride parameter for the data being uploaded to a texture. This
> required correctly setting the alignment from 4 to a value based on the
> depth of the data and also required setting GL_UNPACK_ROW_LENGTH based
> on both the stride and the alignment.
>
> The stride parameter was also updated in glamor_put_image to be
> correctly specified, the old values would cause the xserver to crash.
> [ Michel Dänzer: squashed in follow-up fix for the stride ]
>
> Part of bug: https://bugs.freedesktop.org/show_bug.cgi?id=71813
>
> Signed-off-by: Anthony Waters <awaters1 at gmail.com>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
> glamor/glamor_pixmap.c | 38 +++++++++++++++++++++++++++++++++-----
> glamor/glamor_putimage.c | 6 ++++--
> 2 files changed, 37 insertions(+), 7 deletions(-)
>
> diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
> index 54b414b..8846741 100644
> --- a/glamor/glamor_pixmap.c
> +++ b/glamor/glamor_pixmap.c
> @@ -697,13 +697,38 @@ static void
> __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
> GLenum format,
> GLenum type,
> - int x, int y, int w, int h,
> + int x, int y, int w, int h, int stride,
> void *bits, int pbo)
> {
> glamor_screen_private *glamor_priv =
> glamor_get_screen_private(pixmap->drawable.pScreen);
> int non_sub = 0;
> unsigned int iformat = 0;
> + int bpp, alignment;
> +
> + switch (type) {
> + case GL_UNSIGNED_BYTE:
> + bpp = 8;
> + break;
> + case GL_UNSIGNED_INT_8_8_8_8:
> + case GL_UNSIGNED_INT_8_8_8_8_REV:
> + case GL_UNSIGNED_INT_2_10_10_10_REV:
> + bpp = 32;
> + break;
> + case GL_UNSIGNED_SHORT_5_6_5:
> + case GL_UNSIGNED_SHORT_5_6_5_REV:
> + case GL_UNSIGNED_SHORT_1_5_5_5_REV:
> + case GL_UNSIGNED_SHORT_4_4_4_4_REV:
> + bpp = 16;
> + break;
> + default:
> + bpp = 0;
> + }
> + alignment = bpp / 8;
Why do we need this switch statement? Isn't the type/format always the
same bits per pixel as pixmap->drawable.bitsPerPixel?
> + if (stride == 0) {
> + alignment = 4;
> + }
I'd much rather see an explicit stride in the callers.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140423/45705aea/attachment.sig>
More information about the xorg-devel
mailing list