From 5e0c956cb219e54dfc22e64ac3f00e22619c763f Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Tue, 29 Jan 2013 12:52:17 -0500 Subject: r600g: add cs memory usage accounting and limit it v3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Olšák --- src/gallium/drivers/r600/r600_state.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gallium/drivers/r600/r600_state.c') diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index c0bc2a5b9c1..44cd00ead8a 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1544,6 +1544,7 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx, surf = (struct r600_surface*)state->cbufs[i]; rtex = (struct r600_texture*)surf->base.texture; + r600_context_add_resource_size(ctx, state->cbufs[i]->texture); if (!surf->color_initialized || force_cmask_fmask) { r600_init_color_surface(rctx, surf, force_cmask_fmask); @@ -1576,6 +1577,8 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx, if (state->zsbuf) { surf = (struct r600_surface*)state->zsbuf; + r600_context_add_resource_size(ctx, state->zsbuf->texture); + if (!surf->depth_initialized) { r600_init_depth_surface(rctx, surf); } -- cgit v1.2.3