freedreno/layout: layout simplifications and pitch from level 0 pitch
[mesa.git] / src / gallium / drivers / freedreno / a4xx / fd4_resource.c
index 1640a1acb959c587c553a3dcdacf8bfe5fc3bc5b..57cd0d5cefbf90bb29cbeb5a73a3e0e722842435 100644 (file)
@@ -32,7 +32,6 @@ fd4_setup_slices(struct fd_resource *rsc)
 {
        struct pipe_resource *prsc = &rsc->base;
        enum pipe_format format = prsc->format;
-       enum util_format_layout layout = util_format_description(format)->layout;
        uint32_t level, size = 0;
        uint32_t width = prsc->width0;
        uint32_t height = prsc->height0;
@@ -52,17 +51,16 @@ fd4_setup_slices(struct fd_resource *rsc)
                alignment = 1;
        }
 
+       /* 32 pixel alignment */
+       fdl_set_pitchalign(&rsc->layout, fdl_cpp_shift(&rsc->layout) + 5);
+
        for (level = 0; level <= prsc->last_level; level++) {
                struct fdl_slice *slice = fd_resource_slice(rsc, level);
-               uint32_t blocks;
+               uint32_t pitch = fdl_pitch(&rsc->layout, level);
+               uint32_t nblocksy = util_format_get_nblocksy(format, height);
 
-               if (layout == UTIL_FORMAT_LAYOUT_ASTC)
-                       width = util_align_npot(width, 32 * util_format_get_blockwidth(format));
-               else
-                       width = align(width, 32);
-               slice->pitch = util_format_get_nblocksx(format, width) * rsc->layout.cpp;
                slice->offset = size;
-               blocks = util_format_get_nblocks(format, width, height);
+
                /* 3d textures can have different layer sizes for high levels, but the
                 * hw auto-sizer is buggy (or at least different than what this code
                 * does), so as soon as the layer size range gets into range, we stop
@@ -72,7 +70,7 @@ fd4_setup_slices(struct fd_resource *rsc)
                        (level > 1 && fd_resource_slice(rsc, level - 1)->size0 <= 0xf000))
                        slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
                else
-                       slice->size0 = align(blocks * rsc->layout.cpp, alignment);
+                       slice->size0 = align(nblocksy * pitch, alignment);
 
                size += slice->size0 * depth * layers_in_level;