gallium/util: add helper util_max_layer from r600g
authorMarek Olšák <maraeo@gmail.com>
Wed, 2 Jan 2013 19:40:24 +0000 (20:40 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 26 Feb 2013 00:14:05 +0000 (01:14 +0100)
src/gallium/auxiliary/util/u_inlines.h
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/radeonsi/r600_blit.c
src/gallium/drivers/radeonsi/r600_texture.c
src/gallium/drivers/radeonsi/radeonsi_pipe.h

index 2ff90c982d87a786ed028aef36d30409bc0741ca..ba745ebb5fb6ca370119824954149a425ceee071 100644 (file)
@@ -582,6 +582,22 @@ util_copy_constant_buffer(struct pipe_constant_buffer *dst,
    }
 }
 
+static INLINE unsigned
+util_max_layer(struct pipe_resource *r, unsigned level)
+{
+   switch (r->target) {
+   case PIPE_TEXTURE_CUBE:
+      return 6 - 1;
+   case PIPE_TEXTURE_3D:
+      return u_minify(r->depth0, level) - 1;
+   case PIPE_TEXTURE_1D_ARRAY:
+   case PIPE_TEXTURE_2D_ARRAY:
+   case PIPE_TEXTURE_CUBE_ARRAY:
+      return r->array_size - 1;
+   default:
+      return 0;
+   }
+}
 
 #ifdef __cplusplus
 }
index 046eab54c42359f4f4108188fcabcef7423c392c..3e0d89c06f00731d39660b19d6a08242f2d42b1a 100644 (file)
@@ -150,7 +150,7 @@ void r600_blit_decompress_depth(struct pipe_context *ctx,
 
                /* The smaller the mipmap level, the less layers there are
                 * as far as 3D textures are concerned. */
-               max_layer = u_max_layer(&texture->resource.b.b, level);
+               max_layer = util_max_layer(&texture->resource.b.b, level);
                checked_last_layer = last_layer < max_layer ? last_layer : max_layer;
 
                for (layer = first_layer; layer <= checked_last_layer; layer++) {
@@ -222,7 +222,7 @@ static void r600_blit_decompress_depth_in_place(struct r600_context *rctx,
 
                /* The smaller the mipmap level, the less layers there are
                 * as far as 3D textures are concerned. */
-               max_layer = u_max_layer(&texture->resource.b.b, level);
+               max_layer = util_max_layer(&texture->resource.b.b, level);
                checked_last_layer = last_layer < max_layer ? last_layer : max_layer;
 
                for (layer = first_layer; layer <= checked_last_layer; layer++) {
@@ -273,11 +273,11 @@ void r600_decompress_depth_textures(struct r600_context *rctx,
                    r600_can_read_depth(tex)) {
                        r600_blit_decompress_depth_in_place(rctx, tex,
                                                   view->u.tex.first_level, view->u.tex.last_level,
-                                                  0, u_max_layer(&tex->resource.b.b, view->u.tex.first_level));
+                                                  0, util_max_layer(&tex->resource.b.b, view->u.tex.first_level));
                } else {
                        r600_blit_decompress_depth(&rctx->context, tex, NULL,
                                                   view->u.tex.first_level, view->u.tex.last_level,
-                                                  0, u_max_layer(&tex->resource.b.b, view->u.tex.first_level),
+                                                  0, util_max_layer(&tex->resource.b.b, view->u.tex.first_level),
                                                   0, u_max_sample(&tex->resource.b.b));
                }
        }
@@ -319,7 +319,7 @@ static void r600_blit_decompress_color(struct pipe_context *ctx,
 
                /* The smaller the mipmap level, the less layers there are
                 * as far as 3D textures are concerned. */
-               max_layer = u_max_layer(&rtex->resource.b.b, level);
+               max_layer = util_max_layer(&rtex->resource.b.b, level);
                checked_last_layer = last_layer < max_layer ? last_layer : max_layer;
 
                for (layer = first_layer; layer <= checked_last_layer; layer++) {
@@ -366,7 +366,7 @@ void r600_decompress_color_textures(struct r600_context *rctx,
 
                r600_blit_decompress_color(&rctx->context, tex,
                                           view->u.tex.first_level, view->u.tex.last_level,
-                                          0, u_max_layer(&tex->resource.b.b, view->u.tex.first_level));
+                                          0, util_max_layer(&tex->resource.b.b, view->u.tex.first_level));
        }
 }
 
index de9c205cf7bdfbfa14d97b9d2d1ac5c3b6059004..88b587e50a7f05d3982d1d00e9aa10d9de6b216e 100644 (file)
@@ -988,22 +988,6 @@ static INLINE uint64_t r600_resource_va(struct pipe_screen *screen, struct pipe_
        return rscreen->ws->buffer_get_virtual_address(rresource->cs_buf);
 }
 
-static INLINE unsigned u_max_layer(struct pipe_resource *r, unsigned level)
-{
-       switch (r->target) {
-       case PIPE_TEXTURE_CUBE:
-               return 6 - 1;
-       case PIPE_TEXTURE_3D:
-               return u_minify(r->depth0, level) - 1;
-       case PIPE_TEXTURE_1D_ARRAY:
-       case PIPE_TEXTURE_2D_ARRAY:
-       case PIPE_TEXTURE_CUBE_ARRAY:
-               return r->array_size - 1;
-       default:
-               return 0;
-       }
-}
-
 static INLINE void r600_context_add_resource_size(struct pipe_context *ctx, struct pipe_resource *r)
 {
        struct r600_context *rctx = (struct r600_context *)ctx;
index 7f5752d81e6c401d719fd264d1f86f06fb319f57..acea19d77443ca1da0040a4a941b66bc2ac91fb8 100644 (file)
@@ -609,8 +609,8 @@ struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
 {
        struct r600_surface *surface = CALLOC_STRUCT(r600_surface);
 
-        assert(templ->u.tex.first_layer <= u_max_layer(texture, templ->u.tex.level));
-        assert(templ->u.tex.last_layer <= u_max_layer(texture, templ->u.tex.level));
+        assert(templ->u.tex.first_layer <= util_max_layer(texture, templ->u.tex.level));
+        assert(templ->u.tex.last_layer <= util_max_layer(texture, templ->u.tex.level));
        assert(templ->u.tex.first_layer == templ->u.tex.last_layer);
        if (surface == NULL)
                return NULL;
@@ -821,7 +821,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
                resource.flags = R600_RESOURCE_FLAG_TRANSFER;
 
                /* We must set the correct texture target and dimensions if needed for a 3D transfer. */
-               if (box->depth > 1 && u_max_layer(texture, level) > 0)
+               if (box->depth > 1 && util_max_layer(texture, level) > 0)
                        resource.target = texture->target;
                else
                        resource.target = PIPE_TEXTURE_2D;
index 0b0eba3c79400c44a45a32ae9fa69978a5d2e81c..eb69cd54ee0ac2049c4ad1b1b332efc2a0e61434 100644 (file)
@@ -136,7 +136,7 @@ void si_blit_uncompress_depth(struct pipe_context *ctx,
 
                /* The smaller the mipmap level, the less layers there are
                 * as far as 3D textures are concerned. */
-               max_layer = u_max_layer(&texture->resource.b.b, level);
+               max_layer = util_max_layer(&texture->resource.b.b, level);
                checked_last_layer = last_layer < max_layer ? last_layer : max_layer;
 
                for (layer = first_layer; layer <= checked_last_layer; layer++) {
@@ -187,7 +187,7 @@ static void si_blit_decompress_depth_in_place(struct r600_context *rctx,
 
                /* The smaller the mipmap level, the less layers there are
                 * as far as 3D textures are concerned. */
-               max_layer = u_max_layer(&texture->resource.b.b, level);
+               max_layer = util_max_layer(&texture->resource.b.b, level);
                checked_last_layer = last_layer < max_layer ? last_layer : max_layer;
 
                for (layer = first_layer; layer <= checked_last_layer; layer++) {
@@ -231,7 +231,7 @@ void si_flush_depth_textures(struct r600_context *rctx,
 
                si_blit_decompress_depth_in_place(rctx, tex,
                                                  view->u.tex.first_level, view->u.tex.last_level,
-                                                 0, u_max_layer(&tex->resource.b.b, view->u.tex.first_level));
+                                                 0, util_max_layer(&tex->resource.b.b, view->u.tex.first_level));
        }
 }
 
index 153df00639f994dab111fdcabfa6c1dd54cac76c..1b8382fd308f6785309a638b1aabc66455ed51c5 100644 (file)
@@ -312,7 +312,7 @@ static void *si_texture_transfer_map(struct pipe_context *ctx,
                resource.flags = R600_RESOURCE_FLAG_TRANSFER;
 
                /* We must set the correct texture target and dimensions if needed for a 3D transfer. */
-               if (box->depth > 1 && u_max_layer(texture, level) > 0)
+               if (box->depth > 1 && util_max_layer(texture, level) > 0)
                        resource.target = texture->target;
                else
                        resource.target = PIPE_TEXTURE_2D;
@@ -554,8 +554,8 @@ static struct pipe_surface *r600_create_surface(struct pipe_context *pipe,
        struct r600_surface *surface = CALLOC_STRUCT(r600_surface);
        unsigned level = surf_tmpl->u.tex.level;
 
-       assert(surf_tmpl->u.tex.first_layer <= u_max_layer(texture, surf_tmpl->u.tex.level));
-       assert(surf_tmpl->u.tex.last_layer <= u_max_layer(texture, surf_tmpl->u.tex.level));
+       assert(surf_tmpl->u.tex.first_layer <= util_max_layer(texture, surf_tmpl->u.tex.level));
+       assert(surf_tmpl->u.tex.last_layer <= util_max_layer(texture, surf_tmpl->u.tex.level));
        assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
        if (surface == NULL)
                return NULL;
index 8c6d9081266c2cd1575c9acb1fe47810ed64a80d..d0f04f405626646bba823b316b6db1d96d5973c9 100644 (file)
@@ -277,20 +277,4 @@ static INLINE uint64_t r600_resource_va(struct pipe_screen *screen, struct pipe_
        return rscreen->ws->buffer_get_virtual_address(rresource->cs_buf);
 }
 
-static INLINE unsigned u_max_layer(struct pipe_resource *r, unsigned level)
-{
-       switch (r->target) {
-       case PIPE_TEXTURE_CUBE:
-               return 6 - 1;
-       case PIPE_TEXTURE_3D:
-               return u_minify(r->depth0, level) - 1;
-       case PIPE_TEXTURE_1D_ARRAY:
-       case PIPE_TEXTURE_2D_ARRAY:
-       case PIPE_TEXTURE_CUBE_ARRAY:
-               return r->array_size - 1;
-       default:
-               return 0;
-       }
-}
-
 #endif