laurentlb / shader-minifier

Minify and obfuscate GLSL or HLSL code

Home Page:https://ctrl-alt-test.fr/minifier/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spurious swizzling of struct members

therontarigo opened this issue · comments

Input

struct Foo {
  int field1;
  int field2;
  int wz;
  int xy;
};

out vec4 O;
void main() {
  Foo f;
  f.field1 = 1;
  f.field2 = 2;
  f.wz = 3;
  f.xy = 4;
  O.xy=vec2(f.wz,f.xy);
}

Output

struct Foo{int field1;int field2;int wz;int xy;};
out vec4 i;
void main()
{
  Foo f;
  f.field1=1;
  f.field2=2;
  f.wz=3;
  f.xy=4;
  i.xy=vec2(f.wzxy);  // uh-oh
}

Not yet encountered in practice, but anticipated when considering #393
I don't see how this can be avoided except by disallowing all struct member names that resemble vector swizzles, even when they consist of canonicalFieldNames characters.