summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nouveau/nouveau_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/nouveau/nouveau_context.h')
-rw-r--r--src/gallium/drivers/nouveau/nouveau_context.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h
index 79efd08fa91..531c6238b9f 100644
--- a/src/gallium/drivers/nouveau/nouveau_context.h
+++ b/src/gallium/drivers/nouveau/nouveau_context.h
@@ -3,6 +3,8 @@
#include "pipe/p_context.h"
+#define NOUVEAU_MAX_SCRATCH_BUFS 4
+
struct nouveau_context {
struct pipe_context pipe;
struct nouveau_screen *screen;
@@ -24,6 +26,19 @@ struct nouveau_context {
struct nouveau_bo *, unsigned domain,
unsigned base, unsigned size,
unsigned offset, unsigned words, const uint32_t *);
+
+ struct {
+ uint8_t *map;
+ unsigned id;
+ unsigned wrap;
+ unsigned offset;
+ unsigned end;
+ struct nouveau_bo *bo[NOUVEAU_MAX_SCRATCH_BUFS];
+ struct nouveau_bo *current;
+ struct nouveau_bo **runout;
+ unsigned nr_runout;
+ unsigned bo_size;
+ } scratch;
};
static INLINE struct nouveau_context *
@@ -35,4 +50,26 @@ nouveau_context(struct pipe_context *pipe)
void
nouveau_context_init_vdec(struct nouveau_context *);
+void
+nouveau_scratch_runout_release(struct nouveau_context *);
+
+/* This is needed because we don't hold references outside of context::scratch,
+ * because we don't want to un-bo_ref each allocation every time. This is less
+ * work, and we need the wrap index anyway for extreme situations.
+ */
+static INLINE void
+nouveau_scratch_done(struct nouveau_context *nv)
+{
+ nv->scratch.wrap = nv->scratch.id;
+ if (unlikely(nv->scratch.nr_runout))
+ nouveau_scratch_runout_release(nv);
+}
+
+/* Get pointer to scratch buffer.
+ * The returned nouveau_bo is only referenced by the context, don't un-ref it !
+ */
+void *
+nouveau_scratch_get(struct nouveau_context *, unsigned size, uint64_t *gpu_addr,
+ struct nouveau_bo **);
+
#endif