diff options
author | Jerome Glisse <[email protected]> | 2013-01-29 12:52:17 -0500 |
---|---|---|
committer | Jerome Glisse <[email protected]> | 2013-01-31 14:23:52 -0500 |
commit | 5e0c956cb219e54dfc22e64ac3f00e22619c763f (patch) | |
tree | 90ed914596c27cb1d6fdf453b2fc4bcf91cea8de /src/gallium/drivers/r600/r600_pipe.h | |
parent | 5c86a728d4f688c0fe7fbf9f4b8f88060b65c4ee (diff) |
r600g: add cs memory usage accounting and limit it v3
We are now seing cs that can go over the vram+gtt size to avoid
failing flush early cs that goes over 70% (gtt+vram) usage. 70%
is use to allow some fragmentation.
The idea is to compute a gross estimate of memory requirement of
each draw call. After each draw call, memory will be precisely
accounted. So the uncertainty is only on the current draw call.
In practice this gave very good estimate (+/- 10% of the target
memory limit).
v2: Remove left over from testing version, remove useless NULL
checking. Improve commit message.
v3: Add comment to code on memory accounting precision
Signed-off-by: Jerome Glisse <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/drivers/r600/r600_pipe.h')
-rw-r--r-- | src/gallium/drivers/r600/r600_pipe.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 3ff42d38f15..ec59c929524 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -447,6 +447,10 @@ struct r600_context { unsigned backend_mask; unsigned max_db; /* for OQ */ + /* current unaccounted memory usage */ + uint64_t vram; + uint64_t gtt; + /* Miscellaneous state objects. */ void *custom_dsa_flush; void *custom_blend_resolve; @@ -998,4 +1002,28 @@ static INLINE unsigned u_max_layer(struct pipe_resource *r, unsigned level) } } +static INLINE void r600_context_add_resource_size(struct pipe_context *ctx, struct pipe_resource *r) +{ + struct r600_context *rctx = (struct r600_context *)ctx; + struct r600_resource *rr = (struct r600_resource *)r; + + if (r == NULL) { + return; + } + + /* + * The idea is to compute a gross estimate of memory requirement of + * each draw call. After each draw call, memory will be precisely + * accounted. So the uncertainty is only on the current draw call. + * In practice this gave very good estimate (+/- 10% of the target + * memory limit). + */ + if (rr->domains & RADEON_DOMAIN_GTT) { + rctx->gtt += rr->buf->size; + } + if (rr->domains & RADEON_DOMAIN_VRAM) { + rctx->vram += rr->buf->size; + } +} + #endif |