iris: Add BO_ALLOC_PLAIN flag

We had iris_bo_alloc() call with the wrong flags value, it was
mistaken by aligment, see commit 68652dca0c.

To avoid such mistakes in future here adding BO_ALLOC_PLAIN so
iris_bo_alloc() calls have a more descriptive flag parameter when
there is no special allocation request.

While at it, also standardizing unsigned as the type for this flag.

No behavior changes here.

Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19857>
This commit is contained in:
José Roberto de Souza
2022-11-17 12:27:08 -08:00
parent c12f7f601c
commit 6b3f085c3c
6 changed files with 17 additions and 9 deletions

View File

@@ -70,7 +70,7 @@ binder_realloc(struct iris_context *ice)
iris_bo_unreference(binder->bo);
binder->bo = iris_bo_alloc(bufmgr, "binder", binder->size, binder->alignment,
IRIS_MEMZONE_BINDER, 0);
IRIS_MEMZONE_BINDER, BO_ALLOC_PLAIN);
binder->map = iris_bo_map(NULL, binder->bo, MAP_WRITE);
/* Avoid using offset 0 - tools consider it NULL. */

View File

@@ -76,7 +76,7 @@ iris_init_border_color_pool(struct iris_bufmgr *bufmgr,
pool->bo = iris_bo_alloc(bufmgr, "border colors",
IRIS_BORDER_COLOR_POOL_SIZE, 64,
IRIS_MEMZONE_BORDER_COLOR_POOL, 0);
IRIS_MEMZONE_BORDER_COLOR_POOL, BO_ALLOC_PLAIN);
pool->map = iris_bo_map(NULL, pool->bo, MAP_WRITE);
/* Don't make 0 a valid offset - tools treat that as a NULL pointer. */

View File

@@ -654,8 +654,7 @@ iris_slab_alloc(void *priv,
{
struct iris_bufmgr *bufmgr = priv;
struct iris_slab *slab = calloc(1, sizeof(struct iris_slab));
unsigned flags = heap == IRIS_HEAP_SYSTEM_MEMORY ? BO_ALLOC_SMEM :
heap == IRIS_HEAP_DEVICE_LOCAL ? BO_ALLOC_LMEM : 0;
uint32_t flags;
unsigned slab_size = 0;
/* We only support slab allocation for IRIS_MEMZONE_OTHER */
enum iris_memory_zone memzone = IRIS_MEMZONE_OTHER;
@@ -707,6 +706,13 @@ iris_slab_alloc(void *priv,
}
assert(slab_size != 0);
if (heap == IRIS_HEAP_SYSTEM_MEMORY)
flags = BO_ALLOC_SMEM;
else if (heap == IRIS_HEAP_DEVICE_LOCAL)
flags = BO_ALLOC_LMEM;
else
flags = BO_ALLOC_PLAIN;
slab->bo =
iris_bo_alloc(bufmgr, "slab", slab_size, slab_size, memzone, flags);
if (!slab->bo)

View File

@@ -296,6 +296,7 @@ struct iris_bo {
};
};
#define BO_ALLOC_PLAIN 0
#define BO_ALLOC_ZEROED (1<<0)
#define BO_ALLOC_COHERENT (1<<1)
#define BO_ALLOC_SMEM (1<<2)

View File

@@ -2404,7 +2404,7 @@ iris_get_scratch_space(struct iris_context *ice,
assert(stage < ARRAY_SIZE(devinfo->max_scratch_ids));
uint32_t size = per_thread_scratch * devinfo->max_scratch_ids[stage];
*bop = iris_bo_alloc(bufmgr, "scratch", size, 1024,
IRIS_MEMZONE_SHADER, 0);
IRIS_MEMZONE_SHADER, BO_ALLOC_PLAIN);
}
return *bop;

View File

@@ -443,15 +443,15 @@ iris_resource_disable_aux(struct iris_resource *res)
res->aux.state = NULL;
}
static uint32_t
static unsigned
iris_resource_alloc_flags(const struct iris_screen *screen,
const struct pipe_resource *templ,
enum isl_aux_usage aux_usage)
{
if (templ->flags & IRIS_RESOURCE_FLAG_DEVICE_MEM)
return 0;
return BO_ALLOC_PLAIN;
uint32_t flags = 0;
unsigned flags = BO_ALLOC_PLAIN;
switch (templ->usage) {
case PIPE_USAGE_STAGING:
@@ -1959,11 +1959,12 @@ iris_invalidate_buffer(struct iris_context *ice, struct iris_resource *res)
return false;
struct iris_bo *old_bo = res->bo;
unsigned flags = old_bo->real.protected ? BO_ALLOC_PROTECTED : BO_ALLOC_PLAIN;
struct iris_bo *new_bo =
iris_bo_alloc(screen->bufmgr, res->bo->name, res->base.b.width0,
iris_buffer_alignment(res->base.b.width0),
iris_memzone_for_address(old_bo->address),
old_bo->real.protected ? BO_ALLOC_PROTECTED : 0);
flags);
if (!new_bo)
return false;