r600g: avoid reemiting literal, avoid scheduling empty cs
authorJerome Glisse <jglisse@redhat.com>
Tue, 10 Aug 2010 15:52:00 +0000 (11:52 -0400)
committerJerome Glisse <jglisse@redhat.com>
Tue, 10 Aug 2010 15:53:05 +0000 (11:53 -0400)
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/drivers/r600/r600_asm.c
src/gallium/drivers/r600/r600_asm.h
src/gallium/drivers/r600/r600_context.c
src/gallium/drivers/r600/radeon.h
src/gallium/winsys/r600/drm/radeon_ctx.c
src/gallium/winsys/r600/drm/radeon_priv.h

index 16c98504ad9207da48b5eebebbe97f7825c610ab..ae818bf19b70d740f0193c5ff4ebc8e3a5512a6e 100644 (file)
@@ -179,12 +179,13 @@ int r600_bc_add_literal(struct r600_bc *bc, const u32 *value)
                return -EINVAL;
        }
        alu = LIST_ENTRY(struct r600_bc_alu, bc->cf_last->alu.prev, list);
-       if (!alu->last || !alu->nliteral) {
+       if (!alu->last || !alu->nliteral || alu->literal_added) {
                return 0;
        }
        memcpy(alu->value, value, 4 * 4);
        bc->cf_last->ndw += alu->nliteral;
        bc->ndw += alu->nliteral;
+       alu->literal_added = 1;
        return 0;
 }
 
index 3fd94dbda0361e58f4ee2464fd838a717e432997..10d98afaf00ce6830a88ee82f5909c95b524f2c3 100644 (file)
@@ -48,6 +48,7 @@ struct r600_bc_alu {
        unsigned                        last;
        unsigned                        is_op3;
        unsigned                        nliteral;
+       unsigned                        literal_added;
        u32                             value[4];
 };
 
index 052eb1cd6ddde93fa8c03a8cfd9e1288782f7771..edde80c660a0daae512e5545208888701c2a47ea 100644 (file)
@@ -54,15 +54,18 @@ void r600_flush(struct pipe_context *ctx, unsigned flags,
        /* FIXME dumping should be removed once shader support instructions
         * without throwing bad code
         */
+       if (!rctx->ctx->cpm4)
+               goto out;
        sprintf(dname, "gallium-%08d.bof", dc);
        if (dc < 1)
                radeon_ctx_dump_bof(rctx->ctx, dname);
 #if 1
        radeon_ctx_submit(rctx->ctx);
 #endif
+       dc++;
+out:
        rctx->ctx = radeon_ctx_decref(rctx->ctx);
        rctx->ctx = radeon_ctx(rscreen->rw);
-       dc++;
 }
 
 static void r600_init_config(struct r600_context *rctx)
index 00cff41b4fd3e3e7645845f9096f6901b630dd32..8f00a4895a0c82a184dc43158c3669aede8332dc 100644 (file)
@@ -156,6 +156,37 @@ int radeon_ctx_pm4(struct radeon_ctx *ctx);
 int radeon_ctx_submit(struct radeon_ctx *ctx);
 void radeon_ctx_dump_bof(struct radeon_ctx *ctx, const char *file);
 
+/*
+ * radeon context functions
+ */
+#pragma pack(1)
+struct radeon_cs_reloc {
+       uint32_t        handle;
+       uint32_t        read_domain;
+       uint32_t        write_domain;
+       uint32_t        flags;
+};
+#pragma pack()
+
+struct radeon_ctx {
+       int                             refcount;
+       struct radeon                   *radeon;
+       u32                             *pm4;
+       u32                             cpm4;
+       u32                             draw_cpm4;
+       unsigned                        id;
+       unsigned                        next_id;
+       unsigned                        nreloc;
+       struct radeon_cs_reloc          *reloc;
+       unsigned                        nbo;
+       struct radeon_bo                **bo;
+       unsigned                        ndraw;
+       struct radeon_draw              *cdraw;
+       struct radeon_draw              **draw;
+       unsigned                        nstate;
+       struct radeon_state             **state;
+};
+
 /*
  * R600/R700
  */
index 6b0eba0b28938cf72518e826e1fc715eac9fdf17..ff70ce6de7a8d1efd19222498e3df62fc333ec91 100644 (file)
@@ -151,6 +151,8 @@ int radeon_ctx_submit(struct radeon_ctx *ctx)
        uint64_t chunk_array[2];
        int r = 0;
 
+       if (!ctx->cpm4)
+               return 0;
 #if 0
        for (r = 0; r < ctx->cpm4; r++) {
                fprintf(stderr, "0x%08X\n", ctx->pm4[r]);
index b91421f43898b22e4a5065a6b9df0b7cf42e5323..96c0d060f7ea14c7662b52c5d696df004bcb70b7 100644 (file)
@@ -68,36 +68,6 @@ extern int radeon_is_family_compatible(unsigned family1, unsigned family2);
 extern int radeon_reg_id(struct radeon *radeon, unsigned offset, unsigned *typeid, unsigned *stateid, unsigned *id);
 extern unsigned radeon_type_from_id(struct radeon *radeon, unsigned id);
 
-/*
- * radeon context functions
- */
-#pragma pack(1)
-struct radeon_cs_reloc {
-       uint32_t        handle;
-       uint32_t        read_domain;
-       uint32_t        write_domain;
-       uint32_t        flags;
-};
-#pragma pack()
-
-struct radeon_ctx {
-       int                             refcount;
-       struct radeon                   *radeon;
-       u32                             *pm4;
-       u32                             cpm4;
-       u32                             draw_cpm4;
-       unsigned                        id;
-       unsigned                        next_id;
-       unsigned                        nreloc;
-       struct radeon_cs_reloc          *reloc;
-       unsigned                        nbo;
-       struct radeon_bo                **bo;
-       unsigned                        ndraw;
-       struct radeon_draw              *cdraw;
-       struct radeon_draw              **draw;
-       unsigned                        nstate;
-       struct radeon_state             **state;
-};
 
 int radeon_ctx_set_bo_new(struct radeon_ctx *ctx, struct radeon_bo *bo);
 struct radeon_bo *radeon_ctx_get_bo(struct radeon_ctx *ctx, unsigned reloc);