slang: No need to purify source text for tokeniser.
[mesa.git] / src / mesa / shader / program_parse_extra.c
1 /*
2 * Copyright © 2009 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 #include <string.h>
25 #include "main/mtypes.h"
26 #include "prog_instruction.h"
27 #include "program_parser.h"
28
29
30 /**
31 * Extra assembly-level parser routines
32 *
33 * \author Ian Romanick <ian.d.romanick@intel.com>
34 */
35
36 int
37 _mesa_ARBvp_parse_option(struct asm_parser_state *state, const char *option)
38 {
39 if (strcmp(option, "ARB_position_invariant") == 0) {
40 state->option.PositionInvariant = 1;
41 return 1;
42 }
43
44 return 0;
45 }
46
47
48 int
49 _mesa_ARBfp_parse_option(struct asm_parser_state *state, const char *option)
50 {
51 /* All of the options currently supported start with "ARB_". The code is
52 * currently structured with nested if-statements because eventually options
53 * that start with "NV_" will be supported. This structure will result in
54 * less churn when those options are added.
55 */
56 if (strncmp(option, "ARB_", 4) == 0) {
57 /* Advance the pointer past the "ARB_" prefix.
58 */
59 option += 4;
60
61
62 if (strncmp(option, "fog_", 4) == 0) {
63 option += 4;
64
65 if (state->option.Fog == OPTION_NONE) {
66 if (strcmp(option, "exp") == 0) {
67 state->option.Fog = OPTION_FOG_EXP;
68 return 1;
69 } else if (strcmp(option, "exp2") == 0) {
70 state->option.Fog = OPTION_FOG_EXP2;
71 return 1;
72 } else if (strcmp(option, "linear") == 0) {
73 state->option.Fog = OPTION_FOG_LINEAR;
74 return 1;
75 }
76 }
77
78 return 0;
79 } else if (strncmp(option, "precision_hint_", 15) == 0) {
80 option += 15;
81
82 if (state->option.PrecisionHint == OPTION_NONE) {
83 if (strcmp(option, "nicest") == 0) {
84 state->option.PrecisionHint = OPTION_NICEST;
85 return 1;
86 } else if (strcmp(option, "fastest") == 0) {
87 state->option.PrecisionHint = OPTION_FASTEST;
88 return 1;
89 }
90 }
91
92 return 0;
93 } else if (strcmp(option, "draw_buffers") == 0) {
94 /* Don't need to check extension availability because all Mesa-based
95 * drivers support GL_ARB_draw_buffers.
96 */
97 state->option.DrawBuffers = 1;
98 return 1;
99 } else if (strcmp(option, "fragment_program_shadow") == 0) {
100 if (state->ctx->Extensions.ARB_fragment_program_shadow) {
101 state->option.Shadow = 1;
102 return 1;
103 }
104 }
105 } else if (strncmp(option, "MESA_", 5) == 0) {
106 option += 5;
107
108 if (strcmp(option, "texture_array") == 0) {
109 if (state->ctx->Extensions.MESA_texture_array) {
110 state->option.TexArray = 1;
111 return 1;
112 }
113 }
114 }
115
116 return 0;
117 }