R600_STATE_DRAW,
R600_STATE_CB_FLUSH,
R600_STATE_DB_FLUSH,
+ R600_STATE_MAX,
};
#include "r600_states_inc.h"
}
}
}
+ radeon->max_states = id;
radeon->stype = types;
radeon->nstype = size;
}
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) {
__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;
}
{
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;
}
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;
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);
}
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;
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);
}