• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2016 Red Hat.
3  * Copyright © 2016 Bas Nieuwenhuizen
4  *
5  * based in part on anv driver which is:
6  * Copyright © 2015 Intel Corporation
7  *
8  * SPDX-License-Identifier: MIT
9  */
10 
11 #ifndef RADV_BUFFER_H
12 #define RADV_BUFFER_H
13 
14 #include "radv_radeon_winsys.h"
15 
16 #include "vk_buffer.h"
17 
18 struct radv_device;
19 struct radv_device_memory;
20 
21 struct radv_buffer {
22    struct vk_buffer vk;
23 
24    /* Set when bound */
25    struct radeon_winsys_bo *bo;
26    VkDeviceSize offset;
27    uint64_t bo_va;
28    uint64_t range;
29 };
30 
31 VK_DEFINE_NONDISP_HANDLE_CASTS(radv_buffer, vk.base, VkBuffer, VK_OBJECT_TYPE_BUFFER)
32 
33 void radv_buffer_init(struct radv_buffer *buffer, struct radv_device *device, struct radeon_winsys_bo *bo,
34                       uint64_t size, uint64_t offset);
35 void radv_buffer_finish(struct radv_buffer *buffer);
36 
37 VkResult radv_create_buffer(struct radv_device *device, const VkBufferCreateInfo *pCreateInfo,
38                             const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer, bool is_internal);
39 
40 VkResult radv_bo_create(struct radv_device *device, struct vk_object_base *object, uint64_t size, unsigned alignment,
41                         enum radeon_bo_domain domain, enum radeon_bo_flag flags, unsigned priority, uint64_t address,
42                         bool is_internal, struct radeon_winsys_bo **out_bo);
43 
44 VkResult radv_bo_virtual_bind(struct radv_device *device, struct vk_object_base *object,
45                               struct radeon_winsys_bo *parent, uint64_t offset, uint64_t size,
46                               struct radeon_winsys_bo *bo, uint64_t bo_offset);
47 
48 void radv_bo_destroy(struct radv_device *device, struct vk_object_base *object, struct radeon_winsys_bo *bo);
49 
50 VkResult radv_bo_from_fd(struct radv_device *device, int fd, unsigned priority, struct radv_device_memory *mem,
51                          uint64_t *alloc_size);
52 
53 VkResult radv_bo_from_ptr(struct radv_device *device, void *host_ptr, uint64_t alloc_size, unsigned priority,
54                           struct radv_device_memory *mem);
55 
56 #endif /* RADV_BUFFER_H */
57