diff options
author | Dave Airlie <[email protected]> | 2010-09-10 22:41:00 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2010-09-10 22:41:00 +1000 |
commit | fcae8ca57512f84c51b7445456aab7ec92a21254 (patch) | |
tree | 238b9b1af10697b14c721f65c6e756969954a277 /src/gallium | |
parent | f61b241ebabf2d8db9b96f7860afe79bec980df7 (diff) |
r600g: fixup state calculations for picking states.
for evergreen I ended up using a non-contig array of states, but
this code needs a bit of fixing up to deal with that.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/r600/radeon.h | 1 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/r600_state.c | 1 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon.c | 15 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_ctx.c | 19 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_draw.c | 2 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_priv.h | 3 | ||||
-rw-r--r-- | src/gallium/winsys/r600/drm/radeon_state.c | 4 |
7 files changed, 16 insertions, 29 deletions
diff --git a/src/gallium/drivers/r600/radeon.h b/src/gallium/drivers/r600/radeon.h index cd063e4a94c..7991821ddab 100644 --- a/src/gallium/drivers/r600/radeon.h +++ b/src/gallium/drivers/r600/radeon.h @@ -214,6 +214,7 @@ enum r600_stype { R600_STATE_DRAW, R600_STATE_CB_FLUSH, R600_STATE_DB_FLUSH, + R600_STATE_MAX, }; #include "r600_states_inc.h" diff --git a/src/gallium/winsys/r600/drm/r600_state.c b/src/gallium/winsys/r600/drm/r600_state.c index 4a0111b6c5f..b8ef89dfd67 100644 --- a/src/gallium/winsys/r600/drm/r600_state.c +++ b/src/gallium/winsys/r600/drm/r600_state.c @@ -632,6 +632,7 @@ static void build_types_array(struct radeon *radeon, struct radeon_stype_info *t } } } + radeon->max_states = id; radeon->stype = types; radeon->nstype = size; } diff --git a/src/gallium/winsys/r600/drm/radeon.c b/src/gallium/winsys/r600/drm/radeon.c index 64ccc7db877..ccf60605ed8 100644 --- a/src/gallium/winsys/r600/drm/radeon.c +++ b/src/gallium/winsys/r600/drm/radeon.c @@ -45,7 +45,7 @@ static int radeon_get_device(struct radeon *radeon) struct radeon *radeon_new(int fd, unsigned device) { struct radeon *radeon; - int r, i, id; + int r, i, id, j, k; radeon = calloc(1, sizeof(*radeon)); if (radeon == NULL) { @@ -120,19 +120,6 @@ struct radeon *radeon_new(int fd, unsigned device) __func__, radeon->device); break; } - radeon->state_type_id = calloc(radeon->nstype, sizeof(unsigned)); - if (radeon->state_type_id == NULL) { - return radeon_decref(radeon); - } - for (i = 0, id = 0; i < radeon->nstype; i++) { - radeon->state_type_id[i] = id; - for (int j = 0; j < radeon->nstype; j++) { - if (radeon->stype[j].stype != i) - continue; - id += radeon->stype[j].num; - } - } - radeon->nstate_per_shader = id; return radeon; } diff --git a/src/gallium/winsys/r600/drm/radeon_ctx.c b/src/gallium/winsys/r600/drm/radeon_ctx.c index 5d9cdca112e..bd0916aeb0b 100644 --- a/src/gallium/winsys/r600/drm/radeon_ctx.c +++ b/src/gallium/winsys/r600/drm/radeon_ctx.c @@ -259,25 +259,24 @@ int radeon_ctx_set_draw(struct radeon_ctx *ctx, struct radeon_draw *draw) { unsigned previous_cdwords; int r = 0; + int i; - for (int i = 0; i < (ctx->radeon->nstate_per_shader * R600_SHADER_MAX); i++) { + for (i = 0; i < ctx->radeon->max_states; i++) { r = radeon_ctx_state_bo(ctx, draw->state[i]); if (r) return r; } previous_cdwords = ctx->cdwords; - for (int i = 0, id = 0; i < ctx->radeon->nstate_per_shader; i++) { - for (int j = 0; j < R600_SHADER_MAX; j++) { - id = j * ctx->radeon->nstate_per_shader + i; - if (draw->state[id]) { - r = radeon_ctx_state_schedule(ctx, draw->state[id]); - if (r) { - ctx->cdwords = previous_cdwords; - return r; - } + for (i = 0; i < ctx->radeon->max_states; i++) { + if (draw->state[i]) { + r = radeon_ctx_state_schedule(ctx, draw->state[i]); + if (r) { + ctx->cdwords = previous_cdwords; + return r; } } } + return 0; } diff --git a/src/gallium/winsys/r600/drm/radeon_draw.c b/src/gallium/winsys/r600/drm/radeon_draw.c index b992c4a55dc..a1269014958 100644 --- a/src/gallium/winsys/r600/drm/radeon_draw.c +++ b/src/gallium/winsys/r600/drm/radeon_draw.c @@ -34,7 +34,7 @@ int radeon_draw_init(struct radeon_draw *draw, struct radeon *radeon) { draw->radeon = radeon; - draw->state = calloc(radeon->nstate_per_shader * R600_SHADER_MAX, sizeof(void*)); + draw->state = calloc(radeon->max_states, sizeof(void*)); if (draw->state == NULL) return -ENOMEM; return 0; diff --git a/src/gallium/winsys/r600/drm/radeon_priv.h b/src/gallium/winsys/r600/drm/radeon_priv.h index 84e552ba4d3..bcaa91d0288 100644 --- a/src/gallium/winsys/r600/drm/radeon_priv.h +++ b/src/gallium/winsys/r600/drm/radeon_priv.h @@ -59,9 +59,8 @@ struct radeon { unsigned device; unsigned family; unsigned nstype; - unsigned nstate_per_shader; - unsigned *state_type_id; struct radeon_stype_info *stype; + unsigned max_states; }; extern struct radeon *radeon_new(int fd, unsigned device); diff --git a/src/gallium/winsys/r600/drm/radeon_state.c b/src/gallium/winsys/r600/drm/radeon_state.c index ac60485b280..e37e7145339 100644 --- a/src/gallium/winsys/r600/drm/radeon_state.c +++ b/src/gallium/winsys/r600/drm/radeon_state.c @@ -70,8 +70,8 @@ int radeon_state_init(struct radeon_state *state, struct radeon *radeon, u32 sty } memset(state, 0, sizeof(struct radeon_state)); - state->state_id = radeon->nstate_per_shader * shader_index + radeon->state_type_id[stype] + id; state->stype = found; + state->state_id = state->stype->num * shader_index + state->stype->base_id + id; state->radeon = radeon; state->id = id; state->shader_index = shader_index; @@ -128,7 +128,7 @@ int radeon_state_convert(struct radeon_state *state, u32 stype, u32 id, u32 shad state->stype = found; state->id = id; state->shader_index = shader_index; - state->state_id = state->radeon->nstate_per_shader * shader_index + state->radeon->state_type_id[stype] + id; + state->state_id = state->stype->num * shader_index + state->stype->base_id + id; return radeon_state_pm4(state); } |