Mesa (master): r300g: Work around "defect" in r300compiler.

Corbin Simpson csimpson at kemper.freedesktop.org
Thu Feb 11 02:40:48 UTC 2010


Module: Mesa
Branch: master
Commit: 229db2b8ade33571e4cece1d838234895db220c2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=229db2b8ade33571e4cece1d838234895db220c2

Author: Corbin Simpson <MostAwesomeDude at gmail.com>
Date:   Wed Feb 10 18:38:53 2010 -0800

r300g: Work around "defect" in r300compiler.

r300compiler doesn't handle half swizzles for vert shaders, which don't
have them. So, for now, disable them.

---

 src/gallium/drivers/r300/r300_fs.c         |    1 +
 src/gallium/drivers/r300/r300_tgsi_to_rc.c |    5 +++--
 src/gallium/drivers/r300/r300_tgsi_to_rc.h |    6 ++++++
 src/gallium/drivers/r300/r300_vs.c         |    1 +
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c
index 75a0549..ae4c62b 100644
--- a/src/gallium/drivers/r300/r300_fs.c
+++ b/src/gallium/drivers/r300/r300_fs.c
@@ -179,6 +179,7 @@ static void r300_translate_fragment_shader(
     /* Translate TGSI to our internal representation */
     ttr.compiler = &compiler.Base;
     ttr.info = &fs->info;
+    ttr.use_half_swizzles = TRUE;
 
     r300_tgsi_to_rc(&ttr, fs->state.tokens);
 
diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
index 1c82fcc..aff4ddd 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
@@ -307,7 +307,7 @@ static void handle_immediate(struct tgsi_to_rc * ttr,
     for (i = 0; i < 4; i++) {
         if (imm->u[i].Float == 0.0f) {
             swizzle |= RC_SWIZZLE_ZERO << (i * 3);
-        } else if (imm->u[i].Float == 0.5f) {
+        } else if (imm->u[i].Float == 0.5f && ttr->use_half_swizzles) {
             swizzle |= RC_SWIZZLE_HALF << (i * 3);
         } else if (imm->u[i].Float == 1.0f) {
             swizzle |= RC_SWIZZLE_ONE << (i * 3);
@@ -330,7 +330,8 @@ static void handle_immediate(struct tgsi_to_rc * ttr,
     }
 }
 
-void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
+void r300_tgsi_to_rc(struct tgsi_to_rc * ttr,
+                     const struct tgsi_token * tokens)
 {
     struct tgsi_parse_context parser;
     unsigned imm_index = 0;
diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.h b/src/gallium/drivers/r300/r300_tgsi_to_rc.h
index 39b473c..97641a9 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.h
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.h
@@ -23,6 +23,8 @@
 #ifndef R300_TGSI_TO_RC_H
 #define R300_TGSI_TO_RC_H
 
+#include "pipe/p_compiler.h"
+
 struct radeon_compiler;
 
 struct tgsi_full_declaration;
@@ -41,6 +43,10 @@ struct tgsi_to_rc {
     int immediate_offset;
     struct swizzled_imms * imms_to_swizzle;
     unsigned imms_to_swizzle_count;
+
+    /* Vertex shaders have no half swizzles, and no way to handle them, so
+     * until rc grows proper support, indicate if they're safe to use. */
+    boolean use_half_swizzles;
 };
 
 void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens);
diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c
index fb81b24..a6786c3 100644
--- a/src/gallium/drivers/r300/r300_vs.c
+++ b/src/gallium/drivers/r300/r300_vs.c
@@ -340,6 +340,7 @@ void r300_translate_vertex_shader(struct r300_context* r300,
     /* Translate TGSI to our internal representation */
     ttr.compiler = &compiler.Base;
     ttr.info = &vs->info;
+    ttr.use_half_swizzles = FALSE;
 
     r300_tgsi_to_rc(&ttr, vs->state.tokens);
 




More information about the mesa-commit mailing list