diff --git a/progs/demos/arbocclude.c b/progs/demos/arbocclude.c index 9188ad5..0f7176d 100644 --- a/progs/demos/arbocclude.c +++ b/progs/demos/arbocclude.c @@ -177,6 +177,7 @@ static void Display( void ) glColor3f(1, 1, 1); #if defined(GL_ARB_occlusion_query) sprintf(s, " %4d Fragments Visible", passed); +fputs(s, stderr); glRasterPos3f(-0.50, -0.7, 0); PrintString(s); if (!passed) { diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 7a9c098..e0c2ede 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -200,5 +200,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->dirty_state = R300_NEW_KITCHEN_SINK; r300->dirty_hw++; make_empty_list(&r300->query_list); + make_empty_list(&r300->atom_list); + r300_setup_atom_list(r300); return &r300->context; } diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index d2e8875..5d75688 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -41,6 +41,13 @@ struct r300_fragment_shader; struct r300_vertex_shader; +struct r300_state_atom { + struct r300_state_atom *next, *prev; + uint32_t state; + int (*check)(struct r300_state_atom *atom); + void (*emit)(struct r300_context *r300, struct r300_state_atom *atom); +}; + struct r300_blend_state { uint32_t blend_control; /* R300_RB3D_CBLEND: 0x4e04 */ uint32_t alpha_blend_control; /* R300_RB3D_ABLEND: 0x4e08 */ @@ -288,6 +295,7 @@ struct r300_context { /** Combination of DBG_xxx flags */ unsigned debug; + struct r300_state_atom atom_list; }; /* Convenience cast wrapper. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index feffadd..a1b54e8 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -28,9 +28,10 @@ #include "r300_state_derived.h" #include "r300_vs.h" -void r300_emit_blend_state(struct r300_context* r300, - struct r300_blend_state* blend) +static void r300_emit_state_blend(struct r300_context* r300, + struct r300_state_atom *atom) { + struct r300_blend_state* blend = r300->blend_state; CS_LOCALS(r300); BEGIN_CS(7); OUT_CS_REG_SEQ(R300_RB3D_CBLEND, 2); @@ -41,10 +42,34 @@ void r300_emit_blend_state(struct r300_context* r300, END_CS; } -void r300_emit_blend_color_state(struct r300_context* r300, - struct r300_blend_color_state* bc) +static void r300_emit_state_query(struct r300_context* r300, + struct r300_state_atom *atom) +{ + struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps; + struct r300_query *query = r300->query_current; + CS_LOCALS(r300); + + if (!query) + return; + + /* XXX This will almost certainly not return good results + * for overlapping queries. */ + BEGIN_CS(4); + if (caps->family == CHIP_FAMILY_RV530) { + OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL); + } else { + OUT_CS_REG(R300_SU_REG_DEST, R300_RASTER_PIPE_SELECT_ALL); + } + OUT_CS_REG(R300_ZB_ZPASS_DATA, 0); + END_CS; + query->begin_emitted = TRUE; +} + +static void r300_emit_state_blend_color(struct r300_context* r300, + struct r300_state_atom *atom) { struct r300_screen* r300screen = r300_screen(r300->context.screen); + struct r300_blend_color_state* bc = r300->blend_color_state; CS_LOCALS(r300); if (r300screen->caps->is_r500) { @@ -320,30 +345,6 @@ void r300_emit_fb_state(struct r300_context* r300, END_CS; } -void r300_emit_query_start(struct r300_context *r300) - -{ - struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps; - struct r300_query *query = r300->query_current; - CS_LOCALS(r300); - - if (!query) - return; - - /* XXX This will almost certainly not return good results - * for overlapping queries. */ - BEGIN_CS(4); - if (caps->family == CHIP_FAMILY_RV530) { - OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL); - } else { - OUT_CS_REG(R300_SU_REG_DEST, R300_RASTER_PIPE_SELECT_ALL); - } - OUT_CS_REG(R300_ZB_ZPASS_DATA, 0); - END_CS; - query->begin_emitted = TRUE; -} - - static void r300_emit_query_finish(struct r300_context *r300, struct r300_query *query) { @@ -700,11 +701,36 @@ void r300_flush_textures(struct r300_context* r300) END_CS; } +static inline struct r300_state_atom *r300_new_atom(struct r300_context *r300, + uint32_t states, + void (*emit)(struct r300_context *r300, struct r300_state_atom *atom)) +{ + struct r300_state_atom *atom; + atom = CALLOC_STRUCT(r300_state_atom); + assert(atom); + atom->emit = emit; + atom->state = states; + return atom; +} + +#define R300_ADD_ATOM(fnname, states) do { \ + struct r300_state_atom *myatom = r300_new_atom(r300, states, r300_emit_state_##fnname); \ + insert_at_tail(&r300->atom_list, myatom); \ +} while(0) + +void r300_setup_atom_list(struct r300_context *r300) +{ + R300_ADD_ATOM(blend, R300_NEW_BLEND); + R300_ADD_ATOM(query, R300_NEW_QUERY); + R300_ADD_ATOM(blend_color, R300_NEW_BLEND_COLOR); +} + /* Emit all dirty state. */ void r300_emit_dirty_state(struct r300_context* r300) { struct r300_screen* r300screen = r300_screen(r300->context.screen); struct r300_texture* tex; + struct r300_state_atom *atom; int i, dirty_tex = 0; boolean invalid = FALSE; @@ -777,21 +803,13 @@ validate: goto validate; } - if (r300->dirty_state & R300_NEW_QUERY) { - r300_emit_query_start(r300); - r300->dirty_state &= ~R300_NEW_QUERY; - } - - if (r300->dirty_state & R300_NEW_BLEND) { - r300_emit_blend_state(r300, r300->blend_state); - r300->dirty_state &= ~R300_NEW_BLEND; + foreach(atom, &r300->atom_list) { + if (r300->dirty_state & atom->state) { + atom->emit(r300, atom); + r300->dirty_state &= ~atom->state; + } } - - if (r300->dirty_state & R300_NEW_BLEND_COLOR) { - r300_emit_blend_color_state(r300, r300->blend_color_state); - r300->dirty_state &= ~R300_NEW_BLEND_COLOR; - } - + if (r300->dirty_state & R300_NEW_CLIP) { r300_emit_clip_state(r300, &r300->clip_state); r300->dirty_state &= ~R300_NEW_CLIP; diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index b62aa9f..eca9cce 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -92,4 +92,5 @@ void r300_flush_textures(struct r300_context* r300); /* Emit all dirty state. */ void r300_emit_dirty_state(struct r300_context* r300); +void r300_setup_atom_list(struct r300_context *r300); #endif /* R300_EMIT_H */ diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index d7b57e1..da2e785 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -188,6 +188,7 @@ static INLINE uint32_t r300_translate_alpha_function(int alpha_func) static INLINE uint32_t r300_translate_wrap(int wrap) { + fprintf(stderr, "wrap is %d\n", wrap); switch (wrap) { case PIPE_TEX_WRAP_REPEAT: return R300_TX_REPEAT; diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 7ea4c33..dceaeae 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -42,6 +42,7 @@ static void r300_setup_texture_state(struct r300_texture* tex) state->format1 |= R300_TX_FORMAT_3D; } + fprintf(stderr,"error %d %d\n", r300_texture_get_stride(tex, 0), pt->block.size); state->format2 = (r300_texture_get_stride(tex, 0) / pt->block.size) - 1; /* Assume (somewhat foolishly) that oversized textures will diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 7ea5d1f..ebe14a7 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -124,12 +124,25 @@ static void radeon_r300_end_cs(struct r300_winsys* winsys, radeon_cs_end(priv->cs, file, function, line); } +void dump_cs(struct radeon_cs *cs) +{ + int i; + for (i = 0; i < cs->cdw; i+=4) { + fprintf(stderr,"%d: %08x %08x %08x %08x\n", i, + cs->packets[i], + cs->packets[i+1], + cs->packets[i+2], + cs->packets[i+3]); + } +} + static void radeon_r300_flush_cs(struct r300_winsys* winsys) { struct radeon_winsys_priv* priv = (struct radeon_winsys_priv*)winsys->radeon_winsys; int retval; + // dump_cs(priv->cs); /* Emit the CS. */ retval = radeon_cs_emit(priv->cs); if (retval) {