Mesa (master): r600g: reduce size of r600 context structure to !insane

Dave Airlie airlied at kemper.freedesktop.org
Fri Sep 3 03:54:33 UTC 2010


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Sep  3 13:53:39 2010 +1000

r600g: reduce size of r600 context structure to !insane

Its now about 7.8k, and might actually fit in a cache.

---

 src/gallium/drivers/r600/r600_context.c |   23 +++++++++++++++++++++++
 src/gallium/drivers/r600/r600_context.h |    9 ++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_context.c b/src/gallium/drivers/r600/r600_context.c
index 7a0e5b4..9525f15 100644
--- a/src/gallium/drivers/r600/r600_context.c
+++ b/src/gallium/drivers/r600/r600_context.c
@@ -53,6 +53,11 @@ static void r600_destroy_context(struct pipe_context *context)
 	rctx->stencil_ref = r600_context_state_decref(rctx->stencil_ref);
 	rctx->viewport = r600_context_state_decref(rctx->viewport);
 	rctx->framebuffer = r600_context_state_decref(rctx->framebuffer);
+
+	free(rctx->ps_constant);
+	free(rctx->vs_constant);
+	free(rctx->vs_resource);
+
 	radeon_ctx_fini(&rctx->ctx);
 	FREE(rctx);
 }
@@ -354,6 +359,24 @@ struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
 
 	r600_init_config(rctx);
 
+	rctx->vs_constant = (struct radeon_state *)calloc(R600_MAX_CONSTANT, sizeof(struct radeon_state));
+	if (!rctx->vs_constant) {
+		FREE(rctx);
+		return NULL;
+	}
+
+	rctx->ps_constant = (struct radeon_state *)calloc(R600_MAX_CONSTANT, sizeof(struct radeon_state));
+	if (!rctx->ps_constant) {
+		FREE(rctx);
+		return NULL;
+	}
+
+	rctx->vs_resource = (struct radeon_state *)calloc(R600_MAX_RESOURCE, sizeof(struct radeon_state));
+	if (!rctx->vs_resource) {
+		FREE(rctx);
+		return NULL;
+	}						   
+
 	radeon_ctx_init(&rctx->ctx, 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 6294f7a..1c32ced 100644
--- a/src/gallium/drivers/r600/r600_context.h
+++ b/src/gallium/drivers/r600/r600_context.h
@@ -121,6 +121,9 @@ struct r600_context_hw_states {
 	struct radeon_state	cb_cntl;
 };
 
+#define R600_MAX_CONSTANT 256 /* magic */
+#define R600_MAX_RESOURCE 160 /* magic */
+
 struct r600_context {
 	struct pipe_context		context;
 	struct r600_screen		*screen;
@@ -130,10 +133,10 @@ struct r600_context {
 	struct radeon_draw		draw;
 	struct radeon_state		config;
 	/* FIXME get rid of those vs_resource,vs/ps_constant */
-	struct radeon_state		vs_resource[160];
+	struct radeon_state		*vs_resource;
 	unsigned			vs_nresource;
-	struct radeon_state		vs_constant[256];
-	struct radeon_state		ps_constant[256];
+	struct radeon_state		*vs_constant;
+	struct radeon_state		*ps_constant;
 	/* hw states */
 	struct r600_context_hw_states	hw_states;
 	/* pipe states */




More information about the mesa-commit mailing list