diff options
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_bufmgr.h')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_bufmgr.h | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.h b/src/gallium/drivers/vc4/vc4_bufmgr.h index baaecfdfd3f..f9559e999a1 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.h +++ b/src/gallium/drivers/vc4/vc4_bufmgr.h @@ -26,6 +26,7 @@ #include <stdint.h> #include "util/u_inlines.h" +#include "vc4_qir.h" struct vc4_context; @@ -41,13 +42,26 @@ struct vc4_bo { void *simulator_winsys_map; uint32_t simulator_winsys_stride; #endif + + /** Entry in the linked list of buffers freed, by age. */ + struct simple_node time_list; + /** Entry in the per-page-count linked list of buffers freed (by age). */ + struct simple_node size_list; + /** Approximate second when the bo was freed. */ + time_t free_time; + /** + * Whether only our process has a reference to the BO (meaning that + * it's safe to reuse it in the BO cache). + */ + bool private; }; struct vc4_bo *vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name); struct vc4_bo *vc4_bo_alloc_mem(struct vc4_screen *screen, const void *data, uint32_t size, const char *name); -void vc4_bo_free(struct vc4_bo *bo); +void vc4_bo_last_unreference(struct vc4_bo *bo); +void vc4_bo_last_unreference_locked_timed(struct vc4_bo *bo, time_t time); struct vc4_bo *vc4_bo_open_name(struct vc4_screen *screen, uint32_t name, uint32_t winsys_stride); struct vc4_bo *vc4_bo_open_dmabuf(struct vc4_screen *screen, int fd, @@ -59,7 +73,7 @@ static inline void vc4_bo_set_reference(struct vc4_bo **old_bo, struct vc4_bo *new_bo) { if (pipe_reference(&(*old_bo)->reference, &new_bo->reference)) - vc4_bo_free(*old_bo); + vc4_bo_last_unreference(*old_bo); *old_bo = new_bo; } @@ -77,7 +91,18 @@ vc4_bo_unreference(struct vc4_bo **bo) return; if (pipe_reference(&(*bo)->reference, NULL)) - vc4_bo_free(*bo); + vc4_bo_last_unreference(*bo); + *bo = NULL; +} + +static inline void +vc4_bo_unreference_locked_timed(struct vc4_bo **bo, time_t time) +{ + if (!*bo) + return; + + if (pipe_reference(&(*bo)->reference, NULL)) + vc4_bo_last_unreference_locked_timed(*bo, time); *bo = NULL; } @@ -93,5 +118,8 @@ vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns); bool vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns); +void +vc4_bufmgr_destroy(struct pipe_screen *pscreen); + #endif /* VC4_BUFMGR_H */ |