mesa: Branch 'glsl-compiler-1' - 6 commits

Brian Paul brianp at kemper.freedesktop.org
Wed Mar 7 17:01:41 UTC 2007


 src/mesa/shader/shader_api.c           |    6 +++--
 src/mesa/shader/slang/slang_codegen.c  |   37 +++++++++++++++++++++++----------
 src/mesa/shader/slang/slang_link.c     |   13 ++++++++++-
 src/mesa/shader/slang/slang_vartable.c |    2 -
 4 files changed, 43 insertions(+), 15 deletions(-)

New commits:
diff-tree 3efd0c7b8d1aaa8abd78b35e4cb92dae4279dd77 (from f3da222839151bc8cbedbbe1e84f771deb31148c)
Author: Brian <brian at yutani.localnet.net>
Date:   Wed Mar 7 09:59:26 2007 -0700

    fix swizzled writemask bug

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index b2c9c72..5c2ee3c 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -1878,26 +1878,32 @@ _slang_gen_variable(slang_assemble_ctx *
  *    v.xy = vec2(a, b);
  * Hard example:
  *    vec3 v;
- *    v.yz = vec2(a, b);
- * this would have to be transformed/swizzled into:
- *    v.yz = vec2(a, b).*xy*         (* = don't care)
- * Instead, we'll effectively do this:
- *    v.y = vec2(a, b).xxxx;
- *    v.z = vec2(a, b).yyyy;
- *
+ *    v.zy = vec2(a, b);
+ * this gets transformed/swizzled into:
+ *    v.zy = vec2(a, b).*yx*         (* = don't care)
+ * This function helps to determine simple vs. non-simple.
  */
 static GLboolean
-_slang_simple_writemask(GLuint writemask)
+_slang_simple_writemask(GLuint writemask, GLuint swizzle)
 {
    switch (writemask) {
    case WRITEMASK_X:
+      return GET_SWZ(swizzle, 0) == SWIZZLE_X;
    case WRITEMASK_Y:
+      return GET_SWZ(swizzle, 1) == SWIZZLE_Y;
    case WRITEMASK_Z:
+      return GET_SWZ(swizzle, 2) == SWIZZLE_Z;
    case WRITEMASK_W:
+      return GET_SWZ(swizzle, 3) == SWIZZLE_W;
    case WRITEMASK_XY:
+      return (GET_SWZ(swizzle, 0) == SWIZZLE_X)
+         && (GET_SWZ(swizzle, 1) == SWIZZLE_Y);
    case WRITEMASK_XYZ:
+      return (GET_SWZ(swizzle, 0) == SWIZZLE_X)
+         && (GET_SWZ(swizzle, 1) == SWIZZLE_Y)
+         && (GET_SWZ(swizzle, 2) == SWIZZLE_Z);
    case WRITEMASK_XYZW:
-      return GL_TRUE;
+      return swizzle == SWIZZLE_NOOP;
    default:
       return GL_FALSE;
    }
@@ -1948,7 +1954,7 @@ swizzle_to_writemask(GLuint swizzle,
                                newSwizzle[2],
                                newSwizzle[3]);
 
-   if (_slang_simple_writemask(mask)) {
+   if (_slang_simple_writemask(mask, *swizzleOut)) {
       if (size >= 1)
          assert(GET_SWZ(*swizzleOut, 0) == SWIZZLE_X);
       if (size >= 2)
diff-tree f3da222839151bc8cbedbbe1e84f771deb31148c (from d25046b6487aaaa55cc2e3cfa57fe75a1c9d6de1)
Author: Brian <brian at yutani.localnet.net>
Date:   Wed Mar 7 09:58:45 2007 -0700

    remove bogus assertion

diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c
index 1299696..e3efa17 100644
--- a/src/mesa/shader/slang/slang_vartable.c
+++ b/src/mesa/shader/slang/slang_vartable.c
@@ -299,7 +299,7 @@ _slang_free_temp(slang_var_table *vt, sl
       t->Temps[r * 4 + comp] = FREE;
    }
    else {
-      assert(store->Swizzle == SWIZZLE_NOOP);
+      /*assert(store->Swizzle == SWIZZLE_NOOP);*/
       assert(t->ValSize[r*4] == store->Size);
       for (i = 0; i < store->Size; i++) {
          assert(t->Temps[r * 4 + i] == TEMP);
diff-tree d25046b6487aaaa55cc2e3cfa57fe75a1c9d6de1 (from e61ec95deb6e7edb2b003036773d57cc70d2c275)
Author: Brian <brian at yutani.localnet.net>
Date:   Wed Mar 7 08:56:09 2007 -0700

    fix incorrect HPOS write test

diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index e564d6d..a3cc233 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -550,13 +550,13 @@ _slang_link(GLcontext *ctx,
 
    if (shProg->VertexProgram) {
       _slang_update_inputs_outputs(&shProg->VertexProgram->Base);
-      if (!(shProg->VertexProgram->Base.OutputsWritten & VERT_RESULT_HPOS)) {
+      if (!(shProg->VertexProgram->Base.OutputsWritten & (1 << VERT_RESULT_HPOS))) {
          /* the vertex program did not compute a vertex position */
          if (shProg->InfoLog) {
             _mesa_free(shProg->InfoLog);
          }
          shProg->InfoLog
-            = _mesa_strdup("gl_Position was not written by vertex shader");
+            = _mesa_strdup("gl_Position was not written by vertex shader\n");
          shProg->LinkStatus = GL_FALSE;
          return;
       }
diff-tree e61ec95deb6e7edb2b003036773d57cc70d2c275 (from cec81eef313cea94ffdbd8e62c18ff8d3f651dbd)
Author: Brian <brian at yutani.localnet.net>
Date:   Wed Mar 7 08:55:42 2007 -0700

    additional error detection

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 26be14a..b2c9c72 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2077,6 +2077,10 @@ _slang_gen_field(slang_assemble_ctx * A,
       GLint size = 4; /* XXX fix? */
 
       base = _slang_gen_operation(A, &oper->children[0]);
+      if (!base) {
+         /* error previously found */
+         return NULL;
+      }
 
       n = new_node1(IR_FIELD, base);
       if (n) {
@@ -2118,6 +2122,7 @@ _slang_gen_subscript(slang_assemble_ctx 
       if (oper->children[1].type != SLANG_OPER_LITERAL_INT ||
           index >= max) {
          slang_info_log_error(A->log, "Invalid array index for vector type");
+         return NULL;
       }
 
       n = _slang_gen_operation(A, &oper->children[0]);
@@ -2143,7 +2148,11 @@ _slang_gen_subscript(slang_assemble_ctx 
       slang_typeinfo_construct(&elem_ti);
       _slang_typeof_operation(A, oper, &elem_ti);
       elemSize = _slang_sizeof_type_specifier(&elem_ti.spec);
-      assert(elemSize >= 1);
+      if (elemSize <= 0) {
+         /* unknown var or type */
+         slang_info_log_error(A->log, "Undefined var or type");
+         return NULL;
+      }
 
       array = _slang_gen_operation(A, &oper->children[0]);
       index = _slang_gen_operation(A, &oper->children[1]);
diff-tree cec81eef313cea94ffdbd8e62c18ff8d3f651dbd (from 55821d021d87fba6551509f5612ee16d9ece977f)
Author: Brian <brian at yutani.localnet.net>
Date:   Wed Mar 7 08:04:06 2007 -0700

    check for null program ptrs in _mesa_uniform()

diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 48ba8b6..924c9d5 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -961,8 +961,10 @@ _mesa_uniform(GLcontext *ctx, GLint loca
    }
 
    if (shProg->Uniforms->Parameters[location].Type == PROGRAM_SAMPLER) {
-      _slang_resolve_samplers(shProg, &shProg->VertexProgram->Base);
-      _slang_resolve_samplers(shProg, &shProg->FragmentProgram->Base);
+      if (shProg->VertexProgram)
+         _slang_resolve_samplers(shProg, &shProg->VertexProgram->Base);
+      if (shProg->FragmentProgram)
+         _slang_resolve_samplers(shProg, &shProg->FragmentProgram->Base);
       FLUSH_VERTICES(ctx, _NEW_TEXTURE);
    }
 }
diff-tree 55821d021d87fba6551509f5612ee16d9ece977f (from 6cb0aa12b82bf29e0306de7a2baa1c398732688c)
Author: Brian <brian at yutani.localnet.net>
Date:   Wed Mar 7 07:52:24 2007 -0700

    Generate an error if the vertex shader does not write to gl_Position.

diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 8f92473..e564d6d 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -548,8 +548,19 @@ _slang_link(GLcontext *ctx,
       }
    }
 
-   if (shProg->VertexProgram)
+   if (shProg->VertexProgram) {
       _slang_update_inputs_outputs(&shProg->VertexProgram->Base);
+      if (!(shProg->VertexProgram->Base.OutputsWritten & VERT_RESULT_HPOS)) {
+         /* the vertex program did not compute a vertex position */
+         if (shProg->InfoLog) {
+            _mesa_free(shProg->InfoLog);
+         }
+         shProg->InfoLog
+            = _mesa_strdup("gl_Position was not written by vertex shader");
+         shProg->LinkStatus = GL_FALSE;
+         return;
+      }
+   }
    if (shProg->FragmentProgram)
       _slang_update_inputs_outputs(&shProg->FragmentProgram->Base);
 



More information about the mesa-commit mailing list