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/winsys/radeon/drm | |
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/winsys/radeon/drm')
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 11 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_winsys.h | 10 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c index cab27040bba..6a7115ba76b 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c @@ -383,6 +383,16 @@ static boolean radeon_drm_cs_validate(struct radeon_winsys_cs *rcs) return status; } +static boolean radeon_drm_cs_memory_below_limit(struct radeon_winsys_cs *rcs, uint64_t vram, uint64_t gtt) +{ + struct radeon_drm_cs *cs = radeon_drm_cs(rcs); + boolean status = + (cs->csc->used_gart + gtt) < cs->ws->info.gart_size * 0.7 && + (cs->csc->used_vram + vram) < cs->ws->info.vram_size * 0.7; + + return status; +} + static void radeon_drm_cs_write_reloc(struct radeon_winsys_cs *rcs, struct radeon_winsys_cs_handle *buf) { @@ -575,6 +585,7 @@ void radeon_drm_cs_init_functions(struct radeon_drm_winsys *ws) ws->base.cs_destroy = radeon_drm_cs_destroy; ws->base.cs_add_reloc = radeon_drm_cs_add_reloc; ws->base.cs_validate = radeon_drm_cs_validate; + ws->base.cs_memory_below_limit = radeon_drm_cs_memory_below_limit; ws->base.cs_write_reloc = radeon_drm_cs_write_reloc; ws->base.cs_flush = radeon_drm_cs_flush; ws->base.cs_set_flush_callback = radeon_drm_cs_set_flush; diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h index 7fdef3fad87..8b64ef2e1a1 100644 --- a/src/gallium/winsys/radeon/drm/radeon_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h @@ -393,6 +393,16 @@ struct radeon_winsys { boolean (*cs_validate)(struct radeon_winsys_cs *cs); /** + * Return TRUE if there is enough memory in VRAM and GTT for the relocs + * added so far. + * + * \param cs A command stream to validate. + * \param vram VRAM memory size pending to be use + * \param gtt GTT memory size pending to be use + */ + boolean (*cs_memory_below_limit)(struct radeon_winsys_cs *cs, uint64_t vram, uint64_t gtt); + + /** * Write a relocated dword to a command buffer. * * \param cs A command stream the relocation is written to. |