As of now, redeclaring a sampler variable causes Mesa to raise
SIGABRT. The attached patch avoids crashing the application and provides
a more helpful error message.

   Here is a trivial fragment shader that illustrates the behaviour:

uniform sampler2D foo;
void dostuff(sampler2D foo) { }
void main() { dostuff(foo); }

   However, nothing in the spec states that samplers should be
considered different from other variables scope-wise. I therefore don't
really understand why the test was here in the first place (especially
since the few tests I did didn't show any problems with redefining
sampler variables).

-- 
Sam.
>From 3396bbd304f1b41aeb32c9ae46f80a1cc1aa9ace Mon Sep 17 00:00:00 2001
From: Sam Hocevar <[EMAIL PROTECTED]>
Date: Thu, 25 Sep 2008 14:56:41 +0200
Subject: [PATCH] mesa: prevent the slang code generator from aborting when faced with
 a sampler variable redeclaration.

---
 src/mesa/shader/slang/slang_codegen.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 7006e86..72a3c0e 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2439,7 +2439,11 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var)
    /*assert(!var->declared);*/
    var->declared = GL_TRUE;
 
-   assert(!is_sampler_type(&var->type));
+   if(is_sampler_type(&var->type)) {
+      slang_info_log_error(A->log, "redeclaration of sampler '%s'",
+			   (char*) var->a_name);
+      return NULL;
+   }
 
    n = new_node0(IR_VAR_DECL);
    if (n) {
-- 
1.5.6.5

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to