r600g: hide radeon_ctx inside winsys.
authorDave Airlie <airlied@redhat.com>
Thu, 16 Sep 2010 07:18:39 +0000 (17:18 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 17 Sep 2010 00:57:44 +0000 (10:57 +1000)
no need for this info to be exported to pipe driver.

src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_context.c
src/gallium/drivers/r600/r600_context.h
src/gallium/drivers/r600/r600_draw.c
src/gallium/drivers/r600/r600_query.c
src/gallium/drivers/r600/radeon.h
src/gallium/winsys/r600/drm/radeon_ctx.c
src/gallium/winsys/r600/drm/radeon_priv.h

index e6b3be6d3bf741082202a5244076382cd255b7ab..2c22adb62a4e93bedf3564796d23d048e4e0a644 100644 (file)
@@ -570,10 +570,10 @@ int r600_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_te
        r600_queries_suspend(ctx);
 
        /* schedule draw*/
-       r = radeon_ctx_set_draw(&rctx->ctx, &draw);
+       r = radeon_ctx_set_draw(rctx->ctx, &draw);
        if (r == -EBUSY) {
                r600_flush(ctx, 0, NULL);
-               r = radeon_ctx_set_draw(&rctx->ctx, &draw);
+               r = radeon_ctx_set_draw(rctx->ctx, &draw);
        }
        if (r) {
                goto out;
index 00df4dcd4286087a249c9a7013284f97f3147cfe..2ec25548e3c0c650bf18187039e14a5a2c486b4d 100644 (file)
@@ -56,7 +56,7 @@ static void r600_destroy_context(struct pipe_context *context)
        free(rctx->vs_constant);
        free(rctx->vs_resource);
 
-       radeon_ctx_fini(&rctx->ctx);
+       radeon_ctx_fini(rctx->ctx);
        FREE(rctx);
 }
 
@@ -65,34 +65,17 @@ void r600_flush(struct pipe_context *ctx, unsigned flags,
 {
        struct r600_context *rctx = r600_context(ctx);
        struct r600_query *rquery = NULL;
-       static int dc = 0;
-#if 0
-       char dname[256];
-#endif
 
        /* suspend queries */
        r600_queries_suspend(ctx);
-       /* FIXME dumping should be removed once shader support instructions
-        * without throwing bad code
-        */
-       if (!rctx->ctx.cdwords)
-               goto out;
-#if 0
-       sprintf(dname, "gallium-%08d.bof", dc);
-       if (dc < 2) {
-               radeon_ctx_dump_bof(&rctx->ctx, dname);
-               R600_ERR("dumped %s\n", dname);
-       }
-#endif
-#if 1
-       radeon_ctx_submit(&rctx->ctx);
-#endif
+
+       radeon_ctx_submit(rctx->ctx);
+
        LIST_FOR_EACH_ENTRY(rquery, &rctx->query_list, list) {
                rquery->flushed = true;
        }
-       dc++;
-out:
-       radeon_ctx_clear(&rctx->ctx);
+
+       radeon_ctx_clear(rctx->ctx);
        /* resume queries */
        r600_queries_resume(ctx);
 }
@@ -151,7 +134,7 @@ struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
                return NULL;
        }                                                  
 
-       radeon_ctx_init(&rctx->ctx, rscreen->rw);
+       rctx->ctx = radeon_ctx_init(rscreen->rw);
        radeon_draw_init(&rctx->draw, rscreen->rw);
        return &rctx->context;
 }
index 6d4a554b9984ee366ac3afc93166af6c54eab19f..73037fdb1b30ec918d6461c92af15b4036d5c841 100644 (file)
@@ -210,7 +210,7 @@ struct r600_context {
        struct pipe_context             context;
        struct r600_screen              *screen;
        struct radeon                   *rw;
-       struct radeon_ctx               ctx;
+       struct radeon_ctx               *ctx;
        struct blitter_context          *blitter;
        struct radeon_draw              draw;
        struct r600_context_hw_state_vtbl *vtbl;
index d0de1658ba18db2c781b70f5d6c43c527cbd6cab..669c9b4cdb62d3c37e3f0eb1e824bf46fef05881 100644 (file)
@@ -105,10 +105,10 @@ static int r600_draw_common(struct r600_draw *draw)
        rctx->vtbl->vgt_prim(draw, prim, vgt_dma_index_type);
        radeon_draw_bind(&rctx->draw, &draw->vgt);
 
-       r = radeon_ctx_set_draw(&rctx->ctx, &rctx->draw);
+       r = radeon_ctx_set_draw(rctx->ctx, &rctx->draw);
        if (r == -EBUSY) {
                r600_flush(draw->ctx, 0, NULL);
-               r = radeon_ctx_set_draw(&rctx->ctx, &rctx->draw);
+               r = radeon_ctx_set_draw(rctx->ctx, &rctx->draw);
        }
 
        radeon_state_fini(&draw->draw);
index 0073072b4afd9d7ac29dd9d31adc2e96966691e6..68358f9dd718d519b11c2814b3dbe94819c685b9 100644 (file)
@@ -155,12 +155,12 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
        rquery->num_results = 0;
        rquery->flushed = false;
        r600_query_resume(ctx, rquery);
-       r = radeon_ctx_set_query_state(&rctx->ctx, &rquery->rstate);
+       r = radeon_ctx_set_query_state(rctx->ctx, &rquery->rstate);
        if (r == -EBUSY) {
                /* this shouldn't happen */
                R600_ERR("had to flush while emitting end query\n");
                ctx->flush(ctx, 0, NULL);
-               r = radeon_ctx_set_query_state(&rctx->ctx, &rquery->rstate);
+               r = radeon_ctx_set_query_state(rctx->ctx, &rquery->rstate);
        }
 }
 
@@ -173,12 +173,12 @@ static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query)
        rquery->state &= ~R600_QUERY_STATE_STARTED;
        rquery->state |= R600_QUERY_STATE_ENDED;
        r600_query_suspend(ctx, rquery);
-       r = radeon_ctx_set_query_state(&rctx->ctx, &rquery->rstate);
+       r = radeon_ctx_set_query_state(rctx->ctx, &rquery->rstate);
        if (r == -EBUSY) {
                /* this shouldn't happen */
                R600_ERR("had to flush while emitting end query\n");
                ctx->flush(ctx, 0, NULL);
-               r = radeon_ctx_set_query_state(&rctx->ctx, &rquery->rstate);
+               r = radeon_ctx_set_query_state(rctx->ctx, &rquery->rstate);
        }
 }
 
@@ -191,12 +191,12 @@ void r600_queries_suspend(struct pipe_context *ctx)
        LIST_FOR_EACH_ENTRY(rquery, &rctx->query_list, list) {
                if (rquery->state & R600_QUERY_STATE_STARTED) {
                        r600_query_suspend(ctx, rquery);
-                       r = radeon_ctx_set_query_state(&rctx->ctx, &rquery->rstate);
+                       r = radeon_ctx_set_query_state(rctx->ctx, &rquery->rstate);
                        if (r == -EBUSY) {
                                /* this shouldn't happen */
                                R600_ERR("had to flush while emitting end query\n");
                                ctx->flush(ctx, 0, NULL);
-                               r = radeon_ctx_set_query_state(&rctx->ctx, &rquery->rstate);
+                               r = radeon_ctx_set_query_state(rctx->ctx, &rquery->rstate);
                        }
                }
                rquery->state |= R600_QUERY_STATE_SUSPENDED;
@@ -212,12 +212,12 @@ void r600_queries_resume(struct pipe_context *ctx)
        LIST_FOR_EACH_ENTRY(rquery, &rctx->query_list, list) {
                if (rquery->state & R600_QUERY_STATE_STARTED) {
                        r600_query_resume(ctx, rquery);
-                       r = radeon_ctx_set_query_state(&rctx->ctx, &rquery->rstate);
+                       r = radeon_ctx_set_query_state(rctx->ctx, &rquery->rstate);
                        if (r == -EBUSY) {
                                /* this shouldn't happen */
                                R600_ERR("had to flush while emitting end query\n");
                                ctx->flush(ctx, 0, NULL);
-                               r = radeon_ctx_set_query_state(&rctx->ctx, &rquery->rstate);
+                               r = radeon_ctx_set_query_state(rctx->ctx, &rquery->rstate);
                        }
                }
                rquery->state &= ~R600_QUERY_STATE_SUSPENDED;
index 7991821ddab95950b8cf64edf8911e0cce46a96b..12e8b993c8fed2d399f98b63dc111752440c38ec 100644 (file)
@@ -161,18 +161,9 @@ struct radeon_cs_reloc {
 };
 #pragma pack()
 
-struct radeon_ctx {
-       struct radeon                   *radeon;
-       u32                             *pm4;
-       int                             cdwords;
-       int                             ndwords;
-       unsigned                        nreloc;
-       struct radeon_cs_reloc          *reloc;
-       unsigned                        nbo;
-       struct radeon_bo                **bo;
-};
+struct radeon_ctx;
 
-int radeon_ctx_init(struct radeon_ctx *ctx, struct radeon *radeon);
+struct radeon_ctx *radeon_ctx_init(struct radeon *radeon);
 void radeon_ctx_fini(struct radeon_ctx *ctx);
 void radeon_ctx_clear(struct radeon_ctx *ctx);
 int radeon_ctx_set_draw(struct radeon_ctx *ctx, struct radeon_draw *draw);
index a3ce7df75621a6626ef1a9a26bb46f9cd57c13cd..9f166b209a165643b935a4256a2d7d0697b92bea 100644 (file)
@@ -82,29 +82,30 @@ void radeon_ctx_clear(struct radeon_ctx *ctx)
        ctx->nbo = 0;
 }
 
-int radeon_ctx_init(struct radeon_ctx *ctx, struct radeon *radeon)
+struct radeon_ctx *radeon_ctx_init(struct radeon *radeon)
 {
+       struct radeon_ctx *ctx;
        if (radeon == NULL)
-               return -EINVAL;
-       memset(ctx, 0, sizeof(struct radeon_ctx));
+               return NULL;
+       ctx = calloc(1, sizeof(struct radeon_ctx));
        ctx->radeon = radeon_incref(radeon);
        radeon_ctx_clear(ctx);
        ctx->pm4 = malloc(RADEON_CTX_MAX_PM4 * 4);
        if (ctx->pm4 == NULL) {
                radeon_ctx_fini(ctx);
-               return -ENOMEM;
+               return NULL;
        }
        ctx->reloc = malloc(sizeof(struct radeon_cs_reloc) * RADEON_CTX_MAX_PM4);
        if (ctx->reloc == NULL) {
                radeon_ctx_fini(ctx);
-               return -ENOMEM;
+               return NULL;
        }
        ctx->bo = malloc(sizeof(void *) * RADEON_CTX_MAX_PM4);
        if (ctx->bo == NULL) {
                radeon_ctx_fini(ctx);
-               return -ENOMEM;
+               return NULL;
        }
-       return 0;
+       return ctx;
 }
 
 void radeon_ctx_fini(struct radeon_ctx *ctx)
@@ -121,7 +122,7 @@ void radeon_ctx_fini(struct radeon_ctx *ctx)
        free(ctx->bo);
        free(ctx->pm4);
        free(ctx->reloc);
-       memset(ctx, 0, sizeof(struct radeon_ctx));
+       free(ctx);
 }
 
 static int radeon_ctx_state_bo(struct radeon_ctx *ctx, struct radeon_state *state)
index bcaa91d02880f0bfee9c33f05abf25dcc147643f..b5a4eeae6bac96c690a7b4b4cfba43cc69bd39a0 100644 (file)
@@ -53,6 +53,17 @@ struct radeon_stype_info {
        unsigned                        npm4;
 };
 
+struct radeon_ctx {
+       struct radeon                   *radeon;
+       u32                             *pm4;
+       int                             cdwords;
+       int                             ndwords;
+       unsigned                        nreloc;
+       struct radeon_cs_reloc          *reloc;
+       unsigned                        nbo;
+       struct radeon_bo                **bo;
+};
+
 struct radeon {
        int                             fd;
        int                             refcount;