Path: blob/21.2-virgl/src/broadcom/vulkan/v3dv_bo.h
4560 views
/*1* Copyright © 2019 Raspberry Pi2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef V3DV_BO_H24#define V3DV_BO_H2526struct v3dv_device;2728struct v3dv_bo {29struct list_head list_link;3031uint32_t handle;32uint64_t handle_bit;33uint32_t size;34uint32_t offset;3536uint32_t map_size;37void *map;3839const char *name;4041/** Entry in the linked list of buffers freed, by age. */42struct list_head time_list;43/** Entry in the per-page-count linked list of buffers freed (by age). */44struct list_head size_list;45/** Approximate second when the bo was freed. */46time_t free_time;4748/**49* Whether only our process has a reference to the BO (meaning that50* it's safe to reuse it in the BO cache).51*/52bool private;5354/**55* If this BO was allocated for a swapchain on the display device, the56* handle of the dumb BO on that device.57*/58int32_t dumb_handle;59};6061void v3dv_bo_init(struct v3dv_bo *bo, uint32_t handle, uint32_t size, uint32_t offset, const char *name, bool private);6263struct v3dv_bo *v3dv_bo_alloc(struct v3dv_device *device, uint32_t size, const char *name, bool private);6465bool v3dv_bo_free(struct v3dv_device *device, struct v3dv_bo *bo);6667bool v3dv_bo_wait(struct v3dv_device *device, struct v3dv_bo *bo, uint64_t timeout_ns);6869bool v3dv_bo_map_unsynchronized(struct v3dv_device *device, struct v3dv_bo *bo, uint32_t size);7071bool v3dv_bo_map(struct v3dv_device *device, struct v3dv_bo *bo, uint32_t size);7273void v3dv_bo_unmap(struct v3dv_device *device, struct v3dv_bo *bo);7475void v3dv_bo_cache_init(struct v3dv_device *device);76void v3dv_bo_cache_destroy(struct v3dv_device *device);7778#endif /* V3DV_BO_H */798081