linker: Link built-in functions instead of including them in every shader
[mesa.git] / src / glsl / glsl_parser_extras.h
index e2efbd9ac9fcfa10dedb1c13407c4b77dda54d44..56f6e18e0bd990d6892b6837d9a2c61e4d78a10e 100644 (file)
@@ -125,6 +125,10 @@ struct _mesa_glsl_parse_state {
 
    /** Extensions supported by the OpenGL implementation. */
    const struct gl_extensions *extensions;
+
+   /** Shaders containing built-in functions that are used for linking. */
+   struct gl_shader *builtins_to_link[16];
+   unsigned num_builtins_to_link;
 };
 
 typedef struct YYLTYPE {
@@ -137,6 +141,25 @@ typedef struct YYLTYPE {
 # define YYLTYPE_IS_DECLARED 1
 # define YYLTYPE_IS_TRIVIAL 1
 
+# define YYLLOC_DEFAULT(Current, Rhs, N)                       \
+do {                                                           \
+   if (N)                                                      \
+   {                                                           \
+      (Current).first_line   = YYRHSLOC(Rhs, 1).first_line;    \
+      (Current).first_column = YYRHSLOC(Rhs, 1).first_column;  \
+      (Current).last_line    = YYRHSLOC(Rhs, N).last_line;     \
+      (Current).last_column  = YYRHSLOC(Rhs, N).last_column;   \
+   }                                                           \
+   else                                                                \
+   {                                                           \
+      (Current).first_line   = (Current).last_line =           \
+        YYRHSLOC(Rhs, 0).last_line;                            \
+      (Current).first_column = (Current).last_column =         \
+        YYRHSLOC(Rhs, 0).last_column;                          \
+   }                                                           \
+   (Current).source = 0;                                       \
+} while (0)
+
 extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
                             const char *fmt, ...);