[Mesa-dev] [PATCH] drisw: fix image stride calculation for 16-bit.
Brian Paul
brianp at vmware.com
Thu Mar 22 06:49:25 PDT 2012
On 03/22/2012 05:56 AM, Dave Airlie wrote:
> If you ran g-s in 16-bpp we'd do a bunch of memory corruption.
>
> now it just misrenders for some other reasons.
>
> applies to stable.
>
> Signed-off-by: Dave Airlie<airlied at redhat.com>
> ---
> src/gallium/state_trackers/dri/sw/drisw.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c
> index f5d1555..91ba3df 100644
> --- a/src/gallium/state_trackers/dri/sw/drisw.c
> +++ b/src/gallium/state_trackers/dri/sw/drisw.c
> @@ -253,6 +253,7 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
> char *map;
> int x, y, w, h;
> int ximage_stride, line;
> + int cpp = util_format_get_blocksize(res->format);
>
> get_drawable_info(dPriv,&x,&y,&w,&h);
>
> @@ -267,7 +268,7 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
>
> /* The pipe transfer has a pitch rounded up to the nearest 64 pixels.
> We assume 32 bit pixels. */
Looks like that comment about 32-bit pixels is no longer needed.
> - ximage_stride = w * 4;
> + ximage_stride = w * cpp;
> for (line = h-1; line; --line) {
> memmove(&map[line * transfer->stride],
> &map[line * ximage_stride],
Otherwise, LGTM.
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the mesa-dev
mailing list