r600g: disable shader rebuild optimization & account cb flush packet
authorJerome Glisse <jglisse@redhat.com>
Wed, 22 Sep 2010 18:00:53 +0000 (14:00 -0400)
committerJerome Glisse <jglisse@redhat.com>
Wed, 22 Sep 2010 18:19:05 +0000 (14:19 -0400)
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 <jglisse@redhat.com>
src/gallium/drivers/r600/r600_state2.c
src/gallium/winsys/r600/drm/r600_state2.c

index b93bdd3022bfb28fe614a73d134a388d82c37502..4ad9e4c6eb1ff81d2881f45764a4a0ae1be4dfd2 100644 (file)
@@ -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;
        }
 }
 
index 32c7171b51826d3b2e5f9d9ff2b94b74e76dcab6..cde4ec37f9aac8236f9e71a4a0328a1a39020ff3 100644 (file)
@@ -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) |