gallium/util: add util_texrange_covers_whole_level from radeon
authorMarek Olšák <marek.olsak@amd.com>
Mon, 9 May 2016 11:36:39 +0000 (13:36 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 1 Jun 2016 15:35:30 +0000 (17:35 +0200)
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/gallium/auxiliary/util/u_inlines.h
src/gallium/drivers/radeon/r600_texture.c

index a38223ca33c437994dff6b8449e8a15a6a285b35..90821b29de20f7027a405cb319aaf2d8791e51a2 100644 (file)
@@ -650,6 +650,18 @@ util_max_layer(const struct pipe_resource *r, unsigned level)
    }
 }
 
+static inline bool
+util_texrange_covers_whole_level(const struct pipe_resource *tex,
+                                 unsigned level, unsigned x, unsigned y,
+                                 unsigned z, unsigned width,
+                                 unsigned height, unsigned depth)
+{
+   return x == 0 && y == 0 && z == 0 &&
+          width == u_minify(tex->width0, level) &&
+          height == u_minify(tex->height0, level) &&
+          depth == util_max_layer(tex, level) + 1;
+}
+
 #ifdef __cplusplus
 }
 #endif
index e2955aa89562ac31c05495b48a3b310d69301a5d..db63bebc676ae0e7e8ea18fd6313ce1e34262619 100644 (file)
@@ -38,17 +38,6 @@ static void r600_texture_discard_cmask(struct r600_common_screen *rscreen,
                                       struct r600_texture *rtex);
 
 
-static bool range_covers_whole_texture(struct pipe_resource *tex,
-                                      unsigned level, unsigned x, unsigned y,
-                                      unsigned z, unsigned width,
-                                      unsigned height, unsigned depth)
-{
-       return x == 0 && y == 0 && z == 0 &&
-              width == u_minify(tex->width0, level) &&
-              height == u_minify(tex->height0, level) &&
-              depth == util_max_layer(tex, level) + 1;
-}
-
 bool r600_prepare_for_dma_blit(struct r600_common_context *rctx,
                               struct r600_texture *rdst,
                               unsigned dst_level, unsigned dstx,
@@ -87,9 +76,9 @@ bool r600_prepare_for_dma_blit(struct r600_common_context *rctx,
        if (rdst->dcc_offset) {
                /* We can't discard DCC if the texture has been exported. */
                if (rdst->resource.is_shared ||
-                   !range_covers_whole_texture(&rdst->resource.b.b, dst_level,
-                                               dstx, dsty, dstz, src_box->width,
-                                               src_box->height, src_box->depth))
+                   !util_texrange_covers_whole_level(&rdst->resource.b.b, dst_level,
+                                                     dstx, dsty, dstz, src_box->width,
+                                                     src_box->height, src_box->depth))
                        return false;
 
                r600_texture_discard_dcc(rctx->screen, rdst);
@@ -101,9 +90,9 @@ bool r600_prepare_for_dma_blit(struct r600_common_context *rctx,
         *        SDMA. Otherwise, use the 3D path.
         */
        if (rdst->cmask.size && rdst->dirty_level_mask & (1 << dst_level)) {
-               if (!range_covers_whole_texture(&rdst->resource.b.b, dst_level,
-                                               dstx, dsty, dstz, src_box->width,
-                                               src_box->height, src_box->depth))
+               if (!util_texrange_covers_whole_level(&rdst->resource.b.b, dst_level,
+                                                     dstx, dsty, dstz, src_box->width,
+                                                     src_box->height, src_box->depth))
                        return false;
 
                r600_texture_discard_cmask(rctx->screen, rdst);