| 1 | %start WholeEnchilada |
|---|
| 2 | %name-prefix="rc10_" |
|---|
| 3 | %{ |
|---|
| 4 | void yyerror(char* s); |
|---|
| 5 | int yylex ( void ); |
|---|
| 6 | |
|---|
| 7 | #ifdef _WIN32 |
|---|
| 8 | # include <windows.h> |
|---|
| 9 | #endif |
|---|
| 10 | |
|---|
| 11 | #include <stdio.h> |
|---|
| 12 | #include <stdlib.h> |
|---|
| 13 | |
|---|
| 14 | #include "rc1.0_combiners.h" |
|---|
| 15 | #include "nvparse_errors.h" |
|---|
| 16 | #include "nvparse_externs.h" |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | %} |
|---|
| 20 | %union { |
|---|
| 21 | int ival; |
|---|
| 22 | float fval; |
|---|
| 23 | RegisterEnum registerEnum; |
|---|
| 24 | BiasScaleEnum biasScaleEnum; |
|---|
| 25 | MappedRegisterStruct mappedRegisterStruct; |
|---|
| 26 | ConstColorStruct constColorStruct; |
|---|
| 27 | GeneralPortionStruct generalPortionStruct; |
|---|
| 28 | GeneralFunctionStruct generalFunctionStruct; |
|---|
| 29 | OpStruct opStruct; |
|---|
| 30 | GeneralCombinerStruct generalCombinerStruct; |
|---|
| 31 | GeneralCombinersStruct generalCombinersStruct; |
|---|
| 32 | FinalProductStruct finalProductStruct; |
|---|
| 33 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 34 | FinalAlphaFunctionStruct finalAlphaFunctionStruct; |
|---|
| 35 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 36 | CombinersStruct combinersStruct; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | %token <registerEnum> regVariable constVariable color_sum final_product |
|---|
| 40 | %token <ival> expandString halfBiasString unsignedString unsignedInvertString muxString sumString |
|---|
| 41 | %token <ival> rgb_portion alpha_portion |
|---|
| 42 | %token <ival> openParen closeParen openBracket closeBracket semicolon comma |
|---|
| 43 | %token <ival> dot times minus equals plus |
|---|
| 44 | %token <biasScaleEnum> bias_by_negative_one_half_scale_by_two bias_by_negative_one_half |
|---|
| 45 | %token <biasScaleEnum> scale_by_one_half scale_by_two scale_by_four |
|---|
| 46 | |
|---|
| 47 | %token <ival> clamp_color_sum lerp |
|---|
| 48 | %token <ival> fragment_rgb fragment_alpha |
|---|
| 49 | |
|---|
| 50 | %token <fval> floatValue |
|---|
| 51 | |
|---|
| 52 | %type <combinersStruct> WholeEnchilada Combiners |
|---|
| 53 | |
|---|
| 54 | %type <constColorStruct> ConstColor |
|---|
| 55 | %type <generalCombinerStruct> GeneralCombiner |
|---|
| 56 | %type <generalCombinersStruct> GeneralCombiners |
|---|
| 57 | %type <ival> PortionDesignator |
|---|
| 58 | %type <opStruct> Mux Sum Dot Mul |
|---|
| 59 | %type <generalPortionStruct> GeneralPortion |
|---|
| 60 | %type <generalFunctionStruct> GeneralFunction |
|---|
| 61 | %type <biasScaleEnum> BiasScale |
|---|
| 62 | |
|---|
| 63 | %type <registerEnum> Register |
|---|
| 64 | %type <mappedRegisterStruct> GeneralMappedRegister FinalMappedRegister |
|---|
| 65 | %type <finalProductStruct> FinalProduct |
|---|
| 66 | %type <ival> ClampColorSum |
|---|
| 67 | %type <finalRgbFunctionStruct> FinalRgbFunction |
|---|
| 68 | %type <finalAlphaFunctionStruct> FinalAlphaFunction |
|---|
| 69 | %type <finalCombinerStruct> FinalCombiner |
|---|
| 70 | |
|---|
| 71 | %% |
|---|
| 72 | |
|---|
| 73 | WholeEnchilada : Combiners |
|---|
| 74 | { |
|---|
| 75 | $1.Validate(); |
|---|
| 76 | $1.Invoke(); |
|---|
| 77 | } |
|---|
| 78 | ; |
|---|
| 79 | |
|---|
| 80 | Combiners : ConstColor GeneralCombiners FinalCombiner |
|---|
| 81 | { |
|---|
| 82 | CombinersStruct combinersStruct; |
|---|
| 83 | combinersStruct.Init($2, $3, $1); |
|---|
| 84 | $$ = combinersStruct; |
|---|
| 85 | } |
|---|
| 86 | | ConstColor ConstColor GeneralCombiners FinalCombiner |
|---|
| 87 | { |
|---|
| 88 | CombinersStruct combinersStruct; |
|---|
| 89 | combinersStruct.Init($3, $4, $1, $2); |
|---|
| 90 | $$ = combinersStruct; |
|---|
| 91 | } |
|---|
| 92 | | GeneralCombiners FinalCombiner |
|---|
| 93 | { |
|---|
| 94 | CombinersStruct combinersStruct; |
|---|
| 95 | combinersStruct.Init($1, $2); |
|---|
| 96 | $$ = combinersStruct; |
|---|
| 97 | } |
|---|
| 98 | | ConstColor FinalCombiner |
|---|
| 99 | { |
|---|
| 100 | GeneralCombinersStruct generalCombinersStruct; |
|---|
| 101 | generalCombinersStruct.Init(); |
|---|
| 102 | CombinersStruct combinersStruct; |
|---|
| 103 | combinersStruct.Init(generalCombinersStruct, $2, $1); |
|---|
| 104 | $$ = combinersStruct; |
|---|
| 105 | } |
|---|
| 106 | | ConstColor ConstColor FinalCombiner |
|---|
| 107 | { |
|---|
| 108 | GeneralCombinersStruct generalCombinersStruct; |
|---|
| 109 | generalCombinersStruct.Init(); |
|---|
| 110 | CombinersStruct combinersStruct; |
|---|
| 111 | combinersStruct.Init(generalCombinersStruct, $3, $1, $2); |
|---|
| 112 | $$ = combinersStruct; |
|---|
| 113 | } |
|---|
| 114 | | FinalCombiner |
|---|
| 115 | { |
|---|
| 116 | GeneralCombinersStruct generalCombinersStruct; |
|---|
| 117 | generalCombinersStruct.Init(); |
|---|
| 118 | CombinersStruct combinersStruct; |
|---|
| 119 | combinersStruct.Init(generalCombinersStruct, $1); |
|---|
| 120 | $$ = combinersStruct; |
|---|
| 121 | } |
|---|
| 122 | ; |
|---|
| 123 | |
|---|
| 124 | ConstColor : constVariable equals openParen floatValue comma floatValue comma floatValue comma floatValue closeParen semicolon |
|---|
| 125 | { |
|---|
| 126 | ConstColorStruct constColorStruct; |
|---|
| 127 | constColorStruct.Init($1, $4, $6, $8, $10); |
|---|
| 128 | $$ = constColorStruct; |
|---|
| 129 | } |
|---|
| 130 | ; |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | GeneralCombiners : GeneralCombiners GeneralCombiner |
|---|
| 134 | { |
|---|
| 135 | $1 += $2; |
|---|
| 136 | $$ = $1; |
|---|
| 137 | } |
|---|
| 138 | | GeneralCombiner |
|---|
| 139 | { |
|---|
| 140 | GeneralCombinersStruct generalCombinersStruct; |
|---|
| 141 | generalCombinersStruct.Init($1); |
|---|
| 142 | $$ = generalCombinersStruct; |
|---|
| 143 | } |
|---|
| 144 | ; |
|---|
| 145 | |
|---|
| 146 | GeneralCombiner : openBracket GeneralPortion GeneralPortion closeBracket |
|---|
| 147 | { |
|---|
| 148 | GeneralCombinerStruct generalCombinerStruct; |
|---|
| 149 | generalCombinerStruct.Init($2, $3); |
|---|
| 150 | $$ = generalCombinerStruct; |
|---|
| 151 | } |
|---|
| 152 | | openBracket ConstColor GeneralPortion GeneralPortion closeBracket |
|---|
| 153 | { |
|---|
| 154 | GeneralCombinerStruct generalCombinerStruct; |
|---|
| 155 | generalCombinerStruct.Init($3, $4, $2); |
|---|
| 156 | $$ = generalCombinerStruct; |
|---|
| 157 | } |
|---|
| 158 | | openBracket ConstColor ConstColor GeneralPortion GeneralPortion closeBracket |
|---|
| 159 | { |
|---|
| 160 | GeneralCombinerStruct generalCombinerStruct; |
|---|
| 161 | generalCombinerStruct.Init($4, $5, $2, $3); |
|---|
| 162 | $$ = generalCombinerStruct; |
|---|
| 163 | } |
|---|
| 164 | | openBracket GeneralPortion closeBracket |
|---|
| 165 | { |
|---|
| 166 | GeneralCombinerStruct generalCombinerStruct; |
|---|
| 167 | generalCombinerStruct.Init($2); |
|---|
| 168 | $$ = generalCombinerStruct; |
|---|
| 169 | } |
|---|
| 170 | | openBracket ConstColor GeneralPortion closeBracket |
|---|
| 171 | { |
|---|
| 172 | GeneralCombinerStruct generalCombinerStruct; |
|---|
| 173 | generalCombinerStruct.Init($3, $2); |
|---|
| 174 | $$ = generalCombinerStruct; |
|---|
| 175 | } |
|---|
| 176 | | openBracket ConstColor ConstColor GeneralPortion closeBracket |
|---|
| 177 | { |
|---|
| 178 | GeneralCombinerStruct generalCombinerStruct; |
|---|
| 179 | generalCombinerStruct.Init($4, $2, $3); |
|---|
| 180 | $$ = generalCombinerStruct; |
|---|
| 181 | } |
|---|
| 182 | ; |
|---|
| 183 | |
|---|
| 184 | GeneralPortion : PortionDesignator openBracket GeneralFunction BiasScale closeBracket |
|---|
| 185 | { |
|---|
| 186 | GeneralPortionStruct generalPortionStruct; |
|---|
| 187 | generalPortionStruct.Init($1, $3, $4); |
|---|
| 188 | $$ = generalPortionStruct; |
|---|
| 189 | } |
|---|
| 190 | | PortionDesignator openBracket GeneralFunction closeBracket |
|---|
| 191 | { |
|---|
| 192 | BiasScaleEnum noScale; |
|---|
| 193 | noScale.word = RCP_SCALE_BY_ONE; |
|---|
| 194 | GeneralPortionStruct generalPortionStruct; |
|---|
| 195 | generalPortionStruct.Init($1, $3, noScale); |
|---|
| 196 | $$ = generalPortionStruct; |
|---|
| 197 | } |
|---|
| 198 | ; |
|---|
| 199 | |
|---|
| 200 | PortionDesignator : rgb_portion |
|---|
| 201 | { |
|---|
| 202 | $$ = $1; |
|---|
| 203 | } |
|---|
| 204 | | alpha_portion |
|---|
| 205 | { |
|---|
| 206 | $$ = $1; |
|---|
| 207 | } |
|---|
| 208 | ; |
|---|
| 209 | |
|---|
| 210 | GeneralMappedRegister : Register |
|---|
| 211 | { |
|---|
| 212 | MappedRegisterStruct reg; |
|---|
| 213 | reg.Init($1, GL_SIGNED_IDENTITY_NV); |
|---|
| 214 | $$ = reg; |
|---|
| 215 | } |
|---|
| 216 | | minus Register |
|---|
| 217 | { |
|---|
| 218 | MappedRegisterStruct reg; |
|---|
| 219 | reg.Init($2, GL_SIGNED_NEGATE_NV); |
|---|
| 220 | $$ = reg; |
|---|
| 221 | } |
|---|
| 222 | | expandString openParen Register closeParen |
|---|
| 223 | { |
|---|
| 224 | MappedRegisterStruct reg; |
|---|
| 225 | reg.Init($3, GL_EXPAND_NORMAL_NV); |
|---|
| 226 | $$ = reg; |
|---|
| 227 | } |
|---|
| 228 | | minus expandString openParen Register closeParen |
|---|
| 229 | { |
|---|
| 230 | MappedRegisterStruct reg; |
|---|
| 231 | reg.Init($4, GL_EXPAND_NEGATE_NV); |
|---|
| 232 | $$ = reg; |
|---|
| 233 | } |
|---|
| 234 | | halfBiasString openParen Register closeParen |
|---|
| 235 | { |
|---|
| 236 | MappedRegisterStruct reg; |
|---|
| 237 | reg.Init($3, GL_HALF_BIAS_NORMAL_NV); |
|---|
| 238 | $$ = reg; |
|---|
| 239 | } |
|---|
| 240 | | minus halfBiasString openParen Register closeParen |
|---|
| 241 | { |
|---|
| 242 | MappedRegisterStruct reg; |
|---|
| 243 | reg.Init($4, GL_HALF_BIAS_NEGATE_NV); |
|---|
| 244 | $$ = reg; |
|---|
| 245 | } |
|---|
| 246 | | unsignedString openParen Register closeParen |
|---|
| 247 | { |
|---|
| 248 | MappedRegisterStruct reg; |
|---|
| 249 | reg.Init($3, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 250 | $$ = reg; |
|---|
| 251 | } |
|---|
| 252 | | unsignedInvertString openParen Register closeParen |
|---|
| 253 | { |
|---|
| 254 | MappedRegisterStruct reg; |
|---|
| 255 | reg.Init($3, GL_UNSIGNED_INVERT_NV); |
|---|
| 256 | $$ = reg; |
|---|
| 257 | } |
|---|
| 258 | ; |
|---|
| 259 | |
|---|
| 260 | GeneralFunction : Dot Dot |
|---|
| 261 | { |
|---|
| 262 | GeneralFunctionStruct generalFunction; |
|---|
| 263 | generalFunction.Init($1, $2); |
|---|
| 264 | $$ = generalFunction; |
|---|
| 265 | } |
|---|
| 266 | | Dot Mul |
|---|
| 267 | { |
|---|
| 268 | GeneralFunctionStruct generalFunction; |
|---|
| 269 | generalFunction.Init($1, $2); |
|---|
| 270 | $$ = generalFunction; |
|---|
| 271 | } |
|---|
| 272 | | Mul Dot |
|---|
| 273 | { |
|---|
| 274 | GeneralFunctionStruct generalFunction; |
|---|
| 275 | generalFunction.Init($1, $2); |
|---|
| 276 | $$ = generalFunction; |
|---|
| 277 | } |
|---|
| 278 | | Dot |
|---|
| 279 | { |
|---|
| 280 | GeneralFunctionStruct generalFunction; |
|---|
| 281 | generalFunction.Init($1); |
|---|
| 282 | $$ = generalFunction; |
|---|
| 283 | } |
|---|
| 284 | | Mul Mul |
|---|
| 285 | { |
|---|
| 286 | GeneralFunctionStruct generalFunction; |
|---|
| 287 | generalFunction.Init($1, $2); |
|---|
| 288 | $$ = generalFunction; |
|---|
| 289 | } |
|---|
| 290 | | Mul Mul Mux |
|---|
| 291 | { |
|---|
| 292 | GeneralFunctionStruct generalFunction; |
|---|
| 293 | generalFunction.Init($1, $2, $3); |
|---|
| 294 | $$ = generalFunction; |
|---|
| 295 | } |
|---|
| 296 | | Mul Mul Sum |
|---|
| 297 | { |
|---|
| 298 | GeneralFunctionStruct generalFunction; |
|---|
| 299 | generalFunction.Init($1, $2, $3); |
|---|
| 300 | $$ = generalFunction; |
|---|
| 301 | } |
|---|
| 302 | | Mul |
|---|
| 303 | { |
|---|
| 304 | GeneralFunctionStruct generalFunction; |
|---|
| 305 | generalFunction.Init($1); |
|---|
| 306 | $$ = generalFunction; |
|---|
| 307 | } |
|---|
| 308 | ; |
|---|
| 309 | |
|---|
| 310 | Dot : Register equals GeneralMappedRegister dot GeneralMappedRegister semicolon |
|---|
| 311 | { |
|---|
| 312 | OpStruct dotFunction; |
|---|
| 313 | dotFunction.Init(RCP_DOT, $1, $3, $5); |
|---|
| 314 | $$ = dotFunction; |
|---|
| 315 | } |
|---|
| 316 | ; |
|---|
| 317 | |
|---|
| 318 | Mul : Register equals GeneralMappedRegister times GeneralMappedRegister semicolon |
|---|
| 319 | { |
|---|
| 320 | OpStruct mulFunction; |
|---|
| 321 | mulFunction.Init(RCP_MUL, $1, $3, $5); |
|---|
| 322 | $$ = mulFunction; |
|---|
| 323 | } |
|---|
| 324 | | Register equals GeneralMappedRegister semicolon |
|---|
| 325 | { |
|---|
| 326 | RegisterEnum zero; |
|---|
| 327 | zero.word = RCP_ZERO; |
|---|
| 328 | MappedRegisterStruct one; |
|---|
| 329 | one.Init(zero, GL_UNSIGNED_INVERT_NV); |
|---|
| 330 | OpStruct mulFunction; |
|---|
| 331 | mulFunction.Init(RCP_MUL, $1, $3, one); |
|---|
| 332 | $$ = mulFunction; |
|---|
| 333 | } |
|---|
| 334 | ; |
|---|
| 335 | |
|---|
| 336 | Mux : Register equals muxString openParen closeParen semicolon |
|---|
| 337 | { |
|---|
| 338 | OpStruct muxFunction; |
|---|
| 339 | muxFunction.Init(RCP_MUX, $1); |
|---|
| 340 | $$ = muxFunction; |
|---|
| 341 | } |
|---|
| 342 | ; |
|---|
| 343 | |
|---|
| 344 | Sum : Register equals sumString openParen closeParen semicolon |
|---|
| 345 | { |
|---|
| 346 | OpStruct sumFunction; |
|---|
| 347 | sumFunction.Init(RCP_SUM, $1); |
|---|
| 348 | $$ = sumFunction; |
|---|
| 349 | } |
|---|
| 350 | ; |
|---|
| 351 | |
|---|
| 352 | BiasScale : bias_by_negative_one_half_scale_by_two openParen closeParen semicolon |
|---|
| 353 | { |
|---|
| 354 | $$ = $1; |
|---|
| 355 | } |
|---|
| 356 | | bias_by_negative_one_half openParen closeParen semicolon |
|---|
| 357 | { |
|---|
| 358 | $$ = $1; |
|---|
| 359 | } |
|---|
| 360 | | scale_by_one_half openParen closeParen semicolon |
|---|
| 361 | { |
|---|
| 362 | $$ = $1; |
|---|
| 363 | } |
|---|
| 364 | | scale_by_two openParen closeParen semicolon |
|---|
| 365 | { |
|---|
| 366 | $$ = $1; |
|---|
| 367 | } |
|---|
| 368 | | scale_by_four openParen closeParen semicolon |
|---|
| 369 | { |
|---|
| 370 | $$ = $1; |
|---|
| 371 | } |
|---|
| 372 | ; |
|---|
| 373 | |
|---|
| 374 | FinalMappedRegister : Register |
|---|
| 375 | { |
|---|
| 376 | MappedRegisterStruct reg; |
|---|
| 377 | reg.Init($1, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 378 | $$ = reg; |
|---|
| 379 | } |
|---|
| 380 | | unsignedString openParen Register closeParen |
|---|
| 381 | { |
|---|
| 382 | MappedRegisterStruct reg; |
|---|
| 383 | reg.Init($3, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 384 | $$ = reg; |
|---|
| 385 | } |
|---|
| 386 | | unsignedInvertString openParen Register closeParen |
|---|
| 387 | { |
|---|
| 388 | MappedRegisterStruct reg; |
|---|
| 389 | reg.Init($3, GL_UNSIGNED_INVERT_NV); |
|---|
| 390 | $$ = reg; |
|---|
| 391 | } |
|---|
| 392 | | color_sum |
|---|
| 393 | { |
|---|
| 394 | MappedRegisterStruct reg; |
|---|
| 395 | reg.Init($1); |
|---|
| 396 | $$ = reg; |
|---|
| 397 | } |
|---|
| 398 | | unsignedString openParen color_sum closeParen |
|---|
| 399 | { |
|---|
| 400 | MappedRegisterStruct reg; |
|---|
| 401 | reg.Init($3, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 402 | $$ = reg; |
|---|
| 403 | } |
|---|
| 404 | | unsignedInvertString openParen color_sum closeParen |
|---|
| 405 | { |
|---|
| 406 | MappedRegisterStruct reg; |
|---|
| 407 | reg.Init($3, GL_UNSIGNED_INVERT_NV); |
|---|
| 408 | $$ = reg; |
|---|
| 409 | } |
|---|
| 410 | | final_product |
|---|
| 411 | { |
|---|
| 412 | MappedRegisterStruct reg; |
|---|
| 413 | reg.Init($1); |
|---|
| 414 | $$ = reg; |
|---|
| 415 | } |
|---|
| 416 | | unsignedString openParen final_product closeParen |
|---|
| 417 | { |
|---|
| 418 | MappedRegisterStruct reg; |
|---|
| 419 | reg.Init($3, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 420 | $$ = reg; |
|---|
| 421 | } |
|---|
| 422 | | unsignedInvertString openParen final_product closeParen |
|---|
| 423 | { |
|---|
| 424 | MappedRegisterStruct reg; |
|---|
| 425 | reg.Init($3, GL_UNSIGNED_INVERT_NV); |
|---|
| 426 | $$ = reg; |
|---|
| 427 | } |
|---|
| 428 | ; |
|---|
| 429 | |
|---|
| 430 | FinalCombiner : FinalAlphaFunction FinalRgbFunction |
|---|
| 431 | { |
|---|
| 432 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 433 | finalCombinerStruct.Init($2, $1, false); |
|---|
| 434 | $$ = finalCombinerStruct; |
|---|
| 435 | } |
|---|
| 436 | | ClampColorSum FinalAlphaFunction FinalRgbFunction |
|---|
| 437 | { |
|---|
| 438 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 439 | finalCombinerStruct.Init($3, $2, true); |
|---|
| 440 | $$ = finalCombinerStruct; |
|---|
| 441 | } |
|---|
| 442 | | FinalProduct FinalAlphaFunction FinalRgbFunction |
|---|
| 443 | { |
|---|
| 444 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 445 | finalCombinerStruct.Init($3, $2, false, $1); |
|---|
| 446 | $$ = finalCombinerStruct; |
|---|
| 447 | } |
|---|
| 448 | | ClampColorSum FinalProduct FinalAlphaFunction FinalRgbFunction |
|---|
| 449 | { |
|---|
| 450 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 451 | finalCombinerStruct.Init($4, $3, true, $2); |
|---|
| 452 | $$ = finalCombinerStruct; |
|---|
| 453 | } |
|---|
| 454 | | FinalProduct ClampColorSum FinalAlphaFunction FinalRgbFunction |
|---|
| 455 | { |
|---|
| 456 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 457 | finalCombinerStruct.Init($4, $3, true, $1); |
|---|
| 458 | $$ = finalCombinerStruct; |
|---|
| 459 | } |
|---|
| 460 | |
|---|
| 461 | | FinalRgbFunction FinalAlphaFunction |
|---|
| 462 | { |
|---|
| 463 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 464 | finalCombinerStruct.Init($1, $2, false); |
|---|
| 465 | $$ = finalCombinerStruct; |
|---|
| 466 | } |
|---|
| 467 | | ClampColorSum FinalRgbFunction FinalAlphaFunction |
|---|
| 468 | { |
|---|
| 469 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 470 | finalCombinerStruct.Init($2, $3, true); |
|---|
| 471 | $$ = finalCombinerStruct; |
|---|
| 472 | } |
|---|
| 473 | | FinalProduct FinalRgbFunction FinalAlphaFunction |
|---|
| 474 | { |
|---|
| 475 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 476 | finalCombinerStruct.Init($2, $3, false, $1); |
|---|
| 477 | $$ = finalCombinerStruct; |
|---|
| 478 | } |
|---|
| 479 | | ClampColorSum FinalProduct FinalRgbFunction FinalAlphaFunction |
|---|
| 480 | { |
|---|
| 481 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 482 | finalCombinerStruct.Init($3, $4, true, $2); |
|---|
| 483 | $$ = finalCombinerStruct; |
|---|
| 484 | } |
|---|
| 485 | | FinalProduct ClampColorSum FinalRgbFunction FinalAlphaFunction |
|---|
| 486 | { |
|---|
| 487 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 488 | finalCombinerStruct.Init($3, $4, true, $1); |
|---|
| 489 | $$ = finalCombinerStruct; |
|---|
| 490 | } |
|---|
| 491 | |
|---|
| 492 | | FinalRgbFunction |
|---|
| 493 | { |
|---|
| 494 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 495 | FinalAlphaFunctionStruct finalAlphaFunctionStruct; |
|---|
| 496 | finalAlphaFunctionStruct.ZeroOut(); |
|---|
| 497 | finalCombinerStruct.Init($1, finalAlphaFunctionStruct, false); |
|---|
| 498 | $$ = finalCombinerStruct; |
|---|
| 499 | } |
|---|
| 500 | | ClampColorSum FinalRgbFunction |
|---|
| 501 | { |
|---|
| 502 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 503 | FinalAlphaFunctionStruct finalAlphaFunctionStruct; |
|---|
| 504 | finalAlphaFunctionStruct.ZeroOut(); |
|---|
| 505 | finalCombinerStruct.Init($2, finalAlphaFunctionStruct, true); |
|---|
| 506 | $$ = finalCombinerStruct; |
|---|
| 507 | } |
|---|
| 508 | | FinalProduct FinalRgbFunction |
|---|
| 509 | { |
|---|
| 510 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 511 | FinalAlphaFunctionStruct finalAlphaFunctionStruct; |
|---|
| 512 | finalAlphaFunctionStruct.ZeroOut(); |
|---|
| 513 | finalCombinerStruct.Init($2, finalAlphaFunctionStruct, false, $1); |
|---|
| 514 | $$ = finalCombinerStruct; |
|---|
| 515 | } |
|---|
| 516 | | ClampColorSum FinalProduct FinalRgbFunction |
|---|
| 517 | { |
|---|
| 518 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 519 | FinalAlphaFunctionStruct finalAlphaFunctionStruct; |
|---|
| 520 | finalAlphaFunctionStruct.ZeroOut(); |
|---|
| 521 | finalCombinerStruct.Init($3, finalAlphaFunctionStruct, true, $2); |
|---|
| 522 | $$ = finalCombinerStruct; |
|---|
| 523 | } |
|---|
| 524 | | FinalProduct ClampColorSum FinalRgbFunction |
|---|
| 525 | { |
|---|
| 526 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 527 | FinalAlphaFunctionStruct finalAlphaFunctionStruct; |
|---|
| 528 | finalAlphaFunctionStruct.ZeroOut(); |
|---|
| 529 | finalCombinerStruct.Init($3, finalAlphaFunctionStruct, true, $1); |
|---|
| 530 | $$ = finalCombinerStruct; |
|---|
| 531 | } |
|---|
| 532 | |
|---|
| 533 | | FinalAlphaFunction |
|---|
| 534 | { |
|---|
| 535 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 536 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 537 | finalRgbFunctionStruct.ZeroOut(); |
|---|
| 538 | finalCombinerStruct.Init(finalRgbFunctionStruct, $1, false); |
|---|
| 539 | $$ = finalCombinerStruct; |
|---|
| 540 | } |
|---|
| 541 | | ClampColorSum FinalAlphaFunction |
|---|
| 542 | { |
|---|
| 543 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 544 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 545 | finalRgbFunctionStruct.ZeroOut(); |
|---|
| 546 | finalCombinerStruct.Init(finalRgbFunctionStruct, $2, true); |
|---|
| 547 | $$ = finalCombinerStruct; |
|---|
| 548 | } |
|---|
| 549 | | FinalProduct FinalAlphaFunction |
|---|
| 550 | { |
|---|
| 551 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 552 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 553 | finalRgbFunctionStruct.ZeroOut(); |
|---|
| 554 | finalCombinerStruct.Init(finalRgbFunctionStruct, $2, false, $1); |
|---|
| 555 | $$ = finalCombinerStruct; |
|---|
| 556 | } |
|---|
| 557 | | ClampColorSum FinalProduct FinalAlphaFunction |
|---|
| 558 | { |
|---|
| 559 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 560 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 561 | finalRgbFunctionStruct.ZeroOut(); |
|---|
| 562 | finalCombinerStruct.Init(finalRgbFunctionStruct, $3, true, $2); |
|---|
| 563 | $$ = finalCombinerStruct; |
|---|
| 564 | } |
|---|
| 565 | | FinalProduct ClampColorSum FinalAlphaFunction |
|---|
| 566 | { |
|---|
| 567 | FinalCombinerStruct finalCombinerStruct; |
|---|
| 568 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 569 | finalRgbFunctionStruct.ZeroOut(); |
|---|
| 570 | finalCombinerStruct.Init(finalRgbFunctionStruct, $3, true, $1); |
|---|
| 571 | $$ = finalCombinerStruct; |
|---|
| 572 | } |
|---|
| 573 | ; |
|---|
| 574 | |
|---|
| 575 | ClampColorSum : clamp_color_sum openParen closeParen semicolon |
|---|
| 576 | { |
|---|
| 577 | $$ = $1; |
|---|
| 578 | } |
|---|
| 579 | ; |
|---|
| 580 | |
|---|
| 581 | FinalProduct : final_product equals FinalMappedRegister times FinalMappedRegister semicolon |
|---|
| 582 | { |
|---|
| 583 | FinalProductStruct finalProductStruct; |
|---|
| 584 | finalProductStruct.Init($3, $5); |
|---|
| 585 | $$ = finalProductStruct; |
|---|
| 586 | } |
|---|
| 587 | ; |
|---|
| 588 | |
|---|
| 589 | FinalRgbFunction : fragment_rgb equals lerp openParen FinalMappedRegister comma FinalMappedRegister comma FinalMappedRegister closeParen plus FinalMappedRegister semicolon |
|---|
| 590 | { |
|---|
| 591 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 592 | finalRgbFunctionStruct.Init($5, $7, $9, $12); |
|---|
| 593 | $$ = finalRgbFunctionStruct; |
|---|
| 594 | } |
|---|
| 595 | | fragment_rgb equals FinalMappedRegister plus lerp openParen FinalMappedRegister comma FinalMappedRegister comma FinalMappedRegister closeParen semicolon |
|---|
| 596 | { |
|---|
| 597 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 598 | finalRgbFunctionStruct.Init($7, $9, $11, $3); |
|---|
| 599 | $$ = finalRgbFunctionStruct; |
|---|
| 600 | } |
|---|
| 601 | | fragment_rgb equals lerp openParen FinalMappedRegister comma FinalMappedRegister comma FinalMappedRegister closeParen semicolon |
|---|
| 602 | { |
|---|
| 603 | RegisterEnum zero; |
|---|
| 604 | zero.word = RCP_ZERO; |
|---|
| 605 | MappedRegisterStruct reg; |
|---|
| 606 | reg.Init(zero, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 607 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 608 | finalRgbFunctionStruct.Init($5, $7, $9, reg); |
|---|
| 609 | $$ = finalRgbFunctionStruct; |
|---|
| 610 | } |
|---|
| 611 | | fragment_rgb equals FinalMappedRegister times FinalMappedRegister semicolon |
|---|
| 612 | { |
|---|
| 613 | RegisterEnum zero; |
|---|
| 614 | zero.word = RCP_ZERO; |
|---|
| 615 | MappedRegisterStruct reg1; |
|---|
| 616 | reg1.Init(zero, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 617 | MappedRegisterStruct reg2; |
|---|
| 618 | reg2.Init(zero, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 619 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 620 | finalRgbFunctionStruct.Init($3, $5, reg1, reg2); |
|---|
| 621 | $$ = finalRgbFunctionStruct; |
|---|
| 622 | } |
|---|
| 623 | | fragment_rgb equals FinalMappedRegister times FinalMappedRegister plus FinalMappedRegister semicolon |
|---|
| 624 | { |
|---|
| 625 | RegisterEnum zero; |
|---|
| 626 | zero.word = RCP_ZERO; |
|---|
| 627 | MappedRegisterStruct reg1; |
|---|
| 628 | reg1.Init(zero, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 629 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 630 | finalRgbFunctionStruct.Init($3, $5, reg1, $7); |
|---|
| 631 | $$ = finalRgbFunctionStruct; |
|---|
| 632 | } |
|---|
| 633 | | fragment_rgb equals FinalMappedRegister semicolon |
|---|
| 634 | { |
|---|
| 635 | RegisterEnum zero; |
|---|
| 636 | zero.word = RCP_ZERO; |
|---|
| 637 | MappedRegisterStruct reg1; |
|---|
| 638 | reg1.Init(zero, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 639 | MappedRegisterStruct reg2; |
|---|
| 640 | reg2.Init(zero, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 641 | MappedRegisterStruct reg3; |
|---|
| 642 | reg3.Init(zero, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 643 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 644 | finalRgbFunctionStruct.Init(reg1, reg2, reg3, $3); |
|---|
| 645 | $$ = finalRgbFunctionStruct; |
|---|
| 646 | } |
|---|
| 647 | | fragment_rgb equals FinalMappedRegister plus FinalMappedRegister semicolon |
|---|
| 648 | { |
|---|
| 649 | RegisterEnum zero; |
|---|
| 650 | zero.word = RCP_ZERO; |
|---|
| 651 | MappedRegisterStruct reg2; |
|---|
| 652 | reg2.Init(zero, GL_UNSIGNED_INVERT_NV); |
|---|
| 653 | MappedRegisterStruct reg3; |
|---|
| 654 | reg3.Init(zero, GL_UNSIGNED_IDENTITY_NV); |
|---|
| 655 | FinalRgbFunctionStruct finalRgbFunctionStruct; |
|---|
| 656 | finalRgbFunctionStruct.Init($3, reg2, reg3, $5); |
|---|
| 657 | $$ = finalRgbFunctionStruct; |
|---|
| 658 | } |
|---|
| 659 | ; |
|---|
| 660 | |
|---|
| 661 | FinalAlphaFunction : fragment_alpha equals FinalMappedRegister semicolon |
|---|
| 662 | { |
|---|
| 663 | FinalAlphaFunctionStruct finalAlphaFunctionStruct; |
|---|
| 664 | finalAlphaFunctionStruct.Init($3); |
|---|
| 665 | $$ = finalAlphaFunctionStruct; |
|---|
| 666 | } |
|---|
| 667 | ; |
|---|
| 668 | |
|---|
| 669 | Register : constVariable |
|---|
| 670 | { |
|---|
| 671 | $$ = $1; |
|---|
| 672 | } |
|---|
| 673 | | regVariable |
|---|
| 674 | { |
|---|
| 675 | $$ = $1; |
|---|
| 676 | } |
|---|
| 677 | ; |
|---|
| 678 | |
|---|
| 679 | %% |
|---|
| 680 | void yyerror(char* s) |
|---|
| 681 | { |
|---|
| 682 | errors.set("unrecognized token"); |
|---|
| 683 | } |
|---|