mesa: glsl: finish up support for precision qualifiers
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 7 Aug 2008 16:26:35 +0000 (10:26 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 7 Aug 2008 19:32:43 +0000 (13:32 -0600)
src/mesa/shader/slang/slang_compile.c
src/mesa/shader/slang/slang_compile_variable.h

index 2a1af39ee07bf6094bae29ba971197f757b36fec..64c0dad611d449dafd73c67cba0a955b0441549e 100644 (file)
@@ -707,20 +707,33 @@ parse_fully_specified_type(slang_parse_ctx * C, slang_output_ctx * O,
    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.
-       */
+      assert(type->specifier.type < TYPE_SPECIFIER_COUNT);
+      if (type->specifier.type < TYPE_SPECIFIER_COUNT)
+         type->precision = O->default_precision[type->specifier.type];
       break;
    case PRECISION_LOW:
+      type->precision = SLANG_PREC_LOW;
+      break;
    case PRECISION_MEDIUM:
+      type->precision = SLANG_PREC_MEDIUM;
+      break;
    case PRECISION_HIGH:
-      /* TODO: Translate to mesa representation.
-       */
+      type->precision = SLANG_PREC_HIGH;
       break;
    default:
       return 0;
    }
+
+#if !FEATURE_es2_glsl
+   if (precision != PRECISION_DEFAULT) {
+      slang_info_log_error(C->L, "precision qualifiers not allowed");
+      return 0;
+   }
+#endif
+
    return 1;
 }
 
index 9b0f85859a4ce0517cf2fc9ece8d372f5215e63e..d81a3d28699649d1dda13928a2acd989aa3edc34 100644 (file)
@@ -51,10 +51,20 @@ slang_type_specifier_type_to_string(slang_type_specifier_type);
 
 
 
+typedef enum slang_type_precision_
+{
+   SLANG_PREC_DEFAULT,
+   SLANG_PREC_LOW,
+   SLANG_PREC_MEDIUM,
+   SLANG_PREC_HIGH
+} slang_type_precision;
+
+
 typedef struct slang_fully_specified_type_
 {
    slang_type_qualifier qualifier;
    slang_type_specifier specifier;
+   slang_type_precision precision;
 } slang_fully_specified_type;
 
 extern int