Aeva / m.grl

Midnight Graphics & Recreation Library
http://mgrl.midnightsisters.org
GNU Lesser General Public License v3.0
44 stars 3 forks source link

non-constant generic global variables in shaders unsupproted #196

Closed Aeva closed 8 years ago

Aeva commented 8 years ago

This following is valid GLSL but the compiler fails spectacularly on it:

float floob;
void main() {
  floob = 10;
  // etc
}
Aeva commented 8 years ago

The bug is in this function.

The parser assumes that a global variable will be declared with one of the following qualifiers: "uniform", "attribute", "varying", or "const". If the mode is not determined, then the function assumes they aren't globals and leaves them in the AST for something else to choke on them.

What it should be doing is looking for something in the pattern of " " followed by either an "=" or an ";". And then in the case of an "=" it should consume the remaining tokens to the ";" as the initialization value.

Detecting two words before either a "=" or a ";" is probably good enough for now inbefore having some kind of fancy type system in place (and then also recognizing typedefs and structs).