panfrost: Respect box->width in tiled stores
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Wed, 3 Apr 2019 03:36:38 +0000 (03:36 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 4 Apr 2019 03:51:43 +0000 (03:51 +0000)
This fixes a regression uploading partial tiled textures introduced
sometime during the cubemap series.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/pan_resource.c
src/gallium/drivers/panfrost/pan_swizzle.c
src/gallium/drivers/panfrost/pan_swizzle.h

index f7df1353d68785439c16d7053798e566d104b757..217b27c5778b99c74b7c8ea9a9f1a1025f0935b5 100644 (file)
@@ -414,7 +414,8 @@ panfrost_transfer_map(struct pipe_context *pctx,
                         return NULL;
 
                 /* TODO: Reads */
-                transfer->map = malloc(ALIGN(box->width, 16) * ALIGN(box->height, 16) * bytes_per_pixel);
+                /* TODO: Only allocate "just" enough, shortening the stride */
+                transfer->map = malloc(transfer->base.stride * box->height);
 
                 return transfer->map;
         } else {
@@ -440,6 +441,7 @@ panfrost_tile_texture(struct panfrost_screen *screen, struct panfrost_resource *
                         trans->base.box.height,
                         util_format_get_blocksize(rsrc->base.format),
                         bo->slices[level].stride,
+                        u_minify(rsrc->base.width0, level),
                         trans->map,
                         bo->cpu
                                 + bo->slices[level].offset
index 578de6554157c634f83c41bb9c570b3095637bfd..afc89506b336800cdb82e2cc9a81cbb660a97309 100644 (file)
@@ -149,12 +149,12 @@ swizzle_bpp4_align16(int width, int height, int source_stride, int block_pitch,
 void
 panfrost_texture_swizzle(unsigned off_x,
                          unsigned off_y,
-                         int width, int height, int bytes_per_pixel, int source_stride,
+                         int width, int height, int bytes_per_pixel, int source_stride, int dest_width,
                          const uint8_t *pixels,
                          uint8_t *ldest)
 {
         /* Calculate maximum size, overestimating a bit */
-        int block_pitch = ALIGN(width, 16) >> 4;
+        int block_pitch = ALIGN(dest_width, 16) >> 4;
 
         /* Use fast path if available */
         if (!(off_x || off_y)) {
index a4d603a0aadb37c46c8921f3d393b9bbab8c32eb..6f4dadef494cd617b8b61bc67488f267b39c51e4 100644 (file)
@@ -32,7 +32,7 @@ panfrost_generate_space_filler_indices(void);
 
 void
 panfrost_texture_swizzle(unsigned off_x, unsigned off_y,
-                        int width, int height, int bytes_per_pixel, int source_stride,
+                        int width, int height, int bytes_per_pixel, int source_stride, int dest_width,
                          const uint8_t *pixels,
                          uint8_t *ldest);