From 1e9ffb63401b7bdaf05c53e07b588128566b437d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 10 Jan 2010 23:02:48 -0800 Subject: [PATCH] r300g: Atomize scissors. Argfl. Some of this code is so questionable. --- src/gallium/drivers/r300/r300_context.c | 5 +++-- src/gallium/drivers/r300/r300_context.h | 3 +-- src/gallium/drivers/r300/r300_emit.c | 9 ++------- src/gallium/drivers/r300/r300_emit.h | 3 +-- src/gallium/drivers/r300/r300_render.c | 2 +- src/gallium/drivers/r300/r300_state.c | 26 ++++++++++++++------------ 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index f003451..af95bbe7 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -73,7 +73,7 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->blend_color_state.state); FREE(r300->clip_state.state); FREE(r300->rs_block); - FREE(r300->scissor_state); + FREE(r300->scissor_state.state); FREE(r300->vertex_info); FREE(r300->viewport_state.state); FREE(r300->ztop_state.state); @@ -125,6 +125,7 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(clip); R300_INIT_ATOM(dsa); R300_INIT_ATOM(rs); + R300_INIT_ATOM(scissor); R300_INIT_ATOM(viewport); } @@ -181,7 +182,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); r300->clip_state.state = CALLOC_STRUCT(pipe_clip_state); r300->rs_block = CALLOC_STRUCT(r300_rs_block); - r300->scissor_state = CALLOC_STRUCT(r300_scissor_state); + r300->scissor_state.state = CALLOC_STRUCT(r300_scissor_state); r300->vertex_info = CALLOC_STRUCT(r300_vertex_info); r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 05ea7ad..70a04d6 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -145,7 +145,6 @@ struct r300_ztop_state { #define R300_NEW_RS_BLOCK 0x00000100 #define R300_NEW_SAMPLER 0x00000200 #define R300_ANY_NEW_SAMPLERS 0x0001fe00 -#define R300_NEW_SCISSOR 0x00020000 #define R300_NEW_TEXTURE 0x00040000 #define R300_ANY_NEW_TEXTURES 0x03fc0000 #define R300_NEW_VERTEX_FORMAT 0x04000000 @@ -295,7 +294,7 @@ struct r300_context { struct r300_sampler_state* sampler_states[8]; int sampler_count; /* Scissor state. */ - struct r300_scissor_state* scissor_state; + struct r300_atom scissor_state; /* Texture states. */ struct r300_texture* textures[8]; int texture_count; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 86d4000..0e5533c 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -653,9 +653,9 @@ static void r300_emit_scissor_regs(struct r300_context* r300, END_CS; } -void r300_emit_scissor_state(struct r300_context* r300, - struct r300_scissor_state* scissor) +void r300_emit_scissor_state(struct r300_context* r300, void* state) { + struct r300_scissor_state* scissor = (struct r300_scissor_state*)state; /* XXX argfl! */ if (((struct r300_rs_state*)r300->rs_state.state)->rs.scissor) { r300_emit_scissor_regs(r300, &scissor->scissor); @@ -1108,11 +1108,6 @@ validate: r300->dirty_state &= ~R300_NEW_RS_BLOCK; } - if (r300->dirty_state & R300_NEW_SCISSOR) { - r300_emit_scissor_state(r300, r300->scissor_state); - r300->dirty_state &= ~R300_NEW_SCISSOR; - } - /* Samplers and textures are tracked separately but emitted together. */ if (r300->dirty_state & (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) { diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 1a76de0..05a6bfe 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -64,8 +64,7 @@ void r300_emit_rs_state(struct r300_context* r300, void* state); void r300_emit_rs_block_state(struct r300_context* r300, struct r300_rs_block* rs); -void r300_emit_scissor_state(struct r300_context* r300, - struct r300_scissor_state* scissor); +void r300_emit_scissor_state(struct r300_context* r300, void* state); void r300_emit_texture(struct r300_context* r300, struct r300_sampler_state* sampler, diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 7098f66..2bd3ace 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -72,7 +72,7 @@ uint32_t r300_translate_primitive(unsigned prim) static boolean r300_nothing_to_draw(struct r300_context *r300) { return ((struct r300_rs_state*)r300->rs_state.state)->rs.scissor && - r300->scissor_state->scissor.empty_area; + ((struct r300_scissor_state*)r300->scissor_state.state)->scissor.empty_area; } static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index da1f40c..86773ad 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -504,7 +504,9 @@ static void const struct pipe_framebuffer_state* state) { struct r300_context* r300 = r300_context(pipe); - struct pipe_scissor_state scissor; + struct r300_scissor_state* scissor = + (struct r300_scissor_state*)r300->scissor_state.state; + struct pipe_scissor_state pscissor; if (r300->draw) { draw_flush(r300->draw); @@ -512,21 +514,19 @@ static void r300->framebuffer_state = *state; - scissor.minx = scissor.miny = 0; - scissor.maxx = state->width; - scissor.maxy = state->height; - r300_set_scissor_regs(&scissor, &r300->scissor_state->framebuffer, + /* XXX Arg. This is silly. */ + pscissor.minx = pscissor.miny = 0; + pscissor.maxx = state->width; + pscissor.maxy = state->height; + r300_set_scissor_regs(&pscissor, &scissor->framebuffer, r300_screen(r300->context.screen)->caps->is_r500); /* Don't rely on the order of states being set for the first time. */ - /* XXX ( >&) */ - if (!r300->rs_state.state) { - r300->dirty_state |= R300_NEW_SCISSOR; - } r300->dirty_state |= R300_NEW_FRAMEBUFFERS; r300->blend_state.dirty = TRUE; r300->dsa_state.dirty = TRUE; + r300->scissor_state.dirty = TRUE; } /* Create fragment shader state. */ @@ -725,11 +725,11 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) r300->rs_state.state = rs; r300->rs_state.dirty = TRUE; /* XXX Why is this still needed, dammit!? */ + r300->scissor_state.dirty = TRUE; r300->viewport_state.dirty = TRUE; /* XXX Clean these up when we move to atom emits */ r300->dirty_state |= R300_NEW_RS_BLOCK; - r300->dirty_state |= R300_NEW_SCISSOR; if (r300->fs && r300->fs->inputs.wpos != ATTR_UNUSED) { r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS; } @@ -867,11 +867,13 @@ static void r300_set_scissor_state(struct pipe_context* pipe, const struct pipe_scissor_state* state) { struct r300_context* r300 = r300_context(pipe); + struct r300_scissor_state* scissor = + (struct r300_scissor_state*)r300->scissor_state.state; - r300_set_scissor_regs(state, &r300->scissor_state->scissor, + r300_set_scissor_regs(state, &scissor->scissor, r300_screen(r300->context.screen)->caps->is_r500); - r300->dirty_state |= R300_NEW_SCISSOR; + r300->scissor_state.dirty = TRUE; } static void r300_set_viewport_state(struct pipe_context* pipe, -- 2.7.4