freedreno: constify fd_vsc_pipe
[mesa.git] / src / gallium / drivers / freedreno / a3xx / fd3_resource.c
index f6b52bd30a100bc1154349afbb41b1b5f6d18b09..6089ca01e40ede9afd2b637e588708feda2c44c6 100644 (file)
@@ -37,20 +37,34 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
        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;
 
-               if (rsc->tile_mode) {
-                       width = util_next_power_of_two(width);
-                       height = util_next_power_of_two(height);
-                       uint32_t tpitch = width * rsc->cpp;
-                       slice->pitch = (tpitch > 32) ? tpitch : 32;
+               if (rsc->layout.tile_mode) {
+                       if (prsc->target != PIPE_TEXTURE_CUBE) {
+                               if (level == 0) {
+                                       width = util_next_power_of_two(width);
+                                       height = util_next_power_of_two(height);
+                               }
+                               width = MAX2(width, 8);
+                               height = MAX2(height, 4);
+                               // Multiplying by 4 is the result of the 4x4 tiling pattern.
+                               slice->pitch = width * 4;
+                               blocks = util_format_get_nblocks(format, width, height);
+                       } else {
+                               uint32_t twidth, theight;
+                               twidth = align(width, 8);
+                               theight = align(height, 4);
+                               // Multiplying by 4 is the result of the 4x4 tiling pattern.
+                               slice->pitch = twidth * 4;
+                               blocks = util_format_get_nblocks(format, twidth, theight);
+                       }
                } else {
                        slice->pitch = width = align(width, pitchalign);
+                       blocks = util_format_get_nblocks(format, slice->pitch, height);
                }
 
                slice->offset = size;
-               blocks = util_format_get_nblocks(format, slice->pitch, height);
                /* 1d array and 2d array textures must all have the same layer size
                 * for each miplevel on a3xx. 3d textures can have different layer
                 * sizes for high levels, but the hw auto-sizer is buggy (or at least
@@ -59,12 +73,12 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
                 */
                if (prsc->target == PIPE_TEXTURE_3D && (
                                        level == 1 ||
-                                       (level > 1 && rsc->slices[level - 1].size0 > 0xf000)))
-                       slice->size0 = align(blocks * rsc->cpp, alignment);
+                                       (level > 1 && fd_resource_slice(rsc, level - 1)->size0 > 0xf000)))
+                       slice->size0 = align(blocks * rsc->layout.cpp, alignment);
                else if (level == 0 || alignment == 1)
-                       slice->size0 = align(blocks * rsc->cpp, alignment);
+                       slice->size0 = align(blocks * rsc->layout.cpp, alignment);
                else
-                       slice->size0 = rsc->slices[level - 1].size0;
+                       slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
 
                size += slice->size0 * depth * prsc->array_size;