Mesa (master): glsl: add more vertex/fragment output info helpers

Brian Paul brianp at kemper.freedesktop.org
Fri Apr 2 04:20:01 UTC 2010


Module: Mesa
Branch: master
Commit: ee91c1e367b9e3bcbb156ed80ab94694f0d4b4ca
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ee91c1e367b9e3bcbb156ed80ab94694f0d4b4ca

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Apr  1 22:15:16 2010 -0600

glsl: add more vertex/fragment output info helpers

---

 src/mesa/shader/slang/slang_builtin.c |   67 ++++++++++++++++++++++++++------
 src/mesa/shader/slang/slang_builtin.h |   10 +++++
 2 files changed, 64 insertions(+), 13 deletions(-)

diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c
index 791e751..492d423 100644
--- a/src/mesa/shader/slang/slang_builtin.c
+++ b/src/mesa/shader/slang/slang_builtin.c
@@ -839,27 +839,28 @@ struct output_info
 {
    const char *Name;
    GLuint Attrib;
+   GLenum Type;
 };
 
 /** Predefined vertex shader outputs */
 static const struct output_info vertOutputs[] = {
-   { "gl_Position", VERT_RESULT_HPOS },
-   { "gl_FrontColor", VERT_RESULT_COL0 },
-   { "gl_BackColor", VERT_RESULT_BFC0 },
-   { "gl_FrontSecondaryColor", VERT_RESULT_COL1 },
-   { "gl_BackSecondaryColor", VERT_RESULT_BFC1 },
-   { "gl_TexCoord", VERT_RESULT_TEX0 },
-   { "gl_FogFragCoord", VERT_RESULT_FOGC },
-   { "gl_PointSize", VERT_RESULT_PSIZ },
-   { NULL, 0 }
+   { "gl_Position", VERT_RESULT_HPOS, GL_FLOAT_VEC4 },
+   { "gl_FrontColor", VERT_RESULT_COL0, GL_FLOAT_VEC4 },
+   { "gl_BackColor", VERT_RESULT_BFC0, GL_FLOAT_VEC4 },
+   { "gl_FrontSecondaryColor", VERT_RESULT_COL1, GL_FLOAT_VEC4 },
+   { "gl_BackSecondaryColor", VERT_RESULT_BFC1, GL_FLOAT_VEC4 },
+   { "gl_TexCoord", VERT_RESULT_TEX0, GL_FLOAT_VEC4 },
+   { "gl_FogFragCoord", VERT_RESULT_FOGC, GL_FLOAT },
+   { "gl_PointSize", VERT_RESULT_PSIZ, GL_FLOAT },
+   { NULL, 0, GL_NONE }
 };
 
 /** Predefined fragment shader outputs */
 static const struct output_info fragOutputs[] = {
-   { "gl_FragColor", FRAG_RESULT_COLOR },
-   { "gl_FragDepth", FRAG_RESULT_DEPTH },
-   { "gl_FragData", FRAG_RESULT_DATA0 },
-   { NULL, 0 }
+   { "gl_FragColor", FRAG_RESULT_COLOR, GL_FLOAT_VEC4 },
+   { "gl_FragDepth", FRAG_RESULT_DEPTH, GL_FLOAT },
+   { "gl_FragData", FRAG_RESULT_DATA0, GL_FLOAT_VEC4 },
+   { NULL, 0, GL_NONE }
 };
 
 
@@ -895,3 +896,43 @@ _slang_output_index(const char *name, GLenum target)
    }
    return -1;
 }
+
+
+/**
+ * Given a VERT_RESULT_x index, return the corresponding string name.
+ */
+const char *
+_slang_vertex_output_name(gl_vert_result index)
+{
+   if (index < Elements(vertOutputs))
+      return vertOutputs[index].Name;
+   else
+      return NULL;
+}
+
+
+/**
+ * Given a FRAG_RESULT_x index, return the corresponding string name.
+ */
+const char *
+_slang_fragment_output_name(gl_frag_result index)
+{
+   if (index < Elements(fragOutputs))
+      return fragOutputs[index].Name;
+   else
+      return NULL;
+}
+
+
+/**
+ * Given a VERT_RESULT_x index, return the corresponding varying
+ * var's datatype.
+ */
+GLenum
+_slang_vertex_output_type(gl_vert_result index)
+{
+   if (index < Elements(vertOutputs))
+      return vertOutputs[index].Type;
+   else
+      return GL_NONE;
+}
diff --git a/src/mesa/shader/slang/slang_builtin.h b/src/mesa/shader/slang/slang_builtin.h
index f814d11..c3021ca 100644
--- a/src/mesa/shader/slang/slang_builtin.h
+++ b/src/mesa/shader/slang/slang_builtin.h
@@ -51,4 +51,14 @@ extern GLenum
 _slang_vert_attrib_type(GLuint attrib);
 
 
+const char *
+_slang_vertex_output_name(gl_vert_result index);
+
+const char *
+_slang_fragment_output_name(gl_frag_result index);
+
+GLenum
+_slang_vertex_output_type(gl_vert_result index);
+
+
 #endif /* SLANG_BUILTIN_H */




More information about the mesa-commit mailing list