summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/r300/r300_state_derived.c
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2009-10-14 03:09:41 -0700
committerCorbin Simpson <MostAwesomeDude@gmail.com>2009-10-14 03:09:41 -0700
commitfd63f89e95342d7d5921d6369346e356b505b584 (patch)
treeeb940c46ffa18432ba7f5190bd6e3055b08e8633 /src/gallium/drivers/r300/r300_state_derived.c
parentf13e507798cdbbe2fad5df33dcd581d49d6fa7ab (diff)
r300g: Move ztop to derived state.
Need to get it into its own atom instead of piggybacking on DSA.
Diffstat (limited to 'src/gallium/drivers/r300/r300_state_derived.c')
-rw-r--r--src/gallium/drivers/r300/r300_state_derived.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
index 335b54820a..5d323a26b1 100644
--- a/src/gallium/drivers/r300/r300_state_derived.c
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -444,6 +444,37 @@ static void r300_update_rs_block(struct r300_context* r300)
rs->inst_count = MAX2(MAX2(col_count - 1, tex_count - 1), 0);
}
+static void r300_update_ztop(struct r300_context* r300)
+{
+ r300->dsa_state->z_buffer_top = R300_ZTOP_ENABLE;
+
+ /* This is important enough that I felt it warranted a comment.
+ *
+ * According to the docs, these are the conditions where ZTOP must be
+ * disabled:
+ * 1) Alpha testing enabled
+ * 2) Texture kill instructions in fragment shader
+ * 3) Chroma key culling enabled
+ * 4) W-buffering enabled
+ *
+ * The docs claim that for the first three cases, if no ZS writes happen,
+ * then ZTOP can be used.
+ *
+ * Additionally, the following conditions require disabled ZTOP:
+ * ~) Depth writes in fragment shader
+ * ~) Outstanding occlusion queries
+ *
+ * ~C.
+ */
+ if (r300->dsa_state->alpha_function) {
+ r300->dsa_state->z_buffer_top = R300_ZTOP_DISABLE;
+ } else if (r300_fragment_shader_writes_depth(r300->fs)) {
+ r300->dsa_state->z_buffer_top = R300_ZTOP_DISABLE;
+ } else if (r300->query_current) {
+ r300->dsa_state->z_buffer_top = R300_ZTOP_DISABLE;
+ }
+}
+
void r300_update_derived_state(struct r300_context* r300)
{
if (r300->dirty_state &
@@ -455,4 +486,9 @@ void r300_update_derived_state(struct r300_context* r300)
r300_update_fs_tab(r300);
r300_update_rs_block(r300);
}
+
+ if (r300->dirty_state &
+ (R300_NEW_DSA | R300_NEW_FRAGMENT_SHADER | R300_NEW_QUERY)) {
+ r300_update_ztop(r300);
+ }
}