summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/r600/drm/radeon_state.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2010-08-27 15:45:58 +1000
committerDave Airlie <airlied@redhat.com>2010-08-27 15:45:58 +1000
commit2184f3ec3059eaf8a9a2b04c995162543f000862 (patch)
treee0d2e070b1688b56384d0deca0fb6ddf15a2787b /src/gallium/winsys/r600/drm/radeon_state.c
parenta03d456f5a41926e39194de70b2d50776e64b8a2 (diff)
Revert "r600g: simplify states"
This reverts commit bd25e23bf3740f59ce8859848c715daeb9e9821f. Apart from introducing a lot of hex magic numbers and being highly impenetable code, it causes lots of lockups on an average piglit run that always runs without lockups. Always run piglit before/after doing big things like this.
Diffstat (limited to 'src/gallium/winsys/r600/drm/radeon_state.c')
-rw-r--r--src/gallium/winsys/r600/drm/radeon_state.c56
1 files changed, 49 insertions, 7 deletions
diff --git a/src/gallium/winsys/r600/drm/radeon_state.c b/src/gallium/winsys/r600/drm/radeon_state.c
index c60b12ef67..308288557a 100644
--- a/src/gallium/winsys/r600/drm/radeon_state.c
+++ b/src/gallium/winsys/r600/drm/radeon_state.c
@@ -32,29 +32,52 @@
/*
* state core functions
*/
-struct radeon_state *radeon_state(struct radeon *radeon, u32 id)
+struct radeon_state *radeon_state(struct radeon *radeon, u32 type, u32 id)
{
struct radeon_state *state;
+ if (type > radeon->ntype) {
+ fprintf(stderr, "%s invalid type %d\n", __func__, type);
+ return NULL;
+ }
+ if (id > radeon->nstate) {
+ fprintf(stderr, "%s invalid state id %d\n", __func__, id);
+ return NULL;
+ }
state = calloc(1, sizeof(*state));
if (state == NULL)
return NULL;
state->radeon = radeon;
+ state->type = type;
state->id = id;
state->refcount = 1;
- state->cpm4 = radeon->type[id].state_cpm4;
- memcpy(state->states, radeon->type[id].state_pm4, radeon->type[id].state_cpm4 * 4);
+ state->npm4 = radeon->type[type].npm4;
+ state->nstates = radeon->type[type].nstates;
+ state->states = calloc(1, state->nstates * 4);
+ state->pm4 = calloc(1, radeon->type[type].npm4 * 4);
+ if (state->states == NULL || state->pm4 == NULL) {
+ radeon_state_decref(state);
+ return NULL;
+ }
return state;
}
struct radeon_state *radeon_state_duplicate(struct radeon_state *state)
{
- struct radeon_state *nstate = radeon_state(state->radeon, state->id);
+ struct radeon_state *nstate = radeon_state(state->radeon, state->type, state->id);
unsigned i;
if (state == NULL)
return NULL;
- *nstate = *state;
+ nstate->cpm4 = state->cpm4;
+ nstate->nbo = state->nbo;
+ nstate->nreloc = state->nreloc;
+ memcpy(nstate->states, state->states, state->nstates * 4);
+ memcpy(nstate->pm4, state->pm4, state->npm4 * 4);
+ memcpy(nstate->placement, state->placement, 8 * 4);
+ memcpy(nstate->reloc_pm4_id, state->reloc_pm4_id, 8 * 4);
+ memcpy(nstate->reloc_bo_id, state->reloc_bo_id, 8 * 4);
+ memcpy(nstate->bo_dirty, state->bo_dirty, 4 * 4);
for (i = 0; i < state->nbo; i++) {
nstate->bo[i] = radeon_bo_incref(state->radeon, state->bo[i]);
}
@@ -79,6 +102,9 @@ struct radeon_state *radeon_state_decref(struct radeon_state *state)
for (i = 0; i < state->nbo; i++) {
state->bo[i] = radeon_bo_decref(state->radeon, state->bo[i]);
}
+ free(state->immd);
+ free(state->states);
+ free(state->pm4);
memset(state, 0, sizeof(*state));
free(state);
return NULL;
@@ -119,8 +145,24 @@ static u32 crc32(void *d, size_t len)
int radeon_state_pm4(struct radeon_state *state)
{
- if (state == NULL)
+ int r;
+
+ if (state == NULL || state->cpm4)
return 0;
- state->pm4_crc = crc32(state->states, state->cpm4 * 4);
+ r = state->radeon->type[state->type].pm4(state);
+ if (r) {
+ fprintf(stderr, "%s failed to build PM4 for state(%d %d)\n",
+ __func__, state->type, state->id);
+ return r;
+ }
+ state->pm4_crc = crc32(state->pm4, state->cpm4 * 4);
+ return 0;
+}
+
+int radeon_state_reloc(struct radeon_state *state, unsigned id, unsigned bo_id)
+{
+ state->reloc_pm4_id[state->nreloc] = id;
+ state->reloc_bo_id[state->nreloc] = bo_id;
+ state->nreloc++;
return 0;
}