cell: Don't segfault when unbinding alpha / stencil / depth test state

This commit is contained in:
Ian Romanick 2008-03-17 16:09:28 -07:00
parent 9f106a8683
commit 9f93e67019
3 changed files with 29 additions and 13 deletions

View file

@ -116,7 +116,7 @@ cell_bind_depth_stencil_alpha_state(struct pipe_context *pipe,
draw_flush(cell->draw);
if (cdsa->code.store == NULL) {
if ((cdsa != NULL) && (cdsa->code.store == NULL)) {
cell_generate_depth_stencil_test(cdsa);
}

View file

@ -74,11 +74,18 @@ cell_emit_state(struct cell_context *cell)
struct cell_command_depth_stencil_alpha_test dsat;
dsat.base = (intptr_t) cell->depth_stencil->code.store;
dsat.size = (char *) cell->depth_stencil->code.csr
- (char *) cell->depth_stencil->code.store;
dsat.read_depth = TRUE;
dsat.read_stencil = FALSE;
if (cell->depth_stencil != NULL) {
dsat.base = (intptr_t) cell->depth_stencil->code.store;
dsat.size = (char *) cell->depth_stencil->code.csr
- (char *) cell->depth_stencil->code.store;
dsat.read_depth = TRUE;
dsat.read_stencil = FALSE;
} else {
dsat.base = 0;
dsat.size = 0;
dsat.read_depth = FALSE;
dsat.read_stencil = FALSE;
}
{
uint32_t *p = cell->depth_stencil->code.store;

View file

@ -260,13 +260,22 @@ cmd_state_depth_stencil(const struct cell_command_depth_stencil_alpha_test *stat
ASSERT_ALIGN16(state->base);
mfc_get(depth_stencil_code_buffer,
(unsigned int) state->base, /* src */
ROUNDUP16(state->size),
TAG_BATCH_BUFFER,
0, /* tid */
0 /* rid */);
wait_on_mask(1 << TAG_BATCH_BUFFER);
if (state->size != 0) {
mfc_get(depth_stencil_code_buffer,
(unsigned int) state->base, /* src */
ROUNDUP16(state->size),
TAG_BATCH_BUFFER,
0, /* tid */
0 /* rid */);
wait_on_mask(1 << TAG_BATCH_BUFFER);
} else {
/* If there is no code, emit a return instruction.
*/
depth_stencil_code_buffer[0] = 0x35;
depth_stencil_code_buffer[1] = 0x00;
depth_stencil_code_buffer[2] = 0x00;
depth_stencil_code_buffer[3] = 0x00;
}
spu.frag_test = (frag_test_func) depth_stencil_code_buffer;
spu.read_depth = state->read_depth;