Closed therontarigo closed 1 month ago
That would be good too, but cmdline should be kept as an override as there are various reasons the #version
line may not exist in the source: a project may be putting it in after minification, or as a separate string, or in some cases it is not needed - WebGL1 defaults to 100 es
(I think) and OpenGL defaults to 110 compatibility
.
That makes sense. We could consider a single flag --lang
to switch between HLSL, GLSL, GLSL ES.
Perhaps, though I simply followed glslang
convention here:
--glsl-version {100 | 110 | 120 | 130 | 140 | 150 |
300es | 310es | 320es | 330
400 | 410 | 420 | 430 | 440 | 450 | 460}
set GLSL version, overrides #version
in shader sourcen
glslang
also uses a single flag for switching to HLSL.
Having a command line flag is also good for reusing the same test file in different versions.
What should happen when #version exists and does not match the command line flag? Use #version, use command-line, show a warning or show an error?
Eventually expressions like (options.hlsl || options.glslver>0 || options.esslver>=300)
should probably be moved to a method with a name describing the feature being tested, in some kind of Version object.
version exists and does not match the command line flag
Override the interpretation (as glslang
does) and show a warning (and leave the literal #version
line untouched).
(options.hlsl || options.glslver>0 || options.esslver>=300)
could be simplified as not (options.esslver>0 && options.esslver<300)
.
Something like this?
module LangFeature
let dynamicloops = not (options.esslver>0 && options.esslver<300)
let implicitconversion = not options.esslver>0
The implicitconv
language feature flag is because of this WIP: https://github.com/therontarigo/Shader_Minifier/compare/glslversion...therontarigo:Shader_Minifier:constants
"100es" does not exist in glslang
, and #version 100 es
is not valid in any environment - confusing as it is, the real behavior of OpenGL is that #version N
(with no "es") selects ESSL when N=100, and OpenGL GLSL otherwise. Likewise in glslang
the ESSL version options are named 100 | 300es | 310es | 320es
. Closing for now.
Do you think we could read the version from the
#version
line? Or it won't be sufficient?