summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2010-04-14 02:33:17 +0200
committerMarek Olšák <[email protected]>2010-04-14 04:48:19 +0200
commit6793506faa13c259b1f36fb4cbe21841f851e248 (patch)
tree862b71a07c411e82dc5a2cf71511c8c489943527
parent075d9698eda4e8728872ffa1648f02d8d2748857 (diff)
r300g: make setting up fragment depth output less hackish
-rw-r--r--src/gallium/drivers/r300/r300_emit.c20
-rw-r--r--src/gallium/drivers/r300/r300_fs.c10
-rw-r--r--src/gallium/drivers/r300/r300_fs.h4
3 files changed, 18 insertions, 16 deletions
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index dd02eae70f9..ce5023c2141 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -233,18 +233,6 @@ static uint32_t pack_float24(float f)
return float24;
}
-static void r300_emit_fragment_depth_config(struct r300_context* r300)
-{
- CS_LOCALS(r300);
- if (r300_fragment_shader_writes_depth(r300_fs(r300))) {
- OUT_CS_REG(R300_FG_DEPTH_SRC, R300_FG_DEPTH_SRC_SHADER);
- OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W24 | R300_W_SRC_US);
- } else {
- OUT_CS_REG(R300_FG_DEPTH_SRC, R300_FG_DEPTH_SRC_SCAN);
- OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W0 | R300_W_SRC_US);
- }
-}
-
unsigned r300_get_fs_atom_size(struct r300_context *r300)
{
struct r300_fragment_shader *fs = r300_fs(r300);
@@ -315,8 +303,8 @@ void r300_emit_fs(struct r300_context* r300, unsigned size, void *state)
}
}
- r300_emit_fragment_depth_config(r300);
- cs_count -= 4;
+ OUT_CS_REG(R300_FG_DEPTH_SRC, fs->shader->fg_depth_src);
+ OUT_CS_REG(R300_US_W_FMT, fs->shader->us_out_w);
END_CS;
}
@@ -435,8 +423,8 @@ void r500_emit_fs(struct r300_context* r300, unsigned size, void *state)
}
}
- r300_emit_fragment_depth_config(r300);
- cs_count -= 4;
+ OUT_CS_REG(R300_FG_DEPTH_SRC, fs->shader->fg_depth_src);
+ OUT_CS_REG(R300_US_W_FMT, fs->shader->us_out_w);
END_CS;
}
diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c
index f75d282205e..8da0796e70f 100644
--- a/src/gallium/drivers/r300/r300_fs.c
+++ b/src/gallium/drivers/r300/r300_fs.c
@@ -31,6 +31,7 @@
#include "r300_context.h"
#include "r300_screen.h"
#include "r300_fs.h"
+#include "r300_reg.h"
#include "r300_tgsi_to_rc.h"
#include "radeon_code.h"
@@ -298,6 +299,15 @@ static void r300_translate_fragment_shader(
}
}
+ /* Setup shader depth output. */
+ if (shader->code.writes_depth) {
+ shader->fg_depth_src = R300_FG_DEPTH_SRC_SHADER;
+ shader->us_out_w = R300_W_FMT_W24 | R300_W_SRC_US;
+ } else {
+ shader->fg_depth_src = R300_FG_DEPTH_SRC_SCAN;
+ shader->us_out_w = R300_W_FMT_W0 | R300_W_SRC_US;
+ }
+
/* And, finally... */
rc_destroy(&compiler.Base);
}
diff --git a/src/gallium/drivers/r300/r300_fs.h b/src/gallium/drivers/r300/r300_fs.h
index 014703b2c4d..1cc43553595 100644
--- a/src/gallium/drivers/r300/r300_fs.h
+++ b/src/gallium/drivers/r300/r300_fs.h
@@ -43,6 +43,10 @@ struct r300_fragment_shader_code {
unsigned immediates_count;
unsigned rc_state_count;
+ /* Registers for fragment depth output setup. */
+ uint32_t fg_depth_src; /* R300_FG_DEPTH_SRC: 0x4bd8 */
+ uint32_t us_out_w; /* R300_US_W_FMT: 0x46b4 */
+
struct r300_fragment_program_external_state compare_state;
struct rX00_fragment_program_code code;