diff options
author | Christoph Bumiller <[email protected]> | 2012-04-14 05:38:16 +0200 |
---|---|---|
committer | Christoph Bumiller <[email protected]> | 2012-04-14 06:14:21 +0200 |
commit | 680f20351ec65fb22774dc08f63d26cf66b47c59 (patch) | |
tree | 3fe9dcf9a125b27d97743e9791fb6a915827d6d9 /src/gallium/drivers/nouveau/nouveau_context.h | |
parent | 36158c199448ce038d9fe913d972f29a655aecab (diff) |
nouveau: add new shared scratch buffers
Diffstat (limited to 'src/gallium/drivers/nouveau/nouveau_context.h')
-rw-r--r-- | src/gallium/drivers/nouveau/nouveau_context.h | 37 |
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 |