1 #ifndef __NOUVEAU_CONTEXT_H__
2 #define __NOUVEAU_CONTEXT_H__
4 #include "pipe/p_context.h"
5 #include <libdrm/nouveau.h>
7 #define NOUVEAU_MAX_SCRATCH_BUFS 4
9 struct nouveau_context
{
10 struct pipe_context pipe
;
11 struct nouveau_screen
*screen
;
13 struct nouveau_client
*client
;
14 struct nouveau_pushbuf
*pushbuf
;
19 void (*copy_data
)(struct nouveau_context
*,
20 struct nouveau_bo
*dst
, unsigned, unsigned,
21 struct nouveau_bo
*src
, unsigned, unsigned, unsigned);
22 void (*push_data
)(struct nouveau_context
*,
23 struct nouveau_bo
*dst
, unsigned, unsigned,
24 unsigned, const void *);
25 /* base, size refer to the whole constant buffer */
26 void (*push_cb
)(struct nouveau_context
*,
27 struct nouveau_bo
*, unsigned domain
,
28 unsigned base
, unsigned size
,
29 unsigned offset
, unsigned words
, const uint32_t *);
37 struct nouveau_bo
*bo
[NOUVEAU_MAX_SCRATCH_BUFS
];
38 struct nouveau_bo
*current
;
39 struct nouveau_bo
**runout
;
45 static INLINE
struct nouveau_context
*
46 nouveau_context(struct pipe_context
*pipe
)
48 return (struct nouveau_context
*)pipe
;
52 nouveau_context_init_vdec(struct nouveau_context
*);
55 nouveau_scratch_runout_release(struct nouveau_context
*);
57 /* This is needed because we don't hold references outside of context::scratch,
58 * because we don't want to un-bo_ref each allocation every time. This is less
59 * work, and we need the wrap index anyway for extreme situations.
62 nouveau_scratch_done(struct nouveau_context
*nv
)
64 nv
->scratch
.wrap
= nv
->scratch
.id
;
65 if (unlikely(nv
->scratch
.nr_runout
))
66 nouveau_scratch_runout_release(nv
);
69 /* Get pointer to scratch buffer.
70 * The returned nouveau_bo is only referenced by the context, don't un-ref it !
73 nouveau_scratch_get(struct nouveau_context
*, unsigned size
, uint64_t *gpu_addr
,
74 struct nouveau_bo
**);
77 nouveau_context_destroy(struct nouveau_context
*ctx
)
81 for (i
= 0; i
< NOUVEAU_MAX_SCRATCH_BUFS
; ++i
)
82 if (ctx
->scratch
.bo
[i
])
83 nouveau_bo_ref(NULL
, &ctx
->scratch
.bo
[i
]);