summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600/r600_query.c
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2010-08-30 17:56:59 -0400
committerJerome Glisse <jglisse@redhat.com>2010-09-01 13:16:23 -0400
commit66e4cb1cd5a55402606a09417349d2be8b009e89 (patch)
treeb9c4e20211fbfc1a979667598f141116f4a5cebd /src/gallium/drivers/r600/r600_query.c
parent15ce70252c5357081a61f3494261c7e343174301 (diff)
downloadexternal_mesa3d-66e4cb1cd5a55402606a09417349d2be8b009e89.zip
external_mesa3d-66e4cb1cd5a55402606a09417349d2be8b009e89.tar.gz
external_mesa3d-66e4cb1cd5a55402606a09417349d2be8b009e89.tar.bz2
r600g: avoid dynamic allocation of states
Make state statically allocated, this kills a bunch of code and avoid intensive use of malloc/free. There is still a lot of useless duplicate function wrapping that can be kill. This doesn't improve yet performance, needs to avoid memcpy states in radeon_ctx_set_draw and to avoid rebuilding vs_resources, dsa, scissor, cb_cntl, ... states at each draw command. Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Diffstat (limited to 'src/gallium/drivers/r600/r600_query.c')
-rw-r--r--src/gallium/drivers/r600/r600_query.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c
index af85710..530940e 100644
--- a/src/gallium/drivers/r600/r600_query.c
+++ b/src/gallium/drivers/r600/r600_query.c
@@ -31,42 +31,36 @@
#include "r600_screen.h"
#include "r600_context.h"
-static struct radeon_state *r600_query_begin(struct r600_context *rctx, struct r600_query *rquery)
+static void r600_query_begin(struct r600_context *rctx, struct r600_query *rquery)
{
struct r600_screen *rscreen = rctx->screen;
- struct radeon_state *rstate;
+ struct radeon_state *rstate = &rquery->rstate;
- rstate = radeon_state(rscreen->rw, R600_STATE_QUERY_BEGIN, 0);
- if (rstate == NULL)
- return NULL;
+ radeon_state_fini(rstate);
+ radeon_state_init(rstate, rscreen->rw, R600_STATE_QUERY_BEGIN, 0, 0);
rstate->states[R600_QUERY__OFFSET] = rquery->num_results;
rstate->bo[0] = radeon_bo_incref(rscreen->rw, rquery->buffer);
rstate->nbo = 1;
rstate->placement[0] = RADEON_GEM_DOMAIN_GTT;
if (radeon_state_pm4(rstate)) {
- radeon_state_decref(rstate);
- return NULL;
+ radeon_state_fini(rstate);
}
- return rstate;
}
-static struct radeon_state *r600_query_end(struct r600_context *rctx, struct r600_query *rquery)
+static void r600_query_end(struct r600_context *rctx, struct r600_query *rquery)
{
struct r600_screen *rscreen = rctx->screen;
- struct radeon_state *rstate;
+ struct radeon_state *rstate = &rquery->rstate;
- rstate = radeon_state(rscreen->rw, R600_STATE_QUERY_END, 0);
- if (rstate == NULL)
- return NULL;
+ radeon_state_fini(rstate);
+ radeon_state_init(rstate, rscreen->rw, R600_STATE_QUERY_END, 0, 0);
rstate->states[R600_QUERY__OFFSET] = rquery->num_results + 8;
rstate->bo[0] = radeon_bo_incref(rscreen->rw, rquery->buffer);
rstate->nbo = 1;
rstate->placement[0] = RADEON_GEM_DOMAIN_GTT;
if (radeon_state_pm4(rstate)) {
- radeon_state_decref(rstate);
- return NULL;
+ radeon_state_fini(rstate);
}
- return rstate;
}
static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned query_type)
@@ -137,8 +131,7 @@ static void r600_query_resume(struct pipe_context *ctx, struct r600_query *rquer
}
r600_query_result(ctx, rquery);
}
- rquery->rstate = radeon_state_decref(rquery->rstate);
- rquery->rstate = r600_query_begin(rctx, rquery);
+ r600_query_begin(rctx, rquery);
rquery->flushed = false;
}
@@ -146,8 +139,7 @@ static void r600_query_suspend(struct pipe_context *ctx, struct r600_query *rque
{
struct r600_context *rctx = r600_context(ctx);
- rquery->rstate = radeon_state_decref(rquery->rstate);
- rquery->rstate = r600_query_end(rctx, rquery);
+ r600_query_end(rctx, rquery);
rquery->num_results += 16;
}
@@ -161,12 +153,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);
}
}
@@ -179,12 +171,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);
}
}
@@ -197,12 +189,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;
@@ -218,12 +210,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;