All Projects → aras-p → Glsl Optimizer

aras-p / Glsl Optimizer

Licence: other
GLSL optimizer based on Mesa's GLSL compiler. Used to be used in Unity for mobile shader optimization.

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
Yacc
648 projects
LLVM
166 projects
Lex
420 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Glsl Optimizer

Hlsl2glslfork
HLSL to GLSL language translator based on ATI's HLSL2GLSL. Used in Unity.
Stars: ✭ 488 (-67.6%)
Mutual labels:  cross-compiler, glsl, shaders
YALCT
Yet Another Live Coding Tool - Powered by Veldrid and elbow grease
Stars: ✭ 25 (-98.34%)
Mutual labels:  metal, shaders, glsl
Solarsys
Realistic Solar System simulation with three.js
Stars: ✭ 49 (-96.75%)
Mutual labels:  glsl, shaders
Glslcanvas
Simple tool to load GLSL shaders on HTML Canvas using WebGL
Stars: ✭ 1,067 (-29.15%)
Mutual labels:  glsl, shaders
3d Game Shaders For Beginners
🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.
Stars: ✭ 11,698 (+676.76%)
Mutual labels:  glsl, shaders
Godot Shaders
A large library of free and open-source shaders for the Godot game engine. Here, you'll get 2D and 3D shaders with playable demos.
Stars: ✭ 988 (-34.4%)
Mutual labels:  glsl, shaders
Shaderworkshop
Interactive GLSL fragment shaders editor made with Qt
Stars: ✭ 43 (-97.14%)
Mutual labels:  glsl, shaders
Shaderconductor
ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages
Stars: ✭ 1,146 (-23.9%)
Mutual labels:  glsl, metal
Wagner
Effects composer for three.js
Stars: ✭ 930 (-38.25%)
Mutual labels:  glsl, shaders
Noodlesplate
Offline Shader Editor with many cool features
Stars: ✭ 79 (-94.75%)
Mutual labels:  glsl, shaders
Shadertoy React
6kB "Shadertoy" like react component letting you easily render your fragment shaders in your React web projects, without having to worry about implementing the WebGL part.
Stars: ✭ 74 (-95.09%)
Mutual labels:  glsl, shaders
Sildurs Shaders.github.io
Sildurs shaders website
Stars: ✭ 84 (-94.42%)
Mutual labels:  glsl, shaders
Langterm
🕹️ WebGL-based VT220 emulator, made as a learning example and frontend for a text adventure
Stars: ✭ 35 (-97.68%)
Mutual labels:  glsl, shaders
Tess Opt
Demonstration of how we can use tessellation shaders to make faster fragment shaders.
Stars: ✭ 13 (-99.14%)
Mutual labels:  glsl, shaders
Curtainsjs
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.
Stars: ✭ 1,039 (-31.01%)
Mutual labels:  glsl, shaders
Month Of Shaders
One GLSL shader for every day of the month August
Stars: ✭ 12 (-99.2%)
Mutual labels:  glsl, shaders
Glsl Worley
Worley noise implementation for WebGL shaders
Stars: ✭ 66 (-95.62%)
Mutual labels:  glsl, shaders
Gdx Vfx
LibGDX post-processing visual effects
Stars: ✭ 105 (-93.03%)
Mutual labels:  glsl, shaders
Leaf3d
A lightweight 3D rendering engine based on modern OpenGL
Stars: ✭ 16 (-98.94%)
Mutual labels:  glsl, shaders
Nau
Nau - OpenGL + Optix 3D Engine
Stars: ✭ 18 (-98.8%)
Mutual labels:  glsl, shaders

GLSL optimizer

⚠️ As of mid-2016, the project is unlikely to have any significant developments. At Unity we are moving to a different shader compilation pipeline, with glsl-optimizer is not used. So from my side there won't be significant work done on it. ⚠️

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.

Usage

Visual Studio 2010 (Windows, x86/x64) and Xcode 5+ (Mac, i386) project files for a static library are provided in projects/vs2010/glsl_optimizer.sln and projects/xcode5/glsl_optimizer_lib respectively.

Note: only the VS and Xcode project files are maintained and should work at any time. There's also a cmake and gyp build system for Linux et al., and some stuff in contrib folder - all that may or might not work.

For Linux you can use cmake. Just type "cmake . && make" in the root directory. This will build the optimizer library and some executable binaries.

Interface for the library is src/glsl/glsl_optimizer.h. General usage is:

ctx = glslopt_initialize(targetVersion);
for (lots of shaders) {
	shader = glslopt_optimize (ctx, shaderType, shaderSource, options);
	if (glslopt_get_status (shader)) {
		newSource = glslopt_get_output (shader);
	} else {
		errorLog = glslopt_get_log (shader);
	}
	glslopt_shader_delete (shader);
}
glslopt_cleanup (ctx);

Tests

There's a testing suite for catching regressions, see tests folder. In VS, build and run glsl_optimizer_tests project; in Xcode use projects/xcode5/glsl_optimizer_tests project. The test executable requires path to the tests folder as an argument.

Each test comes as three text files; input, expected IR dump and expected optimized GLSL dump. GLES3 tests are also converted into Metal.

If you're making changes to the project and want pull requests accepted easier, I'd appreciate if there would be no test suite regressions. If you are implementing a feature, it would be cool to add tests to cover it as well!

Notes

  • GLSL versions 1.10 and 1.20 are supported. 1.10 is the default, use #version 120 to specify 1.20. Higher GLSL versions might work, but aren't tested now.
  • GLSL ES versions 1.00 and 3.00 are supported.

Dev Notes

Pulling Mesa upstream:

git fetch upstream
git merge upstream/master
sh removeDeletedByUs.sh
# inspect files, git rm unneeded ones, fix conflicts etc.
# git commit

Rebuilding flex/bison parsers:

  • When .y/.l files are changed, the parsers are not rebuilt automatically,
  • Run ./generateParsers.sh to do that. You'll need bison & flex (on Mac, do "Install Command Line Tools" from Xcode)
  • I use bison 2.3 and flex 2.5.35 (in OS X 10.8/10.9)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].