freedreno: combine fd_resource_layer_offset()/fd_resource_offset()
authorRob Clark <robdclark@gmail.com>
Tue, 18 Dec 2018 15:27:10 +0000 (10:27 -0500)
committerRob Clark <robdclark@gmail.com>
Sat, 22 Dec 2018 20:27:37 +0000 (15:27 -0500)
We really only need this logic in one place.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/freedreno_resource.c

index 06e68af3a829d7bba3d593e33436c33a2a3f68a3..482ce949595c19f6d5567d14028fa39f2112bbc4 100644 (file)
@@ -347,17 +347,6 @@ fd_blit_to_staging(struct fd_context *ctx, struct fd_transfer *trans)
        do_blit(ctx, &blit, false);
 }
 
-static unsigned
-fd_resource_layer_offset(struct fd_resource *rsc,
-                                                struct fd_resource_slice *slice,
-                                                unsigned layer)
-{
-       if (rsc->layer_first)
-               return layer * rsc->layer_size;
-       else
-               return layer * slice->size0;
-}
-
 static void fd_resource_transfer_flush_region(struct pipe_context *pctx,
                struct pipe_transfer *ptrans,
                const struct pipe_box *box)
@@ -626,10 +615,10 @@ fd_resource_transfer_map(struct pipe_context *pctx,
        }
 
        buf = fd_bo_map(rsc->bo);
-       offset = slice->offset +
+       offset =
                box->y / util_format_get_blockheight(format) * ptrans->stride +
                box->x / util_format_get_blockwidth(format) * rsc->cpp +
-               fd_resource_layer_offset(rsc, slice, box->z);
+               fd_resource_offset(rsc, level, box->z);
 
        if (usage & PIPE_TRANSFER_WRITE)
                rsc->valid = true;