gallium: fix clipping/stride bugs in pipe_get_tile_raw(), pipe_put_tile_raw()
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 7 Aug 2008 01:15:10 +0000 (19:15 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 7 Aug 2008 01:15:10 +0000 (19:15 -0600)
We need to compute the default dst_stride and src_stride _before_ clipping.
After clipping, the width value may have changed.
This fixes visible tile glitches in some demos like progs/glsl/texdemo.c

src/gallium/auxiliary/util/p_tile.c

index 2b6db43..d65e603 100644 (file)
@@ -51,12 +51,12 @@ pipe_get_tile_raw(struct pipe_surface *ps,
 {
    const void *src;
 
-   if (pipe_clip_tile(x, y, &w, &h, ps))
-      return;
-
    if (dst_stride == 0)
       dst_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size;
 
+   if (pipe_clip_tile(x, y, &w, &h, ps))
+      return;
+
    src = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_READ);
    assert(src);
    if(!src)
@@ -79,12 +79,12 @@ pipe_put_tile_raw(struct pipe_surface *ps,
 {
    void *dst;
 
-   if (pipe_clip_tile(x, y, &w, &h, ps))
-      return;
-
    if (src_stride == 0)
       src_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size;
 
+   if (pipe_clip_tile(x, y, &w, &h, ps))
+      return;
+
    dst = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_WRITE);
    assert(dst);
    if(!dst)