freedreno/a3xx: fix up logic for handling block formats
authorIlia Mirkin <imirkin@alum.mit.edu>
Sun, 16 Aug 2015 17:15:55 +0000 (13:15 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Mon, 17 Aug 2015 15:38:38 +0000 (11:38 -0400)
This only appears in cubemaps which have have packed layers, so are very
sensitive to any layout disagreement between sw and hw.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/freedreno/a3xx/fd3_format.c
src/gallium/drivers/freedreno/a3xx/fd3_texture.c
src/gallium/drivers/freedreno/freedreno_resource.c

index ec87aa979e3f1e18faa15c0986561f141d168c16..6fc639ce8f9c2fc0a49afce8bf931bae8aa777c6 100644 (file)
@@ -301,7 +301,7 @@ fd3_pipe2fetchsize(enum pipe_format format)
 {
        if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT)
                format = PIPE_FORMAT_Z32_FLOAT;
-       switch (util_format_get_blocksizebits(format)) {
+       switch (util_format_get_blocksizebits(format) / util_format_get_blockwidth(format)) {
        case 8: return TFETCH_1_BYTE;
        case 16: return TFETCH_2_BYTE;
        case 32: return TFETCH_4_BYTE;
index 3f36ebe62d15f10dbcb64a336bd31a82243ef6d7..2d6ecb2c050b5b05365993be4f1bcd070f6ae8af 100644 (file)
@@ -240,7 +240,7 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
                        A3XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl));
        /* when emitted, A3XX_TEX_CONST_2_INDX() must be OR'd in: */
        so->texconst2 =
-                       A3XX_TEX_CONST_2_PITCH(rsc->slices[lvl].pitch * rsc->cpp);
+                       A3XX_TEX_CONST_2_PITCH(util_format_get_nblocksx(cso->format, rsc->slices[lvl].pitch) * rsc->cpp);
        switch (prsc->target) {
        case PIPE_TEXTURE_1D_ARRAY:
        case PIPE_TEXTURE_2D_ARRAY:
index 800aaa84f7c4c3f068d2b1308fecc9edfe92d6a0..98de0969cab91ba982594a1a1482030f388b563d 100644 (file)
@@ -222,7 +222,7 @@ fd_resource_transfer_map(struct pipe_context *pctx,
        ptrans->level = level;
        ptrans->usage = usage;
        ptrans->box = *box;
-       ptrans->stride = slice->pitch * rsc->cpp;
+       ptrans->stride = util_format_get_nblocksx(format, slice->pitch) * rsc->cpp;
        ptrans->layer_stride = slice->size0;
 
        if (usage & PIPE_TRANSFER_READ)
@@ -375,9 +375,11 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment)
 
        for (level = 0; level <= prsc->last_level; level++) {
                struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
+               uint32_t blocks;
 
                slice->pitch = width = align(width, 32);
                slice->offset = size;
+               blocks = util_format_get_nblocks(prsc->format, width, 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
@@ -387,9 +389,9 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment)
                if (prsc->target == PIPE_TEXTURE_3D && (
                                        level == 1 ||
                                        (level > 1 && rsc->slices[level - 1].size0 > 0xf000)))
-                       slice->size0 = align(slice->pitch * height * rsc->cpp, alignment);
+                       slice->size0 = align(blocks * rsc->cpp, alignment);
                else if (level == 0 || rsc->layer_first || alignment == 1)
-                       slice->size0 = align(slice->pitch * height * rsc->cpp, alignment);
+                       slice->size0 = align(blocks * rsc->cpp, alignment);
                else
                        slice->size0 = rsc->slices[level - 1].size0;