summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_bufmgr.h
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-12-13 15:27:39 -0800
committerEric Anholt <[email protected]>2014-12-17 16:07:01 -0800
commit06890c444a893a96b6ec1cfb36f77915ec9acda8 (patch)
tree779fd6b1c624a69cbebae7ad4ab118d29889015a /src/gallium/drivers/vc4/vc4_bufmgr.h
parent39bc9360116e1c944c1d0d04f67a6ec5f010371f (diff)
vc4: Add a userspace BO cache.
Since our kernel BOs require CMA allocation, and the use of them requires new mmaps, it's pretty expensive and we should avoid it if possible. Copying my original design for Intel, make a userspace cache that reuses BOs that haven't been shared to other processes but frees BOs that have sat in the cache for over a second. Improves glxgears framerate on RPi by around 30%.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_bufmgr.h')
-rw-r--r--src/gallium/drivers/vc4/vc4_bufmgr.h34
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 */