glsl-optimizer | GLSL optimizer based on Mesa 's GLSL compiler
kandi X-RAY | glsl-optimizer Summary
kandi X-RAY | glsl-optimizer Summary
A C++ library that takes GLSL shaders, does some GPU-independent optimizations on them and outputs GLSL or Metal source back. Optimizations are function inlining, dead code removal, copy propagation, constant folding, constant propagation, arithmetic optimizations and so on. Apparently quite a few mobile platforms are pretty bad at optimizing shaders; and unfortunately they also lack offline shader compilers. So using a GLSL optimizer offline before can make the shader run much faster on a platform like that. See performance numbers in [this blog post] Even for drivers that have decent shader optimization, GLSL optimizer could be useful to just strip away dead code, make shaders smaller and do uniform/input reflection offline. Almost all actual code is [Mesa 3D’s GLSL] compiler; all this library does is spits out optimized GLSL or Metal back, and adds GLES type precision handling to the optimizer. This GLSL optimizer is made for [Unity’s] purposes and is built-in starting with Unity 3.0. GLSL Optimizer is licensed according to the terms of the MIT license. See [change log here] Changelog.md).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of glsl-optimizer
glsl-optimizer Key Features
glsl-optimizer Examples and Code Snippets
Community Discussions
Trending Discussions on glsl-optimizer
QUESTION
The mesa drivers, as part of their compilation process, reduce the size of the glsl shader files.
Some libraries, like this one, use this fact to create shader minification libraries. All minification libraries I have found are abandonware, so, unless mesa has functionality to get the intermediary glsl files directly, I may have to edit the actual code the way those libraries did it.
I was wondering if there is an executable within the mesa code base that can be used to do the stripping without having to edit the code.
I tried reading the official mesa documentation, but I didn't anything that suggests either way: https://www.mesa3d.org/opengles.html
...ANSWER
Answered 2020-Jan-20 at 15:19"Minification" is something different to optimization. Typically the term is used to describe a process that takes a source file in text form and removes all superfluous whitespace and replaces all identifiers with shorter ones.
Strictly speaking the whole idea of minification is a folly, since it has zero impact on performance; neither lexing the code, nor the compilation result are affected by it. The whole minification doofus started in web development to reduce webpage resource size; totally worthless, because you'll get far better performance if you just compress the text with gzip or similar. Heck after zipping the original and the minified versions' sized will probably within a few bytes of each other.
If you're really concerned about the size of your shader as a resource, just compress it (but mind the overhead of the decompression code). EDIT: However if your target is WebGL, then make use of HTTP transport gzip compression. The relevant browsers do support it all, and most HTTP servers can be configured to transparently deliver a supplementary .gz
suffixed file (or do the compression and cache it on the fly).
For optimization, you should look to the other offerings of Khronos. Specifically the GLSL to SPIR-V compiler glslc
, the SPIR-V optimizer spirv-opt
, and the SPIR-V decompiler spirv-cross
. You can chain those up to create optimized, "reduced" GLSL.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install glsl-optimizer
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page