Mesa (gallium-0.2): tgsi: Return 0.0 for negative constant register indices .

Michał Król michal at kemper.freedesktop.org
Tue Nov 18 15:07:48 UTC 2008


Module: Mesa
Branch: gallium-0.2
Commit: d86ffcffb365d1f9fc383e450c8e08bf86169726
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d86ffcffb365d1f9fc383e450c8e08bf86169726

Author: Michal Krol <michal at tungstengraphics.com>
Date:   Fri Nov 14 13:31:06 2008 +0100

tgsi: Return 0.0 for negative constant register indices.

---

 src/gallium/auxiliary/tgsi/tgsi_exec.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 177cf20..9656777 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -947,14 +947,22 @@ fetch_src_file_channel(
       switch( file ) {
       case TGSI_FILE_CONSTANT:
          assert(mach->Consts);
-         assert(index->i[0] >= 0);
-         assert(index->i[1] >= 0);
-         assert(index->i[2] >= 0);
-         assert(index->i[3] >= 0);
-         chan->f[0] = mach->Consts[index->i[0]][swizzle];
-         chan->f[1] = mach->Consts[index->i[1]][swizzle];
-         chan->f[2] = mach->Consts[index->i[2]][swizzle];
-         chan->f[3] = mach->Consts[index->i[3]][swizzle];
+         if (index->i[0] < 0)
+            chan->f[0] = 0.0f;
+         else
+            chan->f[0] = mach->Consts[index->i[0]][swizzle];
+         if (index->i[1] < 0)
+            chan->f[1] = 0.0f;
+         else
+            chan->f[1] = mach->Consts[index->i[1]][swizzle];
+         if (index->i[2] < 0)
+            chan->f[2] = 0.0f;
+         else
+            chan->f[2] = mach->Consts[index->i[2]][swizzle];
+         if (index->i[3] < 0)
+            chan->f[3] = 0.0f;
+         else
+            chan->f[3] = mach->Consts[index->i[3]][swizzle];
          break;
 
       case TGSI_FILE_INPUT:




More information about the mesa-commit mailing list