panfrost: Use standard ALIGN_POT/INFINITY macros

We had vendored duplicates from pre-Mesa days; clean that up.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
Alyssa Rosenzweig
2019-07-05 08:25:56 -07:00
parent c78d2d9840
commit 7c82dfba8f
5 changed files with 19 additions and 25 deletions
+3 -3
View 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);
}
+2 -2
View 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];
@@ -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__ */
+6 -6
View 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,
+8 -8
View 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);
}
}