r300g: Atomize DSA.
Also a bit of ztop.
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
static void r300_blitter_save_states(struct r300_context* r300)
|
static void r300_blitter_save_states(struct r300_context* r300)
|
||||||
{
|
{
|
||||||
util_blitter_save_blend(r300->blitter, r300->blend_state.state);
|
util_blitter_save_blend(r300->blitter, r300->blend_state.state);
|
||||||
util_blitter_save_depth_stencil_alpha(r300->blitter, r300->dsa_state);
|
util_blitter_save_depth_stencil_alpha(r300->blitter, r300->dsa_state.state);
|
||||||
util_blitter_save_rasterizer(r300->blitter, r300->rs_state);
|
util_blitter_save_rasterizer(r300->blitter, r300->rs_state);
|
||||||
util_blitter_save_fragment_shader(r300->blitter, r300->fs);
|
util_blitter_save_fragment_shader(r300->blitter, r300->fs);
|
||||||
util_blitter_save_vertex_shader(r300->blitter, r300->vs);
|
util_blitter_save_vertex_shader(r300->blitter, r300->vs);
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ static void r300_setup_atoms(struct r300_context* r300)
|
|||||||
R300_INIT_ATOM(blend);
|
R300_INIT_ATOM(blend);
|
||||||
R300_INIT_ATOM(blend_color);
|
R300_INIT_ATOM(blend_color);
|
||||||
R300_INIT_ATOM(clip);
|
R300_INIT_ATOM(clip);
|
||||||
|
R300_INIT_ATOM(dsa);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pipe_context* r300_create_context(struct pipe_screen* screen,
|
struct pipe_context* r300_create_context(struct pipe_screen* screen,
|
||||||
|
|||||||
@@ -144,7 +144,6 @@ struct r300_ztop_state {
|
|||||||
uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */
|
uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define R300_NEW_DSA 0x00000008
|
|
||||||
#define R300_NEW_FRAMEBUFFERS 0x00000010
|
#define R300_NEW_FRAMEBUFFERS 0x00000010
|
||||||
#define R300_NEW_FRAGMENT_SHADER 0x00000020
|
#define R300_NEW_FRAGMENT_SHADER 0x00000020
|
||||||
#define R300_NEW_FRAGMENT_SHADER_CONSTANTS 0x00000040
|
#define R300_NEW_FRAGMENT_SHADER_CONSTANTS 0x00000040
|
||||||
@@ -290,7 +289,7 @@ struct r300_context {
|
|||||||
/* Shader constants. */
|
/* Shader constants. */
|
||||||
struct r300_constant_buffer shader_constants[PIPE_SHADER_TYPES];
|
struct r300_constant_buffer shader_constants[PIPE_SHADER_TYPES];
|
||||||
/* Depth, stencil, and alpha state. */
|
/* Depth, stencil, and alpha state. */
|
||||||
struct r300_dsa_state* dsa_state;
|
struct r300_atom dsa_state;
|
||||||
/* Fragment shader. */
|
/* Fragment shader. */
|
||||||
struct r300_fragment_shader* fs;
|
struct r300_fragment_shader* fs;
|
||||||
/* Framebuffer state. We currently don't need our own version of this. */
|
/* Framebuffer state. We currently don't need our own version of this. */
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ void r300_emit_clip_state(struct r300_context* r300, void* state)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void r300_emit_dsa_state(struct r300_context* r300,
|
void r300_emit_dsa_state(struct r300_context* r300, void* state)
|
||||||
struct r300_dsa_state* dsa)
|
|
||||||
{
|
{
|
||||||
|
struct r300_dsa_state* dsa = (struct r300_dsa_state*)state;
|
||||||
struct r300_screen* r300screen = r300_screen(r300->context.screen);
|
struct r300_screen* r300screen = r300_screen(r300->context.screen);
|
||||||
CS_LOCALS(r300);
|
CS_LOCALS(r300);
|
||||||
|
|
||||||
@@ -983,10 +983,6 @@ void r300_emit_dirty_state(struct r300_context* r300)
|
|||||||
int i, dirty_tex = 0;
|
int i, dirty_tex = 0;
|
||||||
boolean invalid = FALSE;
|
boolean invalid = FALSE;
|
||||||
|
|
||||||
if (!(r300->dirty_state)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check size of CS. */
|
/* Check size of CS. */
|
||||||
/* Make sure we have at least 8*1024 spare dwords. */
|
/* Make sure we have at least 8*1024 spare dwords. */
|
||||||
/* XXX It would be nice to know the number of dwords we really need to
|
/* XXX It would be nice to know the number of dwords we really need to
|
||||||
@@ -1069,11 +1065,6 @@ validate:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r300->dirty_state & R300_NEW_DSA) {
|
|
||||||
r300_emit_dsa_state(r300, r300->dsa_state);
|
|
||||||
r300->dirty_state &= ~R300_NEW_DSA;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER) {
|
if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER) {
|
||||||
r300_emit_fragment_depth_config(r300, r300->fs);
|
r300_emit_fragment_depth_config(r300, r300->fs);
|
||||||
if (r300screen->caps->is_r500) {
|
if (r300screen->caps->is_r500) {
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ void r300_emit_blend_color_state(struct r300_context* r300, void* state);
|
|||||||
|
|
||||||
void r300_emit_clip_state(struct r300_context* r300, void* state);
|
void r300_emit_clip_state(struct r300_context* r300, void* state);
|
||||||
|
|
||||||
void r300_emit_dsa_state(struct r300_context* r300,
|
void r300_emit_dsa_state(struct r300_context* r300, void* state);
|
||||||
struct r300_dsa_state* dsa);
|
|
||||||
|
|
||||||
void r300_emit_fragment_program_code(struct r300_context* r300,
|
void r300_emit_fragment_program_code(struct r300_context* r300,
|
||||||
struct rX00_fragment_program_code* generic_code);
|
struct rX00_fragment_program_code* generic_code);
|
||||||
|
|||||||
@@ -463,8 +463,8 @@ static void r300_bind_dsa_state(struct pipe_context* pipe,
|
|||||||
{
|
{
|
||||||
struct r300_context* r300 = r300_context(pipe);
|
struct r300_context* r300 = r300_context(pipe);
|
||||||
|
|
||||||
r300->dsa_state = (struct r300_dsa_state*)state;
|
r300->dsa_state.state = state;
|
||||||
r300->dirty_state |= R300_NEW_DSA;
|
r300->dsa_state.dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free DSA state. */
|
/* Free DSA state. */
|
||||||
@@ -523,9 +523,9 @@ static void
|
|||||||
r300->dirty_state |= R300_NEW_SCISSOR;
|
r300->dirty_state |= R300_NEW_SCISSOR;
|
||||||
}
|
}
|
||||||
r300->dirty_state |= R300_NEW_FRAMEBUFFERS;
|
r300->dirty_state |= R300_NEW_FRAMEBUFFERS;
|
||||||
r300->dirty_state |= R300_NEW_DSA;
|
|
||||||
|
|
||||||
r300->blend_state.dirty = TRUE;
|
r300->blend_state.dirty = TRUE;
|
||||||
|
r300->dsa_state.dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create fragment shader state. */
|
/* Create fragment shader state. */
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ static boolean r300_dsa_alpha_test_enabled(struct r300_dsa_state* dsa)
|
|||||||
|
|
||||||
static void r300_update_ztop(struct r300_context* r300)
|
static void r300_update_ztop(struct r300_context* r300)
|
||||||
{
|
{
|
||||||
r300->ztop_state.z_buffer_top = R300_ZTOP_ENABLE;
|
uint32_t ztop = r300->ztop_state.z_buffer_top;
|
||||||
|
|
||||||
/* This is important enough that I felt it warranted a comment.
|
/* This is important enough that I felt it warranted a comment.
|
||||||
*
|
*
|
||||||
@@ -534,14 +534,20 @@ static void r300_update_ztop(struct r300_context* r300)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* ZS writes */
|
/* ZS writes */
|
||||||
if (r300_dsa_writes_depth_stencil(r300->dsa_state) &&
|
if (r300_dsa_writes_depth_stencil(r300->dsa_state.state) &&
|
||||||
(r300_dsa_alpha_test_enabled(r300->dsa_state) || /* (1) */
|
(r300_dsa_alpha_test_enabled(r300->dsa_state.state) ||/* (1) */
|
||||||
r300->fs->info.uses_kill)) { /* (2) */
|
r300->fs->info.uses_kill)) { /* (2) */
|
||||||
r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
|
ztop = R300_ZTOP_DISABLE;
|
||||||
} else if (r300_fragment_shader_writes_depth(r300->fs)) { /* (5) */
|
} else if (r300_fragment_shader_writes_depth(r300->fs)) { /* (5) */
|
||||||
r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
|
ztop = R300_ZTOP_DISABLE;
|
||||||
} else if (r300->query_current) { /* (6) */
|
} else if (r300->query_current) { /* (6) */
|
||||||
r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE;
|
ztop = R300_ZTOP_DISABLE;
|
||||||
|
} else {
|
||||||
|
ztop = R300_ZTOP_ENABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r300->ztop_state.z_buffer_top != ztop) {
|
||||||
|
r300->ztop_state.z_buffer_top = ztop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,8 +559,5 @@ void r300_update_derived_state(struct r300_context* r300)
|
|||||||
r300_update_derived_shader_state(r300);
|
r300_update_derived_shader_state(r300);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r300->dirty_state &
|
r300_update_ztop(r300);
|
||||||
(R300_NEW_DSA | R300_NEW_FRAGMENT_SHADER | R300_NEW_QUERY)) {
|
|
||||||
r300_update_ztop(r300);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user