From b8835a3992edb7b01712ea83b5729ef0f6f94e4f Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Wed, 22 Sep 2010 14:00:53 -0400 Subject: [PATCH] r600g: disable shader rebuild optimization & account cb flush packet Shader rebuild should be more clever, we should store along each shader all the value that change shader program rather than using flags in context (ie change sequence like : change vs buffer, draw, change vs buffer, switch shader will trigger useless shader rebuild). Signed-off-by: Jerome Glisse --- src/gallium/drivers/r600/r600_state2.c | 25 ++++------------------- src/gallium/winsys/r600/drm/r600_state2.c | 10 ++++++++- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/r600/r600_state2.c b/src/gallium/drivers/r600/r600_state2.c index b93bdd3022b..4ad9e4c6eb1 100644 --- a/src/gallium/drivers/r600/r600_state2.c +++ b/src/gallium/drivers/r600/r600_state2.c @@ -137,8 +137,6 @@ struct r600_pipe_context { struct r600_pipe_shader *ps_shader; struct r600_pipe_shader *vs_shader; /* shader information */ - bool ps_rebuild; - bool vs_rebuild; unsigned sprite_coord_enable; bool flatshade; }; @@ -198,7 +196,6 @@ static void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shade r600_pipe_state_add_reg(rstate, R600_GROUP_CONTEXT, R_028894_SQ_PGM_START_FS, 0x00000000, 0xFFFFFFFF, shader->bo); - rctx->vs_rebuild = FALSE; } static void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shader) @@ -268,7 +265,6 @@ static void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shade r600_pipe_state_add_reg(rstate, R600_GROUP_CONTEXT, R_0288CC_SQ_PGM_CF_OFFSET_PS, 0x00000000, 0xFFFFFFFF, NULL); - rctx->ps_rebuild = FALSE; } static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *shader) @@ -350,20 +346,6 @@ static int r600_pipe_shader_update2(struct pipe_context *ctx, struct r600_pipe_s if (shader == NULL) return -EINVAL; - if (shader->bo) { - switch (shader->shader.processor_type) { - case TGSI_PROCESSOR_VERTEX: - if (!rctx->vs_rebuild) - return 0; - break; - case TGSI_PROCESSOR_FRAGMENT: - if (!rctx->ps_rebuild) - return 0; - break; - default: - return -EINVAL; - } - } /* there should be enough input */ if (rctx->vertex_elements->count < shader->shader.bc.nresource) { R600_ERR("%d resources provided, expecting %d\n", @@ -644,6 +626,7 @@ static void r600_draw_common(struct r600_drawl *draw) if (draw->index_buffer) { rbuffer = (struct r600_resource*)draw->index_buffer; rdraw.indices = rbuffer->bo; + rdraw.indices_bo_offset = 0; } r600_context_draw(&rctx->ctx, &rdraw); } @@ -1075,10 +1058,10 @@ static void r600_bind_rs_state(struct pipe_context *ctx, void *state) return; if (rctx->flatshade != rs->flatshade) { - rctx->ps_rebuild = TRUE; +// rctx->ps_rebuild = TRUE; } if (rctx->sprite_coord_enable != rs->sprite_coord_enable) { - rctx->ps_rebuild = TRUE; +// rctx->ps_rebuild = TRUE; } rctx->flatshade = rs->flatshade; rctx->sprite_coord_enable = rs->sprite_coord_enable; @@ -1364,7 +1347,7 @@ static void r600_bind_vertex_elements(struct pipe_context *ctx, void *state) rctx->vertex_elements = v; if (v) { v->refcount++; - rctx->vs_rebuild = TRUE; +// rctx->vs_rebuild = TRUE; } } diff --git a/src/gallium/winsys/r600/drm/r600_state2.c b/src/gallium/winsys/r600/drm/r600_state2.c index 32c7171b518..cde4ec37f9a 100644 --- a/src/gallium/winsys/r600/drm/r600_state2.c +++ b/src/gallium/winsys/r600/drm/r600_state2.c @@ -914,6 +914,15 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw) r600_context_flush(ctx); } } + + /* find number of color buffer */ + for (int i = 0; i < 8; i++) { + cb[i] = r600_context_reg_bo(ctx, R600_GROUP_CONTEXT, R_028040_CB_COLOR0_BASE + (i << 2)); + if (cb[i]) { + ndwords += 7; + } + } + if ((ctx->pm4_dirty_cdwords + ndwords + ctx->pm4_cdwords) > ctx->pm4_ndwords) { /* need to flush */ r600_context_flush(ctx); @@ -955,7 +964,6 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw) /* flush color buffer */ for (int i = 0; i < 8; i++) { - cb[i] = r600_context_reg_bo(ctx, R600_GROUP_CONTEXT, R_028040_CB_COLOR0_BASE + (i << 2)); if (cb[i]) { ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SURFACE_SYNC, 3); ctx->pm4[ctx->pm4_cdwords++] = (S_0085F0_CB0_DEST_BASE_ENA(1) << i) | -- 2.30.2