mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-21 01:10:44 +02:00
iris: Add an explicit alignment parameter to iris_bo_alloc_tiled().
In the future, some images will need to be aligned to a larger value than 4096. Most buffers, however, don't have any such requirement, so for now we only add the parameter to iris_bo_alloc_tiled() and leave the others with the simpler interface. v2: Fix missing alignment in vma_alloc, caught by Caio! Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> Tested-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
parent
042aeffd5b
commit
07f3455664
3 changed files with 19 additions and 12 deletions
|
|
@ -349,6 +349,7 @@ bo_calloc(void)
|
|||
static struct iris_bo *
|
||||
alloc_bo_from_cache(struct iris_bufmgr *bufmgr,
|
||||
struct bo_cache_bucket *bucket,
|
||||
uint32_t alignment,
|
||||
enum iris_memory_zone memzone,
|
||||
unsigned flags,
|
||||
bool match_zone)
|
||||
|
|
@ -385,10 +386,11 @@ alloc_bo_from_cache(struct iris_bufmgr *bufmgr,
|
|||
if (!bo)
|
||||
return NULL;
|
||||
|
||||
/* If the cached BO isn't in the right memory zone, free the old
|
||||
* memory and assign it a new address.
|
||||
/* If the cached BO isn't in the right memory zone, or the alignment
|
||||
* isn't sufficient, free the old memory and assign it a new address.
|
||||
*/
|
||||
if (memzone != iris_memzone_for_address(bo->gtt_offset)) {
|
||||
if (memzone != iris_memzone_for_address(bo->gtt_offset) ||
|
||||
bo->gtt_offset % alignment != 0) {
|
||||
vma_free(bufmgr, bo->gtt_offset, bo->size);
|
||||
bo->gtt_offset = 0ull;
|
||||
}
|
||||
|
|
@ -456,6 +458,7 @@ static struct iris_bo *
|
|||
bo_alloc_internal(struct iris_bufmgr *bufmgr,
|
||||
const char *name,
|
||||
uint64_t size,
|
||||
uint32_t alignment,
|
||||
enum iris_memory_zone memzone,
|
||||
unsigned flags,
|
||||
uint32_t tiling_mode,
|
||||
|
|
@ -476,11 +479,13 @@ bo_alloc_internal(struct iris_bufmgr *bufmgr,
|
|||
/* Get a buffer out of the cache if available. First, we try to find
|
||||
* one with a matching memory zone so we can avoid reallocating VMA.
|
||||
*/
|
||||
bo = alloc_bo_from_cache(bufmgr, bucket, memzone, flags, true);
|
||||
bo = alloc_bo_from_cache(bufmgr, bucket, alignment, memzone, flags, true);
|
||||
|
||||
/* If that fails, we try for any cached BO, without matching memzone. */
|
||||
if (!bo)
|
||||
bo = alloc_bo_from_cache(bufmgr, bucket, memzone, flags, false);
|
||||
if (!bo) {
|
||||
bo = alloc_bo_from_cache(bufmgr, bucket, alignment, memzone, flags,
|
||||
false);
|
||||
}
|
||||
|
||||
mtx_unlock(&bufmgr->lock);
|
||||
|
||||
|
|
@ -492,7 +497,7 @@ bo_alloc_internal(struct iris_bufmgr *bufmgr,
|
|||
|
||||
if (bo->gtt_offset == 0ull) {
|
||||
mtx_lock(&bufmgr->lock);
|
||||
bo->gtt_offset = vma_alloc(bufmgr, memzone, bo->size, 1);
|
||||
bo->gtt_offset = vma_alloc(bufmgr, memzone, bo->size, alignment);
|
||||
mtx_unlock(&bufmgr->lock);
|
||||
|
||||
if (bo->gtt_offset == 0ull)
|
||||
|
|
@ -542,16 +547,17 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr,
|
|||
uint64_t size,
|
||||
enum iris_memory_zone memzone)
|
||||
{
|
||||
return bo_alloc_internal(bufmgr, name, size, memzone,
|
||||
return bo_alloc_internal(bufmgr, name, size, 1, memzone,
|
||||
0, I915_TILING_NONE, 0);
|
||||
}
|
||||
|
||||
struct iris_bo *
|
||||
iris_bo_alloc_tiled(struct iris_bufmgr *bufmgr, const char *name,
|
||||
uint64_t size, enum iris_memory_zone memzone,
|
||||
uint64_t size, uint32_t alignment,
|
||||
enum iris_memory_zone memzone,
|
||||
uint32_t tiling_mode, uint32_t pitch, unsigned flags)
|
||||
{
|
||||
return bo_alloc_internal(bufmgr, name, size, memzone,
|
||||
return bo_alloc_internal(bufmgr, name, size, alignment, memzone,
|
||||
flags, tiling_mode, pitch);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ struct iris_bo *iris_bo_alloc(struct iris_bufmgr *bufmgr,
|
|||
struct iris_bo *iris_bo_alloc_tiled(struct iris_bufmgr *bufmgr,
|
||||
const char *name,
|
||||
uint64_t size,
|
||||
uint32_t alignment,
|
||||
enum iris_memory_zone memzone,
|
||||
uint32_t tiling_mode,
|
||||
uint32_t pitch,
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ iris_resource_alloc_aux(struct iris_screen *screen, struct iris_resource *res)
|
|||
* of bytes instead of trying to recalculate based on different format
|
||||
* block sizes.
|
||||
*/
|
||||
res->aux.bo = iris_bo_alloc_tiled(screen->bufmgr, "aux buffer", size,
|
||||
res->aux.bo = iris_bo_alloc_tiled(screen->bufmgr, "aux buffer", size, 4096,
|
||||
IRIS_MEMZONE_OTHER, I915_TILING_Y,
|
||||
res->aux.surf.row_pitch_B, alloc_flags);
|
||||
if (!res->aux.bo) {
|
||||
|
|
@ -666,7 +666,7 @@ iris_resource_create_with_modifiers(struct pipe_screen *pscreen,
|
|||
IRIS_RESOURCE_FLAG_SURFACE_MEMZONE |
|
||||
IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE)));
|
||||
|
||||
res->bo = iris_bo_alloc_tiled(screen->bufmgr, name, res->surf.size_B,
|
||||
res->bo = iris_bo_alloc_tiled(screen->bufmgr, name, res->surf.size_B, 4096,
|
||||
memzone,
|
||||
isl_tiling_to_i915_tiling(res->surf.tiling),
|
||||
res->surf.row_pitch_B, flags);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue