i965/fs: Allow constant propagation into logical send sources.
[mesa.git] / src / gallium / drivers / vc4 / vc4_bufmgr.h
index baaecfdfd3fe9fffa2e99a15303a0c593397649f..b77506e242af966d73d7b38fc839627921dbf44e 100644 (file)
@@ -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 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 */