Mesa (master): r600g: hide radeon_ctx inside winsys.

Dave Airlie airlied at kemper.freedesktop.org
Fri Sep 17 01:04:25 UTC 2010


Module: Mesa
Branch: master
Commit: ec9d838aa56d2c4bc5649d7c26ac61abb6c4b9bb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ec9d838aa56d2c4bc5649d7c26ac61abb6c4b9bb

Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Sep 16 17:18:39 2010 +1000

r600g: hide radeon_ctx inside winsys.

no need for this info to be exported to pipe driver.

---

 src/gallium/drivers/r600/r600_blit.c      |    4 +-
 src/gallium/drivers/r600/r600_context.c   |   31 ++++++----------------------
 src/gallium/drivers/r600/r600_context.h   |    2 +-
 src/gallium/drivers/r600/r600_draw.c      |    4 +-
 src/gallium/drivers/r600/r600_query.c     |   16 +++++++-------
 src/gallium/drivers/r600/radeon.h         |   13 +----------
 src/gallium/winsys/r600/drm/radeon_ctx.c  |   17 ++++++++-------
 src/gallium/winsys/r600/drm/radeon_priv.h |   11 ++++++++++
 8 files changed, 42 insertions(+), 56 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index e6b3be6..2c22adb 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -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;
diff --git a/src/gallium/drivers/r600/r600_context.c b/src/gallium/drivers/r600/r600_context.c
index 00df4dc..2ec2554 100644
--- a/src/gallium/drivers/r600/r600_context.c
+++ b/src/gallium/drivers/r600/r600_context.c
@@ -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;
 }
diff --git a/src/gallium/drivers/r600/r600_context.h b/src/gallium/drivers/r600/r600_context.h
index 6d4a554..73037fd 100644
--- a/src/gallium/drivers/r600/r600_context.h
+++ b/src/gallium/drivers/r600/r600_context.h
@@ -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;
diff --git a/src/gallium/drivers/r600/r600_draw.c b/src/gallium/drivers/r600/r600_draw.c
index d0de165..669c9b4 100644
--- a/src/gallium/drivers/r600/r600_draw.c
+++ b/src/gallium/drivers/r600/r600_draw.c
@@ -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);
diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c
index 0073072..68358f9 100644
--- a/src/gallium/drivers/r600/r600_query.c
+++ b/src/gallium/drivers/r600/r600_query.c
@@ -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;
diff --git a/src/gallium/drivers/r600/radeon.h b/src/gallium/drivers/r600/radeon.h
index 7991821..12e8b99 100644
--- a/src/gallium/drivers/r600/radeon.h
+++ b/src/gallium/drivers/r600/radeon.h
@@ -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);
diff --git a/src/gallium/winsys/r600/drm/radeon_ctx.c b/src/gallium/winsys/r600/drm/radeon_ctx.c
index a3ce7df..9f166b2 100644
--- a/src/gallium/winsys/r600/drm/radeon_ctx.c
+++ b/src/gallium/winsys/r600/drm/radeon_ctx.c
@@ -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)
diff --git a/src/gallium/winsys/r600/drm/radeon_priv.h b/src/gallium/winsys/r600/drm/radeon_priv.h
index bcaa91d..b5a4eea 100644
--- a/src/gallium/winsys/r600/drm/radeon_priv.h
+++ b/src/gallium/winsys/r600/drm/radeon_priv.h
@@ -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;




More information about the mesa-commit mailing list