laurentlb / shader-minifier

Minify and obfuscate GLSL or HLSL code
https://ctrl-alt-test.fr/minifier/
Apache License 2.0
452 stars 34 forks source link

Error with vector arrays (uvec3, bvec3) #142

Closed maierfelix closed 2 years ago

maierfelix commented 2 years ago

For arrays like this:

const uvec3[24] SWIZZLE_ROT = uvec3[24](
  uvec3(0u, 0u, 0u),
  ...
);

I'm getting:

System.Exception: Parse error:
const uvec3[24] SWIZZLE_ROT = uvec3[24](
           ^
Expecting: identifier

   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1433.Invoke(String message)
   at Main.minify(Tuple`2[] files)
   at Main.run(String[] files)

I found that swapping the brackets to the end makes the minifier work again:

const uvec3 SWIZZLE_ROT[24]

But unfortunately I'm using WebGL2, which expects the brackets before the variable identifier, and not afterwards.

laurentlb commented 2 years ago

Can you share the error message you get with const uvec3 SWIZZLE_ROT[24]?

If I read this reference page correctly, this should be allowed: https://www.khronos.org/files/webgl20-reference-guide.pdf (look for Structures and Arrays)

maierfelix commented 2 years ago

After reading this, I tried it again and WebGL now seems to accept the trailing brackets. No idea why it's suddenly working, I must have messed up somewhere.

Thanks for your project btw!