Module: Mesa
Branch: arb_geometry_shader4
Commit: 4dbf3a9109d2984683ae7b14538153314f607967
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4dbf3a9109d2984683ae7b14538153314f607967

Author: Zack Rusin <[email protected]>
Date:   Sat Feb 14 20:08:55 2009 -0500

gs: start adding builtins

---

 src/mesa/shader/program.c                          |    9 +++-
 src/mesa/shader/slang/library/Makefile             |    4 +-
 .../shader/slang/library/slang_geometry_builtin.gc |   40 ++++++++++++++++++++
 src/mesa/shader/slang/slang_compile.c              |   11 +++++
 src/mesa/shader/slang/slang_emit.c                 |    2 +-
 5 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 70de235..1a08d16 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -306,8 +306,13 @@ _mesa_new_program(GLcontext *ctx, GLenum target, GLuint id)
    case GL_FRAGMENT_PROGRAM_NV:
    case GL_FRAGMENT_PROGRAM_ARB:
       prog =_mesa_init_fragment_program(ctx,
-                                         CALLOC_STRUCT(gl_fragment_program),
-                                         target, id );
+                                        CALLOC_STRUCT(gl_fragment_program),
+                                        target, id );
+      break;
+   case MESA_GEOMETRY_PROGRAM:
+      prog = _mesa_init_geometry_program(ctx,
+                                         CALLOC_STRUCT(gl_geometry_program),
+                                         target, id);
       break;
    default:
       _mesa_problem(ctx, "bad target in _mesa_new_program");
diff --git a/src/mesa/shader/slang/library/Makefile 
b/src/mesa/shader/slang/library/Makefile
index 0e03fac..df05063 100644
--- a/src/mesa/shader/slang/library/Makefile
+++ b/src/mesa/shader/slang/library/Makefile
@@ -55,7 +55,7 @@ slang_pp_version_syn.h: syn_to_c slang_pp_version.syn
 
 builtin_110: slang_common_builtin_gc.h slang_core_gc.h 
slang_fragment_builtin_gc.h slang_vertex_builtin_gc.h
 
-builtin_120: slang_120_core_gc.h slang_builtin_120_common_gc.h 
slang_builtin_120_fragment_gc.h
+builtin_120: slang_120_core_gc.h slang_builtin_120_common_gc.h 
slang_builtin_120_fragment_gc.h slang_geometry_builtin_gc.h
 
 
 slang_120_core_gc.h: gc_to_bin slang_120_core.gc
@@ -79,3 +79,5 @@ slang_fragment_builtin_gc.h: gc_to_bin 
slang_fragment_builtin.gc
 slang_vertex_builtin_gc.h: gc_to_bin slang_vertex_builtin.gc
        ./gc_to_bin 2 slang_vertex_builtin.gc slang_vertex_builtin_gc.h
 
+slang_geometry_builtin_gc.h: gc_to_bin slang_geometry_builtin.gc
+       ./gc_to_bin 2 slang_geometry_builtin.gc slang_geometry_builtin_gc.h
diff --git a/src/mesa/shader/slang/library/slang_geometry_builtin.gc 
b/src/mesa/shader/slang/library/slang_geometry_builtin.gc
new file mode 100644
index 0000000..b6c96da
--- /dev/null
+++ b/src/mesa/shader/slang/library/slang_geometry_builtin.gc
@@ -0,0 +1,40 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.5
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+attribute int gl_VerticesIn;
+
+varying vec4 gl_FrontColorIn[];
+varying vec4 gl_BackColorIn[];
+varying vec4 gl_FrontSecondaryColorIn[];
+varying vec4 gl_BackSecondaryColorIn[];
+//varying vec4 gl_TexCoordIn[][];
+varying float gl_FogFragCoordIn[];
+varying vec4 gl_PositionIn[];
+varying float gl_PointSizeIn[];
+varying vec4 gl_ClipVertexIn[];
+
+varying vec4 gl_FrontColor;
+varying vec4 gl_BackColor;
+varying vec4 gl_FrontSecondaryColor;
+varying vec4 gl_BackSecondaryColor;
+varying vec4 gl_TexCoord[];
+varying float gl_FogFragCoord;
diff --git a/src/mesa/shader/slang/slang_compile.c 
b/src/mesa/shader/slang/slang_compile.c
index dd08108..b9dc6f7 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -2582,6 +2582,10 @@ static const byte slang_vertex_builtin_gc[] = {
 #include "library/slang_vertex_builtin_gc.h"
 };
 
+static const byte slang_geometry_builtin_gc[] = {
+#include "library/slang_geometry_builtin_gc.h"
+};
+
 static GLboolean
 compile_object(grammar * id, const char *source, slang_code_object * object,
                slang_unit_type type, slang_info_log * infolog,
@@ -2673,6 +2677,13 @@ compile_object(grammar * id, const char *source, 
slang_code_object * object,
                              SLANG_UNIT_VERTEX_BUILTIN, infolog, NULL,
                              &object->builtin[SLANG_BUILTIN_COMMON], NULL))
             return GL_FALSE;
+      } else if (type == SLANG_UNIT_GEOMETRY_SHADER) {
+         if (!compile_binary(slang_geometry_builtin_gc,
+                             &object->builtin[SLANG_BUILTIN_TARGET],
+                             base_version,
+                             SLANG_UNIT_GEOMETRY_BUILTIN, infolog, NULL,
+                             &object->builtin[SLANG_BUILTIN_COMMON], NULL))
+            return GL_FALSE;
       }
 
       /* disable language extensions */
diff --git a/src/mesa/shader/slang/slang_emit.c 
b/src/mesa/shader/slang/slang_emit.c
index 18e5a3b..3a654e7 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -2426,7 +2426,7 @@ _slang_emit_code(slang_ir_node *n, slang_var_table *vt,
    else if (prog->Target == GL_VERTEX_PROGRAM_ARB) {
       maxUniforms = ctx->Const.VertexProgram.MaxUniformComponents / 4;
    } else {
-      assert(prog->Target == GL_GEOMETRY_SHADER_ARB);
+      assert(prog->Target == MESA_GEOMETRY_PROGRAM);
       maxUniforms = ctx->Const.GeometryProgram.MaxUniformComponents / 4;
    }
    if (prog->Parameters->NumParameters > maxUniforms) {

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to