~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/mesa/shader/program_lexer.l

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%{
2
 
/*
3
 
 * Copyright © 2009 Intel Corporation
4
 
 *
5
 
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 
 * copy of this software and associated documentation files (the "Software"),
7
 
 * to deal in the Software without restriction, including without limitation
8
 
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 
 * and/or sell copies of the Software, and to permit persons to whom the
10
 
 * Software is furnished to do so, subject to the following conditions:
11
 
 *
12
 
 * The above copyright notice and this permission notice (including the next
13
 
 * paragraph) shall be included in all copies or substantial portions of the
14
 
 * Software.
15
 
 *
16
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19
 
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 
 * DEALINGS IN THE SOFTWARE.
23
 
 */
24
 
#include "main/glheader.h"
25
 
#include "main/imports.h"
26
 
#include "shader/prog_instruction.h"
27
 
#include "shader/prog_statevars.h"
28
 
 
29
 
#include "shader/symbol_table.h"
30
 
#include "shader/program_parser.h"
31
 
#include "shader/program_parse.tab.h"
32
 
 
33
 
#define require_ARB_vp (yyextra->mode == ARB_vertex)
34
 
#define require_ARB_fp (yyextra->mode == ARB_fragment)
35
 
#define require_NV_fp  (yyextra->option.NV_fragment)
36
 
#define require_shadow (yyextra->option.Shadow)
37
 
#define require_rect   (yyextra->option.TexRect)
38
 
#define require_texarray        (yyextra->option.TexArray)
39
 
 
40
 
#ifndef HAVE_UNISTD_H
41
 
#define YY_NO_UNISTD_H
42
 
#endif
43
 
 
44
 
#define return_token_or_IDENTIFIER(condition, token)    \
45
 
   do {                                                 \
46
 
      if (condition) {                                  \
47
 
         return token;                                  \
48
 
      } else {                                          \
49
 
         return handle_ident(yyextra, yytext, yylval);  \
50
 
      }                                                 \
51
 
   } while (0)
52
 
 
53
 
#define return_token_or_DOT(condition, token)           \
54
 
   do {                                                 \
55
 
      if (condition) {                                  \
56
 
         return token;                                  \
57
 
      } else {                                          \
58
 
         yyless(1);                                     \
59
 
         return DOT;                                    \
60
 
      }                                                 \
61
 
   } while (0)
62
 
 
63
 
 
64
 
#define return_opcode(condition, token, opcode, len)    \
65
 
   do {                                                 \
66
 
      if (condition &&                                  \
67
 
          _mesa_parse_instruction_suffix(yyextra,       \
68
 
                                         yytext + len,  \
69
 
                                         & yylval->temp_inst)) {        \
70
 
         yylval->temp_inst.Opcode = OPCODE_ ## opcode;  \
71
 
         return token;                                  \
72
 
      } else {                                          \
73
 
         return handle_ident(yyextra, yytext, yylval);  \
74
 
      }                                                 \
75
 
   } while (0)
76
 
 
77
 
#define SWIZZLE_INVAL  MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \
78
 
                                     SWIZZLE_NIL, SWIZZLE_NIL)
79
 
 
80
 
static unsigned
81
 
mask_from_char(char c)
82
 
{
83
 
   switch (c) {
84
 
   case 'x':
85
 
   case 'r':
86
 
      return WRITEMASK_X;
87
 
   case 'y':
88
 
   case 'g':
89
 
      return WRITEMASK_Y;
90
 
   case 'z':
91
 
   case 'b':
92
 
      return WRITEMASK_Z;
93
 
   case 'w':
94
 
   case 'a':
95
 
      return WRITEMASK_W;
96
 
   }
97
 
 
98
 
   return 0;
99
 
}
100
 
 
101
 
static unsigned
102
 
swiz_from_char(char c)
103
 
{
104
 
   switch (c) {
105
 
   case 'x':
106
 
   case 'r':
107
 
      return SWIZZLE_X;
108
 
   case 'y':
109
 
   case 'g':
110
 
      return SWIZZLE_Y;
111
 
   case 'z':
112
 
   case 'b':
113
 
      return SWIZZLE_Z;
114
 
   case 'w':
115
 
   case 'a':
116
 
      return SWIZZLE_W;
117
 
   }
118
 
 
119
 
   return 0;
120
 
}
121
 
 
122
 
static int
123
 
handle_ident(struct asm_parser_state *state, const char *text, YYSTYPE *lval)
124
 
{
125
 
   lval->string = strdup(text);
126
 
 
127
 
   return (_mesa_symbol_table_find_symbol(state->st, 0, text) == NULL)
128
 
      ? IDENTIFIER : USED_IDENTIFIER;
129
 
}
130
 
 
131
 
#define YY_USER_ACTION                                                  \
132
 
   do {                                                                 \
133
 
      yylloc->first_column = yylloc->last_column;                       \
134
 
      yylloc->last_column += yyleng;                                    \
135
 
      if ((yylloc->first_line == 1)                                     \
136
 
          && (yylloc->first_column == 1)) {                             \
137
 
         yylloc->position = 1;                                          \
138
 
      } else {                                                          \
139
 
         yylloc->position += yylloc->last_column - yylloc->first_column; \
140
 
      }                                                                 \
141
 
   } while(0);
142
 
 
143
 
#define YY_EXTRA_TYPE struct asm_parser_state *
144
 
%}
145
 
 
146
 
num    [0-9]+
147
 
exp    [Ee][-+]?[0-9]+
148
 
frac   "."[0-9]+
149
 
dot    "."[ \t]*
150
 
 
151
 
sz     [HRX]?
152
 
szf    [HR]?
153
 
cc     C?
154
 
sat    (_SAT)?
155
 
 
156
 
%option bison-bridge bison-locations reentrant noyywrap
157
 
%%
158
 
 
159
 
"!!ARBvp1.0"              { return ARBvp_10; }
160
 
"!!ARBfp1.0"              { return ARBfp_10; }
161
 
ADDRESS                   {
162
 
   yylval->integer = at_address;
163
 
   return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS);
164
 
}
165
 
ALIAS                     { return ALIAS; }
166
 
ATTRIB                    { return ATTRIB; }
167
 
END                       { return END; }
168
 
OPTION                    { return OPTION; }
169
 
OUTPUT                    { return OUTPUT; }
170
 
PARAM                     { return PARAM; }
171
 
TEMP                      { yylval->integer = at_temp; return TEMP; }
172
 
 
173
 
ABS{sz}{cc}{sat}   { return_opcode(             1, VECTOR_OP, ABS, 3); }
174
 
ADD{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, ADD, 3); }
175
 
ARL                { return_opcode(require_ARB_vp, ARL, ARL, 3); }
176
 
 
177
 
CMP{sat}           { return_opcode(require_ARB_fp, TRI_OP, CMP, 3); }
178
 
COS{szf}{cc}{sat}  { return_opcode(require_ARB_fp, SCALAR_OP, COS, 3); }
179
 
 
180
 
DDX{szf}{cc}{sat}  { return_opcode(require_NV_fp,  VECTOR_OP, DDX, 3); }
181
 
DDY{szf}{cc}{sat}  { return_opcode(require_NV_fp,  VECTOR_OP, DDY, 3); }
182
 
DP3{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, DP3, 3); }
183
 
DP4{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, DP4, 3); }
184
 
DPH{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, DPH, 3); }
185
 
DST{szf}{cc}{sat}  { return_opcode(             1, BIN_OP, DST, 3); }
186
 
 
187
 
EX2{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, EX2, 3); }
188
 
EXP                { return_opcode(require_ARB_vp, SCALAR_OP, EXP, 3); }
189
 
 
190
 
FLR{sz}{cc}{sat}   { return_opcode(             1, VECTOR_OP, FLR, 3); }
191
 
FRC{sz}{cc}{sat}   { return_opcode(             1, VECTOR_OP, FRC, 3); }
192
 
 
193
 
KIL                { return_opcode(require_ARB_fp, KIL, KIL, 3); }
194
 
 
195
 
LIT{szf}{cc}{sat}  { return_opcode(             1, VECTOR_OP, LIT, 3); }
196
 
LG2{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, LG2, 3); }
197
 
LOG                { return_opcode(require_ARB_vp, SCALAR_OP, LOG, 3); }
198
 
LRP{sz}{cc}{sat}   { return_opcode(require_ARB_fp, TRI_OP, LRP, 3); }
199
 
 
200
 
MAD{sz}{cc}{sat}   { return_opcode(             1, TRI_OP, MAD, 3); }
201
 
MAX{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, MAX, 3); }
202
 
MIN{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, MIN, 3); }
203
 
MOV{sz}{cc}{sat}   { return_opcode(             1, VECTOR_OP, MOV, 3); }
204
 
MUL{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, MUL, 3); }
205
 
 
206
 
PK2H               { return_opcode(require_NV_fp,  VECTOR_OP, PK2H, 4); }
207
 
PK2US              { return_opcode(require_NV_fp,  VECTOR_OP, PK2US, 5); }
208
 
PK4B               { return_opcode(require_NV_fp,  VECTOR_OP, PK4B, 4); }
209
 
PK4UB              { return_opcode(require_NV_fp,  VECTOR_OP, PK4UB, 5); }
210
 
POW{szf}{cc}{sat}  { return_opcode(             1, BINSC_OP, POW, 3); }
211
 
 
212
 
RCP{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, RCP, 3); }
213
 
RFL{szf}{cc}{sat}  { return_opcode(require_NV_fp,  BIN_OP,    RFL, 3); }
214
 
RSQ{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, RSQ, 3); }
215
 
 
216
 
SCS{sat}           { return_opcode(require_ARB_fp, SCALAR_OP, SCS, 3); }
217
 
SEQ{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SEQ, 3); }
218
 
SFL{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SFL, 3); }
219
 
SGE{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, SGE, 3); }
220
 
SGT{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SGT, 3); }
221
 
SIN{szf}{cc}{sat}  { return_opcode(require_ARB_fp, SCALAR_OP, SIN, 3); }
222
 
SLE{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SLE, 3); }
223
 
SLT{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, SLT, 3); }
224
 
SNE{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SNE, 3); }
225
 
STR{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, STR, 3); }
226
 
SUB{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, SUB, 3); }
227
 
SWZ{sat}           { return_opcode(             1, SWZ, SWZ, 3); }
228
 
 
229
 
TEX{cc}{sat}       { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, 3); }
230
 
TXB{cc}{sat}       { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, 3); }
231
 
TXD{cc}{sat}       { return_opcode(require_NV_fp,  TXD_OP, TXD, 3); }
232
 
TXP{cc}{sat}       { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, 3); }
233
 
 
234
 
UP2H{cc}{sat}      { return_opcode(require_NV_fp,  SCALAR_OP, UP2H, 4); }
235
 
UP2US{cc}{sat}     { return_opcode(require_NV_fp,  SCALAR_OP, UP2US, 5); }
236
 
UP4B{cc}{sat}      { return_opcode(require_NV_fp,  SCALAR_OP, UP4B, 4); }
237
 
UP4UB{cc}{sat}     { return_opcode(require_NV_fp,  SCALAR_OP, UP4UB, 5); }
238
 
 
239
 
X2D{szf}{cc}{sat}  { return_opcode(require_NV_fp,  TRI_OP, X2D, 3); }
240
 
XPD{sat}           { return_opcode(             1, BIN_OP, XPD, 3); }
241
 
 
242
 
vertex                    { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); }
243
 
fragment                  { return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); }
244
 
program                   { return PROGRAM; }
245
 
state                     { return STATE; }
246
 
result                    { return RESULT; }
247
 
 
248
 
{dot}ambient              { return AMBIENT; }
249
 
{dot}attenuation          { return ATTENUATION; }
250
 
{dot}back                 { return BACK; }
251
 
{dot}clip                 { return_token_or_DOT(require_ARB_vp, CLIP); }
252
 
{dot}color                { return COLOR; }
253
 
{dot}depth                { return_token_or_DOT(require_ARB_fp, DEPTH); }
254
 
{dot}diffuse              { return DIFFUSE; }
255
 
{dot}direction            { return DIRECTION; }
256
 
{dot}emission             { return EMISSION; }
257
 
{dot}env                  { return ENV; }
258
 
{dot}eye                  { return EYE; }
259
 
{dot}fogcoord             { return FOGCOORD; }
260
 
{dot}fog                  { return FOG; }
261
 
{dot}front                { return FRONT; }
262
 
{dot}half                 { return HALF; }
263
 
{dot}inverse              { return INVERSE; }
264
 
{dot}invtrans             { return INVTRANS; }
265
 
{dot}light                { return LIGHT; }
266
 
{dot}lightmodel           { return LIGHTMODEL; }
267
 
{dot}lightprod            { return LIGHTPROD; }
268
 
{dot}local                { return LOCAL; }
269
 
{dot}material             { return MATERIAL; }
270
 
{dot}program              { return MAT_PROGRAM; }
271
 
{dot}matrix               { return MATRIX; }
272
 
{dot}matrixindex          { return_token_or_DOT(require_ARB_vp, MATRIXINDEX); }
273
 
{dot}modelview            { return MODELVIEW; }
274
 
{dot}mvp                  { return MVP; }
275
 
{dot}normal               { return_token_or_DOT(require_ARB_vp, NORMAL); }
276
 
{dot}object               { return OBJECT; }
277
 
{dot}palette              { return PALETTE; }
278
 
{dot}params               { return PARAMS; }
279
 
{dot}plane                { return PLANE; }
280
 
{dot}point                { return_token_or_DOT(require_ARB_vp, POINT_TOK); }
281
 
{dot}pointsize            { return_token_or_DOT(require_ARB_vp, POINTSIZE); }
282
 
{dot}position             { return POSITION; }
283
 
{dot}primary              { return PRIMARY; }
284
 
{dot}projection           { return PROJECTION; }
285
 
{dot}range                { return_token_or_DOT(require_ARB_fp, RANGE); }
286
 
{dot}row                  { return ROW; }
287
 
{dot}scenecolor           { return SCENECOLOR; }
288
 
{dot}secondary            { return SECONDARY; }
289
 
{dot}shininess            { return SHININESS; }
290
 
{dot}size                 { return_token_or_DOT(require_ARB_vp, SIZE_TOK); }
291
 
{dot}specular             { return SPECULAR; }
292
 
{dot}spot                 { return SPOT; }
293
 
{dot}texcoord             { return TEXCOORD; }
294
 
{dot}texenv               { return_token_or_DOT(require_ARB_fp, TEXENV); }
295
 
{dot}texgen               { return_token_or_DOT(require_ARB_vp, TEXGEN); }
296
 
{dot}q                    { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); }
297
 
{dot}s                    { return_token_or_DOT(require_ARB_vp, TEXGEN_S); }
298
 
{dot}t                    { return_token_or_DOT(require_ARB_vp, TEXGEN_T); }
299
 
{dot}texture              { return TEXTURE; }
300
 
{dot}transpose            { return TRANSPOSE; }
301
 
{dot}attrib               { return_token_or_DOT(require_ARB_vp, VTXATTRIB); }
302
 
{dot}weight               { return_token_or_DOT(require_ARB_vp, WEIGHT); }
303
 
 
304
 
texture                   { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); }
305
 
1D                        { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); }
306
 
2D                        { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); }
307
 
3D                        { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); }
308
 
CUBE                      { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); }
309
 
RECT                      { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); }
310
 
SHADOW1D                  { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); }
311
 
SHADOW2D                  { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); }
312
 
SHADOWRECT                { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); }
313
 
ARRAY1D                   { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); }
314
 
ARRAY2D                   { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); }
315
 
ARRAYSHADOW1D             { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); }
316
 
ARRAYSHADOW2D             { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); }
317
 
 
318
 
[_a-zA-Z$][_a-zA-Z0-9$]*  { return handle_ident(yyextra, yytext, yylval); }
319
 
 
320
 
".."                      { return DOT_DOT; }
321
 
 
322
 
{num}                     {
323
 
   yylval->integer = strtol(yytext, NULL, 10);
324
 
   return INTEGER;
325
 
}
326
 
{num}?{frac}{exp}?        {
327
 
   yylval->real = _mesa_strtof(yytext, NULL);
328
 
   return REAL;
329
 
}
330
 
{num}"."/[^.]             {
331
 
   yylval->real = _mesa_strtof(yytext, NULL);
332
 
   return REAL;
333
 
}
334
 
{num}{exp}                {
335
 
   yylval->real = _mesa_strtof(yytext, NULL);
336
 
   return REAL;
337
 
}
338
 
{num}"."{exp}             {
339
 
   yylval->real = _mesa_strtof(yytext, NULL);
340
 
   return REAL;
341
 
}
342
 
 
343
 
".xyzw"                   {
344
 
   yylval->swiz_mask.swizzle = SWIZZLE_NOOP;
345
 
   yylval->swiz_mask.mask = WRITEMASK_XYZW;
346
 
   return MASK4;
347
 
}
348
 
 
349
 
".xy"[zw]                 {
350
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
351
 
   yylval->swiz_mask.mask = WRITEMASK_XY
352
 
      | mask_from_char(yytext[3]);
353
 
   return MASK3;
354
 
}
355
 
".xzw"                    {
356
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
357
 
   yylval->swiz_mask.mask = WRITEMASK_XZW;
358
 
   return MASK3;
359
 
}
360
 
".yzw"                    {
361
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
362
 
   yylval->swiz_mask.mask = WRITEMASK_YZW;
363
 
   return MASK3;
364
 
}
365
 
 
366
 
".x"[yzw]                 {
367
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
368
 
   yylval->swiz_mask.mask = WRITEMASK_X
369
 
      | mask_from_char(yytext[2]);
370
 
   return MASK2;
371
 
}
372
 
".y"[zw]                  {
373
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
374
 
   yylval->swiz_mask.mask = WRITEMASK_Y
375
 
      | mask_from_char(yytext[2]);
376
 
   return MASK2;
377
 
}
378
 
".zw"                     {
379
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
380
 
   yylval->swiz_mask.mask = WRITEMASK_ZW;
381
 
   return MASK2;
382
 
}
383
 
 
384
 
"."[xyzw]                 {
385
 
   const unsigned s = swiz_from_char(yytext[1]);
386
 
   yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s);
387
 
   yylval->swiz_mask.mask = mask_from_char(yytext[1]);
388
 
   return MASK1; 
389
 
}
390
 
 
391
 
"."[xyzw]{4}              {
392
 
   yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]),
393
 
                                            swiz_from_char(yytext[2]),
394
 
                                            swiz_from_char(yytext[3]),
395
 
                                            swiz_from_char(yytext[4]));
396
 
   yylval->swiz_mask.mask = 0;
397
 
   return SWIZZLE;
398
 
}
399
 
 
400
 
".rgba"                   {
401
 
   yylval->swiz_mask.swizzle = SWIZZLE_NOOP;
402
 
   yylval->swiz_mask.mask = WRITEMASK_XYZW;
403
 
   return_token_or_DOT(require_ARB_fp, MASK4);
404
 
}
405
 
 
406
 
".rg"[ba]                 {
407
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
408
 
   yylval->swiz_mask.mask = WRITEMASK_XY
409
 
      | mask_from_char(yytext[3]);
410
 
   return_token_or_DOT(require_ARB_fp, MASK3);
411
 
}
412
 
".rba"                    {
413
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
414
 
   yylval->swiz_mask.mask = WRITEMASK_XZW;
415
 
   return_token_or_DOT(require_ARB_fp, MASK3);
416
 
}
417
 
".gba"                    {
418
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
419
 
   yylval->swiz_mask.mask = WRITEMASK_YZW;
420
 
   return_token_or_DOT(require_ARB_fp, MASK3);
421
 
}
422
 
 
423
 
".r"[gba]                 {
424
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
425
 
   yylval->swiz_mask.mask = WRITEMASK_X
426
 
      | mask_from_char(yytext[2]);
427
 
   return_token_or_DOT(require_ARB_fp, MASK2);
428
 
}
429
 
".g"[ba]                  {
430
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
431
 
   yylval->swiz_mask.mask = WRITEMASK_Y
432
 
      | mask_from_char(yytext[2]);
433
 
   return_token_or_DOT(require_ARB_fp, MASK2);
434
 
}
435
 
".ba"                     {
436
 
   yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
437
 
   yylval->swiz_mask.mask = WRITEMASK_ZW;
438
 
   return_token_or_DOT(require_ARB_fp, MASK2);
439
 
}
440
 
 
441
 
"."[gba]                  {
442
 
   const unsigned s = swiz_from_char(yytext[1]);
443
 
   yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s);
444
 
   yylval->swiz_mask.mask = mask_from_char(yytext[1]);
445
 
   return_token_or_DOT(require_ARB_fp, MASK1);
446
 
}
447
 
 
448
 
 
449
 
".r"                      {
450
 
   if (require_ARB_vp) {
451
 
      return TEXGEN_R;
452
 
   } else {
453
 
      yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X,
454
 
                                                SWIZZLE_X, SWIZZLE_X);
455
 
      yylval->swiz_mask.mask = WRITEMASK_X;
456
 
      return MASK1;
457
 
   }
458
 
}
459
 
 
460
 
"."[rgba]{4}              {
461
 
   yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]),
462
 
                                            swiz_from_char(yytext[2]),
463
 
                                            swiz_from_char(yytext[3]),
464
 
                                            swiz_from_char(yytext[4]));
465
 
   yylval->swiz_mask.mask = 0;
466
 
   return_token_or_DOT(require_ARB_fp, SWIZZLE);
467
 
}
468
 
 
469
 
"."                       { return DOT; }
470
 
 
471
 
\n                        {
472
 
   yylloc->first_line++;
473
 
   yylloc->first_column = 1;
474
 
   yylloc->last_line++;
475
 
   yylloc->last_column = 1;
476
 
   yylloc->position++;
477
 
}
478
 
[ \t\r]+                  /* eat whitespace */ ;
479
 
#.*$                      /* eat comments */ ;
480
 
.                         { return yytext[0]; }
481
 
%%
482
 
 
483
 
void
484
 
_mesa_program_lexer_ctor(void **scanner, struct asm_parser_state *state,
485
 
                         const char *string, size_t len)
486
 
{
487
 
   yylex_init_extra(state, scanner);
488
 
   yy_scan_bytes(string, len, *scanner);
489
 
}
490
 
 
491
 
void
492
 
_mesa_program_lexer_dtor(void *scanner)
493
 
{
494
 
   yylex_destroy(scanner);
495
 
}