diff options
author | Jason Ekstrand <[email protected]> | 2017-03-13 16:18:54 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-04-27 20:08:46 -0700 |
commit | 494d6f65a7c5138bd3bda062afd6a1c4adadc1e8 (patch) | |
tree | 8dac4ec72b7bbddf86af69fab4d30263e1ecbe6a /src/intel/vulkan/anv_private.h | |
parent | 5d25ac6a4b0bb655101b67e267fdac7a15775916 (diff) |
anv/allocator: Add a BO cache
This cache allows us to easily ensure that we have a unique anv_bo for
each gem handle. We'll need this in order to support multiple-import of
memory objects and semaphores.
v2 (Jason Ekstrand):
- Reject BO imports if the size doesn't match the prime fd size as
reported by lseek().
Reviewed-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_private.h')
-rw-r--r-- | src/intel/vulkan/anv_private.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 36a67606153..7ebcfefeb12 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -604,6 +604,27 @@ struct anv_bo *anv_scratch_pool_alloc(struct anv_device *device, gl_shader_stage stage, unsigned per_thread_scratch); +/** Implements a BO cache that ensures a 1-1 mapping of GEM BOs to anv_bos */ +struct anv_bo_cache { + struct hash_table *bo_map; + pthread_mutex_t mutex; +}; + +VkResult anv_bo_cache_init(struct anv_bo_cache *cache); +void anv_bo_cache_finish(struct anv_bo_cache *cache); +VkResult anv_bo_cache_alloc(struct anv_device *device, + struct anv_bo_cache *cache, + uint64_t size, struct anv_bo **bo); +VkResult anv_bo_cache_import(struct anv_device *device, + struct anv_bo_cache *cache, + int fd, uint64_t size, struct anv_bo **bo); +VkResult anv_bo_cache_export(struct anv_device *device, + struct anv_bo_cache *cache, + struct anv_bo *bo_in, int *fd_out); +void anv_bo_cache_release(struct anv_device *device, + struct anv_bo_cache *cache, + struct anv_bo *bo); + struct anv_physical_device { VK_LOADER_DATA _loader_data; |