Mesa (gallium-0.1): tgsi: Add more sanity checking to ureg.
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Tue Aug 25 09:23:53 UTC 2009
Module: Mesa
Branch: gallium-0.1
Commit: 1749cc9f783f42817e237139b81a0d67d30679f7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1749cc9f783f42817e237139b81a0d67d30679f7
Author: José Fonseca <jfonseca at vmware.com>
Date: Mon Aug 24 20:51:25 2009 +0100
tgsi: Add more sanity checking to ureg.
---
src/gallium/auxiliary/tgsi/tgsi_ureg.c | 13 ++++++++++++-
src/gallium/auxiliary/tgsi/tgsi_ureg.h | 13 +++++++++++++
2 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index d78c289..d8e9e55 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -442,6 +442,10 @@ ureg_emit_src( struct ureg_program *ureg,
union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
unsigned n = 0;
+ assert(src.File != TGSI_FILE_NULL);
+ assert(src.File != TGSI_FILE_OUTPUT);
+ assert(src.File < TGSI_FILE_COUNT);
+
out[n].value = 0;
out[n].src.File = src.File;
out[n].src.SwizzleX = src.SwizzleX;
@@ -484,6 +488,13 @@ ureg_emit_dst( struct ureg_program *ureg,
union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
unsigned n = 0;
+ assert(dst.File != TGSI_FILE_NULL);
+ assert(dst.File != TGSI_FILE_CONSTANT);
+ assert(dst.File != TGSI_FILE_INPUT);
+ assert(dst.File != TGSI_FILE_SAMPLER);
+ assert(dst.File != TGSI_FILE_IMMEDIATE);
+ assert(dst.File < TGSI_FILE_COUNT);
+
out[n].value = 0;
out[n].dst.File = dst.File;
out[n].dst.WriteMask = dst.WriteMask;
@@ -783,7 +794,7 @@ const struct tgsi_token *ureg_finalize( struct ureg_program *ureg )
tokens = &ureg->domain[DOMAIN_DECL].tokens[0].token;
- if (0) {
+ if (1) {
debug_printf("%s: emitted shader %d tokens:\n", __FUNCTION__,
ureg->domain[DOMAIN_DECL].count);
tgsi_dump( tokens, 0 );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 23612a8..3bbf1d1 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -30,6 +30,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_debug.h"
#ifdef __cplusplus
extern "C" {
@@ -386,6 +387,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
static INLINE struct ureg_src
ureg_negate( struct ureg_src reg )
{
+ assert(reg.File != TGSI_FILE_NULL);
reg.Negate ^= 1;
return reg;
}
@@ -393,6 +395,7 @@ ureg_negate( struct ureg_src reg )
static INLINE struct ureg_src
ureg_abs( struct ureg_src reg )
{
+ assert(reg.File != TGSI_FILE_NULL);
reg.Absolute = 1;
reg.Negate = 0;
return reg;
@@ -407,6 +410,12 @@ ureg_swizzle( struct ureg_src reg,
(reg.SwizzleZ << 4) |
(reg.SwizzleW << 6));
+ assert(reg.File != TGSI_FILE_NULL);
+ assert(x < 4);
+ assert(y < 4);
+ assert(z < 4);
+ assert(w < 4);
+
reg.SwizzleX = (swz >> (x*2)) & 0x3;
reg.SwizzleY = (swz >> (y*2)) & 0x3;
reg.SwizzleZ = (swz >> (z*2)) & 0x3;
@@ -424,6 +433,7 @@ static INLINE struct ureg_dst
ureg_writemask( struct ureg_dst reg,
unsigned writemask )
{
+ assert(reg.File != TGSI_FILE_NULL);
reg.WriteMask &= writemask;
return reg;
}
@@ -431,6 +441,7 @@ ureg_writemask( struct ureg_dst reg,
static INLINE struct ureg_dst
ureg_saturate( struct ureg_dst reg )
{
+ assert(reg.File != TGSI_FILE_NULL);
reg.Saturate = 1;
return reg;
}
@@ -440,6 +451,7 @@ ureg_dst( struct ureg_src src )
{
struct ureg_dst dst;
+ assert(src.File == TGSI_FILE_TEMPORARY);
dst.File = src.File;
dst.WriteMask = TGSI_WRITEMASK_XYZW;
dst.Indirect = src.Indirect;
@@ -456,6 +468,7 @@ ureg_src( struct ureg_dst dst )
{
struct ureg_src src;
+ assert(dst.File == TGSI_FILE_TEMPORARY);
src.File = dst.File;
src.SwizzleX = TGSI_SWIZZLE_X;
src.SwizzleY = TGSI_SWIZZLE_Y;
More information about the mesa-commit
mailing list