r300g: Atomize ZTOP.

Also do state-change checks. ZTOP's too important to not check.
This commit is contained in:
Corbin Simpson 2010-01-10 11:49:25 -08:00
parent 07ea7e6c80
commit 8a2c961798
5 changed files with 25 additions and 8 deletions

View file

@ -76,6 +76,7 @@ static void r300_destroy_context(struct pipe_context* context)
FREE(r300->scissor_state);
FREE(r300->vertex_info);
FREE(r300->viewport_state);
FREE(r300->ztop_state.state);
FREE(r300);
}
@ -118,6 +119,7 @@ static void r300_flush_cb(void *data)
static void r300_setup_atoms(struct r300_context* r300)
{
make_empty_list(&r300->atom_list);
R300_INIT_ATOM(ztop);
R300_INIT_ATOM(blend);
R300_INIT_ATOM(blend_color);
R300_INIT_ATOM(clip);
@ -172,20 +174,21 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300->shader_hash_table = util_hash_table_create(r300_shader_key_hash,
r300_shader_key_compare);
r300_setup_atoms(r300);
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->vertex_info = CALLOC_STRUCT(r300_vertex_info);
r300->viewport_state = CALLOC_STRUCT(r300_viewport_state);
r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state);
/* Open up the OQ BO. */
r300->oqbo = screen->buffer_create(screen, 4096,
PIPE_BUFFER_USAGE_VERTEX, 4096);
make_empty_list(&r300->query_list);
r300_setup_atoms(r300);
r300_init_flush_functions(r300);
r300_init_query_functions(r300);

View file

@ -311,7 +311,7 @@ struct r300_context {
/* Viewport state. */
struct r300_viewport_state* viewport_state;
/* ZTOP state. */
struct r300_ztop_state ztop_state;
struct r300_atom ztop_state;
/* Vertex buffers for Gallium. */
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];

View file

@ -113,7 +113,7 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state)
struct r300_screen* r300screen = r300_screen(r300->context.screen);
CS_LOCALS(r300);
BEGIN_CS(r300screen->caps->is_r500 ? 10 : 8);
BEGIN_CS(r300screen->caps->is_r500 ? 8 : 6);
OUT_CS_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function);
/* not needed since we use the 8bit alpha ref */
@ -132,7 +132,6 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state)
}
OUT_CS(dsa->stencil_ref_mask);
OUT_CS_REG(R300_ZB_ZTOP, r300->ztop_state.z_buffer_top);
/* XXX it seems r3xx doesn't support STENCILREFMASK_BF */
if (r300screen->caps->is_r500) {
@ -956,6 +955,16 @@ void r300_emit_texture_count(struct r300_context* r300)
}
void r300_emit_ztop_state(struct r300_context* r300, void* state)
{
struct r300_ztop_state* ztop = (struct r300_ztop_state*)state;
CS_LOCALS(r300);
BEGIN_CS(2);
OUT_CS_REG(R300_ZB_ZTOP, ztop->z_buffer_top);
END_CS;
}
void r300_flush_textures(struct r300_context* r300)
{
CS_LOCALS(r300);

View file

@ -90,6 +90,8 @@ void r300_emit_viewport_state(struct r300_context* r300,
void r300_emit_texture_count(struct r300_context* r300);
void r300_emit_ztop_state(struct r300_context* r300, void* state);
void r300_flush_textures(struct r300_context* r300);
/* Emit all dirty state. */

View file

@ -508,7 +508,9 @@ static boolean r300_dsa_alpha_test_enabled(struct r300_dsa_state* dsa)
static void r300_update_ztop(struct r300_context* r300)
{
uint32_t ztop = r300->ztop_state.z_buffer_top;
struct r300_ztop_state* ztop_state =
(struct r300_ztop_state*)r300->ztop_state.state;
uint32_t ztop = ztop_state->z_buffer_top;
/* This is important enough that I felt it warranted a comment.
*
@ -546,8 +548,9 @@ static void r300_update_ztop(struct r300_context* r300)
ztop = R300_ZTOP_ENABLE;
}
if (r300->ztop_state.z_buffer_top != ztop) {
r300->ztop_state.z_buffer_top = ztop;
if (ztop_state->z_buffer_top != ztop) {
ztop_state->z_buffer_top = ztop;
r300->ztop_state.dirty = TRUE;
}
}