freedreno: Make the slice pitch be bytes, not pixels.
[mesa.git] / src / gallium / drivers / freedreno / a2xx / fd2_resource.c
index 2c813804689b0535061605dd902e52af633c0b0a..1cd3e9da884965b96edb148bbd56cdca202af45f 100644 (file)
@@ -37,7 +37,7 @@ fd2_setup_slices(struct fd_resource *rsc)
        uint32_t depth = prsc->depth0;
 
        for (level = 0; level <= prsc->last_level; level++) {
-               struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
+               struct fdl_slice *slice = fd_resource_slice(rsc, level);
                uint32_t blocks;
 
                /* 32 * 32 block alignment */
@@ -61,13 +61,13 @@ fd2_setup_slices(struct fd_resource *rsc)
                        height = util_next_power_of_two(height);
                }
 
-               slice->pitch = width;
+               slice->pitch = util_format_get_nblocksx(format, width) * rsc->layout.cpp;
                slice->offset = size;
 
                blocks = util_format_get_nblocks(format, width, height);
 
                /* 4k aligned size */
-               slice->size0 = align(blocks * rsc->cpp, 4096);
+               slice->size0 = align(blocks * rsc->layout.cpp, 4096);
 
                size += slice->size0 * depth * prsc->array_size;
 
@@ -77,3 +77,15 @@ fd2_setup_slices(struct fd_resource *rsc)
        }
        return size;
 }
+
+unsigned
+fd2_tile_mode(const struct pipe_resource *tmpl)
+{
+       /* disable tiling for cube maps, freedreno uses a 2D array for the staging texture,
+       * (a2xx supports 2D arrays but it is not implemented)
+       */
+       if (tmpl->target == PIPE_TEXTURE_CUBE)
+               return 0;
+       /* we can enable tiling for any resource we can render to */
+       return (tmpl->bind & PIPE_BIND_RENDER_TARGET) ? 1 : 0;
+}