X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fvc4%2Fvc4_bufmgr.h;h=b77506e242af966d73d7b38fc839627921dbf44e;hb=48d743c5019076056739561f979e7101c04acf21;hp=baaecfdfd3fe9fffa2e99a15303a0c593397649f;hpb=39bc9360116e1c944c1d0d04f67a6ec5f010371f;p=mesa.git diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.h b/src/gallium/drivers/vc4/vc4_bufmgr.h index baaecfdfd3f..b77506e242a 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.h +++ b/src/gallium/drivers/vc4/vc4_bufmgr.h @@ -26,6 +26,7 @@ #include #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 list_head time_list; + /** Entry in the per-page-count linked list of buffers freed (by age). */ + struct list_head 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); +struct vc4_bo *vc4_bo_alloc_shader(struct vc4_screen *screen, const void *data, + uint32_t size); +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; } @@ -88,10 +113,14 @@ void * vc4_bo_map_unsynchronized(struct vc4_bo *bo); bool -vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns); +vc4_bo_wait(struct vc4_bo *bo, uint64_t timeout_ns, const char *reason); bool -vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns); +vc4_wait_seqno(struct vc4_screen *screen, uint64_t seqno, uint64_t timeout_ns, + const char *reason); + +void +vc4_bufmgr_destroy(struct pipe_screen *pscreen); #endif /* VC4_BUFMGR_H */