1 /* 2 * Copyright 2019 Google LLC 3 * SPDX-License-Identifier: MIT 4 * 5 * based in part on anv and radv which are: 6 * Copyright © 2015 Intel Corporation 7 * Copyright © 2016 Red Hat. 8 * Copyright © 2016 Bas Nieuwenhuizen 9 */ 10 11 #ifndef VN_BUFFER_H 12 #define VN_BUFFER_H 13 14 #include "vn_common.h" 15 16 struct vn_buffer_memory_requirements { 17 VkMemoryRequirements2 memory; 18 VkMemoryDedicatedRequirements dedicated; 19 }; 20 21 struct vn_buffer_cache_entry { 22 const VkBufferCreateInfo *create_info; 23 24 struct vn_buffer_memory_requirements requirements; 25 }; 26 27 struct vn_buffer_cache { 28 /* cache memory type requirement for AHB backed VkBuffer */ 29 uint32_t ahb_mem_type_bits; 30 31 uint64_t max_buffer_size; 32 33 /* cache memory requirements for common native buffer infos */ 34 struct vn_buffer_cache_entry *entries; 35 uint32_t entry_count; 36 }; 37 38 struct vn_buffer { 39 struct vn_object_base base; 40 41 struct vn_buffer_memory_requirements requirements; 42 }; 43 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_buffer, 44 base.base, 45 VkBuffer, 46 VK_OBJECT_TYPE_BUFFER) 47 48 struct vn_buffer_view { 49 struct vn_object_base base; 50 }; 51 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_buffer_view, 52 base.base, 53 VkBufferView, 54 VK_OBJECT_TYPE_BUFFER_VIEW) 55 56 VkResult 57 vn_buffer_create(struct vn_device *dev, 58 const VkBufferCreateInfo *create_info, 59 const VkAllocationCallbacks *alloc, 60 struct vn_buffer **out_buf); 61 62 VkResult 63 vn_buffer_cache_init(struct vn_device *dev); 64 65 void 66 vn_buffer_cache_fini(struct vn_device *dev); 67 68 #endif /* VN_BUFFER_H */ 69