summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2019-03-23 10:04:16 -0700
committerKenneth Graunke <[email protected]>2019-07-02 07:23:55 +0000
commit07f345566448c4defef109b315a5361266ffd2ea (patch)
treecf829659147d320b59cbf0c27d448ec924b8cdd1
parent042aeffd5b2c8d0af8310bdd57515b4c71eb125e (diff)
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 <[email protected]> Tested-by: Jordan Justen <[email protected]>
-rw-r--r--src/gallium/drivers/iris/iris_bufmgr.c26
-rw-r--r--src/gallium/drivers/iris/iris_bufmgr.h1
-rw-r--r--src/gallium/drivers/iris/iris_resource.c4
3 files changed, 19 insertions, 12 deletions
diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 9894618b1de..da28aad7a75 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -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);
}
diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h
index 5676a35e106..f05a71edf98 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.h
+++ b/src/gallium/drivers/iris/iris_bufmgr.h
@@ -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,
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 9a2b7bda22b..8b7640aa4b6 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -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);