mesa: simplify/rename _mesa_init_program_struct()
[mesa.git] / src / mesa / program / program_parse_extra.c
index ae98b782b70523cb237aea3b05ec85d62759f3bf..a9e36404580f145ceecd9ac7b19e0aa9e3fb3f17 100644 (file)
@@ -194,15 +194,21 @@ _mesa_ARBfp_parse_option(struct asm_parser_state *state, const char *option)
       } else if (strncmp(option, "precision_hint_", 15) == 0) {
         option += 15;
 
-        if (state->option.PrecisionHint == OPTION_NONE) {
-           if (strcmp(option, "nicest") == 0) {
-              state->option.PrecisionHint = OPTION_NICEST;
-              return 1;
-           } else if (strcmp(option, "fastest") == 0) {
-              state->option.PrecisionHint = OPTION_FASTEST;
-              return 1;
-           }
-        }
+         /* The ARB_fragment_program spec, 3.11.4.5.2 says:
+          *
+          * "Only one precision control option may be specified by any given
+          * fragment program.  A fragment program that specifies both the
+          * "ARB_precision_hint_fastest" and "ARB_precision_hint_nicest"
+          * program options will fail to load.
+          */
+
+         if (strcmp(option, "nicest") == 0 && state->option.PrecisionHint != OPTION_FASTEST) {
+            state->option.PrecisionHint = OPTION_NICEST;
+            return 1;
+         } else if (strcmp(option, "fastest") == 0 && state->option.PrecisionHint != OPTION_NICEST) {
+            state->option.PrecisionHint = OPTION_FASTEST;
+            return 1;
+         }
 
         return 0;
       } else if (strcmp(option, "draw_buffers") == 0) {
@@ -229,6 +235,16 @@ _mesa_ARBfp_parse_option(struct asm_parser_state *state, const char *option)
             }
          }
       }
+   } else if (strncmp(option, "ATI_", 4) == 0) {
+      option += 4;
+
+      if (strcmp(option, "draw_buffers") == 0) {
+        /* Don't need to check extension availability because all Mesa-based
+         * drivers support GL_ATI_draw_buffers.
+         */
+        state->option.DrawBuffers = 1;
+        return 1;
+      }
    } else if (strncmp(option, "NV_fragment_program", 19) == 0) {
       option += 19;
 
@@ -240,15 +256,6 @@ _mesa_ARBfp_parse_option(struct asm_parser_state *state, const char *option)
            return 1;
         }
       }
-   } else if (strncmp(option, "MESA_", 5) == 0) {
-      option += 5;
-
-      if (strcmp(option, "texture_array") == 0) {
-        if (state->ctx->Extensions.MESA_texture_array) {
-           state->option.TexArray = 1;
-           return 1;
-        }
-      }
    }
 
    return 0;