panfrost: Use standard ALIGN_POT/INFINITY macros
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 5 Jul 2019 15:25:56 +0000 (08:25 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 10 Jul 2019 13:12:03 +0000 (06:12 -0700)
We had vendored duplicates from pre-Mesa days; clean that up.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_afbc.c
src/gallium/drivers/panfrost/pan_allocate.c
src/gallium/drivers/panfrost/pan_allocate.h
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_resource.c

index d812639d8ca166541110315a3f228c97e86a5f10..298c04be1c45b07c6bc0609a4d9efa9d4541d049 100644 (file)
@@ -105,8 +105,8 @@ unsigned
 panfrost_afbc_header_size(unsigned width, unsigned height)
 {
         /* Align to tile */
-        unsigned aligned_width  = ALIGN(width,  AFBC_TILE_WIDTH);
-        unsigned aligned_height = ALIGN(height, AFBC_TILE_HEIGHT);
+        unsigned aligned_width  = ALIGN_POT(width,  AFBC_TILE_WIDTH);
+        unsigned aligned_height = ALIGN_POT(height, AFBC_TILE_HEIGHT);
 
         /* Compute size in tiles, rather than pixels */
         unsigned tile_count_x = aligned_width  / AFBC_TILE_WIDTH;
@@ -117,6 +117,6 @@ panfrost_afbc_header_size(unsigned width, unsigned height)
         unsigned header_bytes = tile_count * AFBC_HEADER_BYTES_PER_TILE;
 
         /* Align and go */
-        return ALIGN(header_bytes, AFBC_CACHE_ALIGN);
+        return ALIGN_POT(header_bytes, AFBC_CACHE_ALIGN);
 
 }
index 37a6785e7dffbcaaf5c12efb9b4a4efe77c1654c..dff8373cbd5785ce36e43bf10f2a3d0e11fb8e0e 100644 (file)
@@ -38,7 +38,7 @@
 struct panfrost_transfer
 panfrost_allocate_chunk(struct panfrost_context *ctx, size_t size, unsigned heap_id)
 {
-        size = ALIGN(size, ALIGNMENT);
+        size = ALIGN_POT(size, ALIGNMENT);
 
         struct pipe_context *gallium = (struct pipe_context *) ctx;
         struct panfrost_screen *screen = pan_screen(gallium->screen);
@@ -63,7 +63,7 @@ struct panfrost_transfer
 panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz)
 {
         /* Pad the size */
-        sz = ALIGN(sz, ALIGNMENT);
+        sz = ALIGN_POT(sz, ALIGNMENT);
 
         /* Check if there is room in the current entry */
         struct panfrost_transient_pool *pool = &ctx->transient_pools[ctx->cmdstream_i];
index 20ba204dee861dae13ae3f6e86a6c290da0df3b0..45c86b7cb7b9a0ea30dafa864c5d63b3f97f96bb 100644 (file)
@@ -127,10 +127,4 @@ panfrost_reserve(struct panfrost_memory *mem, size_t sz)
 struct panfrost_transfer
 panfrost_allocate_chunk(struct panfrost_context *ctx, size_t size, unsigned heap_id);
 
-#include <math.h>
-#define inff INFINITY
-
-#define R(...) #__VA_ARGS__
-#define ALIGN(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
-
 #endif /* __PAN_ALLOCATE_H__ */
index b9fb187be4463e0968b73a17d255e4194c1f4bbb..90ea38645dcf00073821e12acd677a243c8570fa 100644 (file)
@@ -536,7 +536,7 @@ panfrost_emit_varyings(
         slot->stride = stride;
         slot->size = stride * count;
 
-        ctx->varying_height += ALIGN(slot->size, 64);
+        ctx->varying_height += ALIGN_POT(slot->size, 64);
         assert(ctx->varying_height < ctx->varying_mem.bo->size);
 
         return varying_address;
@@ -1292,7 +1292,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                         mali_ptr gpu = panfrost_map_constant_buffer_gpu(ctx, buf, ubo);
 
                         unsigned bytes_per_field = 16;
-                        unsigned aligned = ALIGN(sz, bytes_per_field);
+                        unsigned aligned = ALIGN_POT(sz, bytes_per_field);
                         unsigned fields = aligned / bytes_per_field;
 
                         ubos[ubo].size = MALI_POSITIVE(fields);
@@ -1318,10 +1318,10 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                  * should work, but in practice causes issues when we're not
                  * explicitly trying to scissor */
 
-                .clip_minx = -inff,
-                .clip_miny = -inff,
-                .clip_maxx = inff,
-                .clip_maxy = inff,
+                .clip_minx = -INFINITY,
+                .clip_miny = -INFINITY,
+                .clip_maxx = INFINITY,
+                .clip_maxy = INFINITY,
 
                 .clip_minz = 0.0,
                 .clip_maxz = 1.0,
index b651fcffb1110e02e0c04bde1f35f9459dc3bef7..4acbae25d4a1fe6ef38205ba34727b32d85671cf 100644 (file)
@@ -229,8 +229,8 @@ panfrost_compute_checksum_sizes(
                 unsigned width,
                 unsigned height)
 {
-        unsigned aligned_width = ALIGN(width, CHECKSUM_TILE_WIDTH);
-        unsigned aligned_height = ALIGN(height, CHECKSUM_TILE_HEIGHT);
+        unsigned aligned_width = ALIGN_POT(width, CHECKSUM_TILE_WIDTH);
+        unsigned aligned_height = ALIGN_POT(height, CHECKSUM_TILE_HEIGHT);
 
         unsigned tile_count_x = aligned_width / CHECKSUM_TILE_WIDTH;
         unsigned tile_count_y = aligned_height / CHECKSUM_TILE_HEIGHT;
@@ -282,8 +282,8 @@ panfrost_setup_slices(struct panfrost_resource *pres, size_t *bo_size)
                 unsigned effective_depth = depth;
 
                 if (should_align) {
-                        effective_width = ALIGN(effective_width, 16);
-                        effective_height = ALIGN(effective_height, 16);
+                        effective_width = ALIGN_POT(effective_width, 16);
+                        effective_height = ALIGN_POT(effective_height, 16);
 
                         /* We don't need to align depth */
                 }
@@ -295,7 +295,7 @@ panfrost_setup_slices(struct panfrost_resource *pres, size_t *bo_size)
 
                 /* ..but cache-line align it for performance */
                 if (can_align_stride && pres->layout == PAN_LINEAR)
-                        stride = ALIGN(stride, 64);
+                        stride = ALIGN_POT(stride, 64);
 
                 slice->stride = stride;
 
@@ -337,14 +337,14 @@ panfrost_setup_slices(struct panfrost_resource *pres, size_t *bo_size)
         if (res->target != PIPE_TEXTURE_3D) {
                 /* Arrays and cubemaps have the entire miptree duplicated */
 
-                pres->cubemap_stride = ALIGN(offset, 64);
-                *bo_size = ALIGN(pres->cubemap_stride * res->array_size, 4096);
+                pres->cubemap_stride = ALIGN_POT(offset, 64);
+                *bo_size = ALIGN_POT(pres->cubemap_stride * res->array_size, 4096);
         } else {
                 /* 3D strides across the 2D layers */
                 assert(res->array_size == 1);
 
                 pres->cubemap_stride = size_2d;
-                *bo_size = ALIGN(offset, 4096);
+                *bo_size = ALIGN_POT(offset, 4096);
         }
 }