From 1cd868f105fac358c93ae0781366407e95c8b6dc Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 21 Jul 2021 22:50:22 -0700 Subject: [PATCH] iris: Add some accessor wrappers for a few fields. In the future, we're going to have "real" BOs representing GEM objects, and "slab allocated" BOs suballocated out of a larger BO. Many fields are properties of the real underlying BO, but we may still want to ask about an arbitrary BO, and have the accessor chase answers down as necessary. Reviewed-by: Paulo Zanoni Part-of: --- src/gallium/drivers/iris/iris_bufmgr.h | 18 ++++++++++++++++++ src/gallium/drivers/iris/iris_resource.c | 9 +++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h index 98fae46a056..b9c3bfc579a 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.h +++ b/src/gallium/drivers/iris/iris_bufmgr.h @@ -359,6 +359,24 @@ iris_bo_is_external(const struct iris_bo *bo) return bo->exported || bo->imported; } +static inline bool +iris_bo_is_imported(const struct iris_bo *bo) +{ + return bo->imported; +} + +static inline bool +iris_bo_is_exported(const struct iris_bo *bo) +{ + return bo->exported; +} + +static inline enum iris_mmap_mode +iris_bo_mmap_mode(const struct iris_bo *bo) +{ + return bo->mmap_mode; +} + /** * Mark a buffer as being shared with other external clients. */ diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 12140ac06f4..c96bd894deb 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -2052,7 +2052,7 @@ iris_transfer_map(struct pipe_context *ctx, * other devices that I915_GEM_MMAP cannot work with. */ if ((usage & PIPE_MAP_DIRECTLY) && - (surf->tiling != ISL_TILING_LINEAR || res->bo->imported)) + (surf->tiling != ISL_TILING_LINEAR || iris_bo_is_imported(res->bo))) return NULL; bool map_would_stall = false; @@ -2095,7 +2095,7 @@ iris_transfer_map(struct pipe_context *ctx, if (usage & PIPE_MAP_WRITE) util_range_add(&res->base.b, &res->valid_buffer_range, box->x, box->x + box->width); - if (res->bo->mmap_mode != IRIS_MMAP_NONE) { + if (iris_bo_mmap_mode(res->bo) != IRIS_MMAP_NONE) { /* GPU copies are not useful for buffer reads. Instead of stalling to * read from the original buffer, we'd simply copy it to a temporary... * then stall (a bit longer) to read from that buffer. @@ -2119,7 +2119,8 @@ iris_transfer_map(struct pipe_context *ctx, */ if (!map_would_stall && !isl_aux_usage_has_compression(res->aux.usage) && - !((usage & PIPE_MAP_READ) && res->bo->mmap_mode != IRIS_MMAP_WB)) { + !((usage & PIPE_MAP_READ) && + iris_bo_mmap_mode(res->bo) != IRIS_MMAP_WB)) { usage |= PIPE_MAP_DIRECTLY; } } @@ -2273,7 +2274,7 @@ iris_texture_subdata(struct pipe_context *ctx, surf->tiling == ISL_TILING_4 || isl_aux_usage_has_compression(res->aux.usage) || resource_is_busy(ice, res) || - res->bo->mmap_mode == IRIS_MMAP_NONE) { + iris_bo_mmap_mode(res->bo) == IRIS_MMAP_NONE) { return u_default_texture_subdata(ctx, resource, level, usage, box, data, stride, layer_stride); }