anv: Add helpers in anv_allocator for mapping BOs

Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13610>
This commit is contained in:
Jason Ekstrand
2021-10-30 17:02:41 -05:00
committed by Marge Bot
parent 90ac06e502
commit 13fe43714c
3 changed files with 72 additions and 30 deletions

View File

@@ -452,12 +452,17 @@ struct anv_bo {
/** Size of the buffer not including implicit aux */
uint64_t size;
/* Map for internally mapped BOs.
/* Map for mapped BOs.
*
* If ANV_BO_WRAPPER is set in flags, map points to the wrapped BO.
* If ANV_BO_ALLOC_MAPPED is set in flags, this is the map for the whole
* BO. If ANV_BO_WRAPPER is set in flags, map points to the wrapped BO.
* Otherwise, this is the map for the currently mapped range mapped via
* vkMapMemory().
*/
void *map;
size_t map_size;
/** Size of the implicit CCS range at the end of the buffer
*
* On Gfx12, CCS data is always a direct 1/256 scale-down. A single 64K
@@ -1379,6 +1384,14 @@ VkResult anv_device_alloc_bo(struct anv_device *device,
enum anv_bo_alloc_flags alloc_flags,
uint64_t explicit_address,
struct anv_bo **bo);
VkResult anv_device_map_bo(struct anv_device *device,
struct anv_bo *bo,
uint64_t offset,
size_t size,
uint32_t gem_flags,
void **map_out);
void anv_device_unmap_bo(struct anv_device *device,
struct anv_bo *bo);
VkResult anv_device_import_bo_from_host_ptr(struct anv_device *device,
void *host_ptr, uint32_t size,
enum anv_bo_alloc_flags alloc_flags,
@@ -1774,11 +1787,9 @@ struct anv_device_memory {
struct anv_bo * bo;
const struct anv_memory_type * type;
VkDeviceSize map_size;
void * map;
/* The map, from the user PoV is map + map_delta */
uint32_t map_delta;
/* The map, from the user PoV is bo->map + map_delta */
uint64_t map_delta;
/* If set, we are holding reference to AHardwareBuffer
* which we must release when memory is freed.