mesa: Extend GLSL syntax to accept type precision in full type specifiers.
authorMichal Krol <michal@tungstengraphics.com>
Thu, 7 Aug 2008 14:49:54 +0000 (16:49 +0200)
committerMichal Krol <michal@tungstengraphics.com>
Thu, 7 Aug 2008 14:49:54 +0000 (16:49 +0200)
src/mesa/shader/slang/library/slang_shader.syn
src/mesa/shader/slang/library/slang_shader_syn.h
src/mesa/shader/slang/slang_compile.c

index 4505758520a4e62766281d0acc9c8dd66a4e0860..06bd8ac883c2f0f22d7fb96766732e59a359d220 100644 (file)
@@ -49,7 +49,7 @@
 .syntax translation_unit;
 
 /* revision number - increment after each change affecting emitted output */
-.emtcode REVISION                                   3
+.emtcode REVISION                                   4
 
 /* external declaration (or precision or invariant stmt) */
 .emtcode EXTERNAL_NULL                              0
 .emtcode INVARIANT_STMT                             4
 
 /* precision */
-.emtcode PRECISION_LOW                              0
-.emtcode PRECISION_MEDIUM                           1
-.emtcode PRECISION_HIGH                             2
+.emtcode PRECISION_DEFAULT                          0
+.emtcode PRECISION_LOW                              1
+.emtcode PRECISION_MEDIUM                           2
+.emtcode PRECISION_HIGH                             3
 
 /* declaration */
 .emtcode DECLARATION_FUNCTION_PROTOTYPE             1
@@ -855,15 +856,21 @@ single_declaration_6
 /*
     <fully_specified_type>              ::= <type_specifier>
                                           | <type_qualifier> <type_specifier>
+                                          | <precision> <type_specifier>
+                                          | <type_qualifier> <precision> <type_specifier>
 */
 fully_specified_type_space
-    fully_specified_type_1 .and type_specifier_space;
+    fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
 fully_specified_type_nospace
-    fully_specified_type_1 .and type_specifier_nospace;
-fully_specified_type_1
-    fully_specified_type_2 .or .true .emit TYPE_QUALIFIER_NONE;
-fully_specified_type_2
+    fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
+fully_specified_type_optqual
+    fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;
+fully_specified_type_qual
     type_qualifier .and space;
+fully_specified_type_optprec
+    fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;
+fully_specified_type_prec
+    precision .and space;
 
 /*
     <type_qualifier>                    ::= "const"
index 0c4c14f9d1ed65a48f753e253c643c06e490f511..1b258fcdc13dddc81aff50dd35b1eabe9c410972 100644 (file)
@@ -2,15 +2,16 @@
 /* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */
 
 ".syntax translation_unit;\n"
-".emtcode REVISION 3\n"
+".emtcode REVISION 4\n"
 ".emtcode EXTERNAL_NULL 0\n"
 ".emtcode EXTERNAL_FUNCTION_DEFINITION 1\n"
 ".emtcode EXTERNAL_DECLARATION 2\n"
 ".emtcode DEFAULT_PRECISION 3\n"
 ".emtcode INVARIANT_STMT 4\n"
-".emtcode PRECISION_LOW 0\n"
-".emtcode PRECISION_MEDIUM 1\n"
-".emtcode PRECISION_HIGH 2\n"
+".emtcode PRECISION_DEFAULT 0\n"
+".emtcode PRECISION_LOW 1\n"
+".emtcode PRECISION_MEDIUM 2\n"
+".emtcode PRECISION_HIGH 3\n"
 ".emtcode DECLARATION_FUNCTION_PROTOTYPE 1\n"
 ".emtcode DECLARATION_INIT_DECLARATOR_LIST 2\n"
 ".emtcode FUNCTION_ORDINARY 0\n"
 "single_declaration_6\n"
 " constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n"
 "fully_specified_type_space\n"
-" fully_specified_type_1 .and type_specifier_space;\n"
+" fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;\n"
 "fully_specified_type_nospace\n"
-" fully_specified_type_1 .and type_specifier_nospace;\n"
-"fully_specified_type_1\n"
-" fully_specified_type_2 .or .true .emit TYPE_QUALIFIER_NONE;\n"
-"fully_specified_type_2\n"
+" fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;\n"
+"fully_specified_type_optqual\n"
+" fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;\n"
+"fully_specified_type_qual\n"
 " type_qualifier .and space;\n"
+"fully_specified_type_optprec\n"
+" fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;\n"
+"fully_specified_type_prec\n"
+" precision .and space;\n"
 "type_qualifier\n"
 " \"const\" .emit TYPE_QUALIFIER_CONST .or\n"
 " .if (shader_type == 2) \"attribute\" .emit TYPE_QUALIFIER_ATTRIBUTE .or\n"
index f90bbd8c567f127b595d48ed70b1eba958048b64..2a1af39ee07bf6094bae29ba971197f757b36fec 100644 (file)
@@ -237,7 +237,7 @@ parse_float(slang_parse_ctx * C, float *number)
 }
 
 /* revision number - increment after each change affecting emitted output */
-#define REVISION 3
+#define REVISION 4
 
 static int
 check_revision(slang_parse_ctx * C)
@@ -691,14 +691,36 @@ parse_type_specifier(slang_parse_ctx * C, slang_output_ctx * O,
    return 1;
 }
 
+#define PRECISION_DEFAULT 0
+#define PRECISION_LOW     1
+#define PRECISION_MEDIUM  2
+#define PRECISION_HIGH    3
+
 static int
 parse_fully_specified_type(slang_parse_ctx * C, slang_output_ctx * O,
                            slang_fully_specified_type * type)
 {
+   GLuint precision;
+
    if (!parse_type_qualifier(C, &type->qualifier))
       return 0;
+   precision = *C->I++;
    if (!parse_type_specifier(C, O, &type->specifier))
       return 0;
+   switch (precision) {
+   case PRECISION_DEFAULT:
+      /* TODO: Grab the default precision for the given type specifier.
+       */
+      break;
+   case PRECISION_LOW:
+   case PRECISION_MEDIUM:
+   case PRECISION_HIGH:
+      /* TODO: Translate to mesa representation.
+       */
+      break;
+   default:
+      return 0;
+   }
    return 1;
 }
 
@@ -1869,11 +1891,6 @@ parse_declaration(slang_parse_ctx * C, slang_output_ctx * O)
    return 1;
 }
 
-
-#define PRECISION_LOW    0
-#define PRECISION_MEDIUM 1
-#define PRECISION_HIGH   2
-
 static int
 parse_default_precision(slang_parse_ctx * C, slang_output_ctx * O)
 {