gallium/radeon: don't call u_format helpers if we have that info already
authorMarek Olšák <marek.olsak@amd.com>
Wed, 26 Oct 2016 16:12:07 +0000 (18:12 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 1 Nov 2016 21:33:13 +0000 (22:33 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeon/r600_texture.c
src/gallium/drivers/radeonsi/si_blit.c

index 46281cbd0e5347b11a991e82f5ddb3c1d670266b..364ed4078cd6728c2c3ef01d3e95e26328914639 100644 (file)
@@ -53,8 +53,7 @@ bool r600_prepare_for_dma_blit(struct r600_common_context *rctx,
        if (!rctx->dma.cs)
                return false;
 
-       if (util_format_get_blocksizebits(rdst->resource.b.b.format) !=
-           util_format_get_blocksizebits(rsrc->resource.b.b.format))
+       if (rdst->surface.bpe != rsrc->surface.bpe)
                return false;
 
        /* MSAA: Blits don't exist in the real world. */
@@ -181,12 +180,10 @@ static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct r600
 static unsigned r600_texture_get_offset(struct r600_texture *rtex, unsigned level,
                                        const struct pipe_box *box)
 {
-       enum pipe_format format = rtex->resource.b.b.format;
-
        return rtex->surface.level[level].offset +
               box->z * rtex->surface.level[level].slice_size +
-              box->y / util_format_get_blockheight(format) * rtex->surface.level[level].pitch_bytes +
-              box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+              box->y / rtex->surface.blk_h * rtex->surface.level[level].pitch_bytes +
+              box->x / rtex->surface.blk_w * rtex->surface.bpe;
 }
 
 static int r600_init_surface(struct r600_common_screen *rscreen,
@@ -2195,7 +2192,7 @@ static void evergreen_set_clear_color(struct r600_texture *rtex,
 
        memset(&uc, 0, sizeof(uc));
 
-       if (util_format_get_blocksizebits(surface_format) == 128) {
+       if (rtex->surface.bpe == 16) {
                /* DCC fast clear only:
                 *   CLEAR_WORD0 = R = G = B
                 *   CLEAR_WORD1 = A
@@ -2502,7 +2499,7 @@ void evergreen_do_fast_color_clear(struct r600_common_context *rctx,
                        tex->separate_dcc_dirty = true;
                } else {
                        /* 128-bit formats are unusupported */
-                       if (util_format_get_blocksizebits(fb->cbufs[i]->format) > 64) {
+                       if (tex->surface.bpe > 8) {
                                continue;
                        }
 
index 0f46d71ddafff994ee30faa853c2a592ef5f462f..fe17f7392424de904e4f7ffee2e40e827267ddf5 100644 (file)
@@ -838,6 +838,7 @@ void si_resource_copy_region(struct pipe_context *ctx,
                             const struct pipe_box *src_box)
 {
        struct si_context *sctx = (struct si_context *)ctx;
+       struct r600_texture *rsrc = (struct r600_texture*)src;
        struct pipe_surface *dst_view, dst_templ;
        struct pipe_sampler_view src_templ, *src_view;
        unsigned dst_width, dst_height, src_width0, src_height0;
@@ -867,7 +868,7 @@ void si_resource_copy_region(struct pipe_context *ctx,
 
        if (util_format_is_compressed(src->format) ||
            util_format_is_compressed(dst->format)) {
-               unsigned blocksize = util_format_get_blocksize(src->format);
+               unsigned blocksize = rsrc->surface.bpe;
 
                if (blocksize == 8)
                        src_templ.format = PIPE_FORMAT_R16G16B16A16_UINT; /* 64-bit block */
@@ -909,7 +910,7 @@ void si_resource_copy_region(struct pipe_context *ctx,
                        sbox.width = util_format_get_nblocksx(src->format, src_box->width);
                        src_box = &sbox;
                } else {
-                       unsigned blocksize = util_format_get_blocksize(src->format);
+                       unsigned blocksize = rsrc->surface.bpe;
 
                        switch (blocksize) {
                        case 1: