1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2016 Red Hat. 3bf215546Sopenharmony_ci * Copyright © 2016 Bas Nieuwenhuizen 4bf215546Sopenharmony_ci * SPDX-License-Identifier: MIT 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * based in part on anv driver which is: 7bf215546Sopenharmony_ci * Copyright © 2015 Intel Corporation 8bf215546Sopenharmony_ci */ 9bf215546Sopenharmony_ci 10bf215546Sopenharmony_ci#ifndef TU_SUBALLOC_H 11bf215546Sopenharmony_ci#define TU_SUBALLOC_H 12bf215546Sopenharmony_ci 13bf215546Sopenharmony_ci#include "tu_common.h" 14bf215546Sopenharmony_ci 15bf215546Sopenharmony_ci#include "tu_drm.h" 16bf215546Sopenharmony_ci 17bf215546Sopenharmony_ci/* externally-synchronized BO suballocator. */ 18bf215546Sopenharmony_cistruct tu_suballocator 19bf215546Sopenharmony_ci{ 20bf215546Sopenharmony_ci struct tu_device *dev; 21bf215546Sopenharmony_ci 22bf215546Sopenharmony_ci uint32_t default_size; 23bf215546Sopenharmony_ci enum tu_bo_alloc_flags flags; 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci /** Current BO we're suballocating out of. */ 26bf215546Sopenharmony_ci struct tu_bo *bo; 27bf215546Sopenharmony_ci uint32_t next_offset; 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci /** Optional BO cached for recycling as the next suballoc->bo, instead of having to allocate one. */ 30bf215546Sopenharmony_ci struct tu_bo *cached_bo; 31bf215546Sopenharmony_ci}; 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_cistruct tu_suballoc_bo 34bf215546Sopenharmony_ci{ 35bf215546Sopenharmony_ci struct tu_bo *bo; 36bf215546Sopenharmony_ci uint64_t iova; 37bf215546Sopenharmony_ci uint32_t size; /* bytes */ 38bf215546Sopenharmony_ci}; 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_civoid 41bf215546Sopenharmony_citu_bo_suballocator_init(struct tu_suballocator *suballoc, 42bf215546Sopenharmony_ci struct tu_device *dev, 43bf215546Sopenharmony_ci uint32_t default_size, 44bf215546Sopenharmony_ci uint32_t flags); 45bf215546Sopenharmony_civoid 46bf215546Sopenharmony_citu_bo_suballocator_finish(struct tu_suballocator *suballoc); 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_ciVkResult 49bf215546Sopenharmony_citu_suballoc_bo_alloc(struct tu_suballoc_bo *suballoc_bo, struct tu_suballocator *suballoc, 50bf215546Sopenharmony_ci uint32_t size, uint32_t align); 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_civoid * 53bf215546Sopenharmony_citu_suballoc_bo_map(struct tu_suballoc_bo *bo); 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_civoid 56bf215546Sopenharmony_citu_suballoc_bo_free(struct tu_suballocator *suballoc, struct tu_suballoc_bo *bo); 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci#endif /* TU_SUBALLOC_H */ 59