{"id":13731903,"url":"https://github.com/aras-p/glsl-optimizer","last_synced_at":"2025-05-14T20:08:31.659Z","repository":{"id":38857003,"uuid":"805175","full_name":"aras-p/glsl-optimizer","owner":"aras-p","description":"GLSL optimizer based on Mesa's GLSL compiler. Used to be used in Unity for mobile shader optimization.","archived":false,"fork":false,"pushed_at":"2020-05-14T19:15:37.000Z","size":159102,"stargazers_count":1752,"open_issues_count":51,"forks_count":427,"subscribers_count":120,"default_branch":"master","last_synced_at":"2025-04-06T13:04:27.294Z","etag":null,"topics":["cross-compiler","glsl","metal","optimizer","shaders"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aras-p.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-07-29T11:41:28.000Z","updated_at":"2025-03-24T00:50:08.000Z","dependencies_parsed_at":"2022-08-09T06:16:35.841Z","dependency_job_id":null,"html_url":"https://github.com/aras-p/glsl-optimizer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aras-p%2Fglsl-optimizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aras-p%2Fglsl-optimizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aras-p%2Fglsl-optimizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aras-p%2Fglsl-optimizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aras-p","download_url":"https://codeload.github.com/aras-p/glsl-optimizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741197,"owners_count":21154252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-compiler","glsl","metal","optimizer","shaders"],"created_at":"2024-08-03T02:01:41.100Z","updated_at":"2025-04-13T15:58:15.232Z","avatar_url":"https://github.com/aras-p.png","language":"C++","funding_links":[],"categories":["Lighting, Rendering \u0026 Shaders","Graphics"],"sub_categories":["Rendering \u0026 Shader Theory"],"readme":"GLSL optimizer\n==============\n\n\u003e :warning: As of mid-2016, the project is unlikely to have any significant developments. At Unity we are moving to a different\nshader compilation pipeline, with glsl-optimizer is not used. So from my side there won't be significant work done on it. :warning:\n\n\nA C++ library that takes GLSL shaders, does some GPU-independent optimizations on them\nand outputs GLSL or Metal source back. Optimizations are function inlining, dead code removal, copy propagation,\nconstant folding, constant propagation, arithmetic optimizations and so on.\n\nApparently quite a few mobile platforms are pretty bad at optimizing shaders; and\nunfortunately they *also* lack offline shader compilers. So using a GLSL optimizer offline\nbefore can make the shader run much faster on a platform like that. See performance numbers\nin [this blog post](http://aras-p.info/blog/2010/09/29/glsl-optimizer/).\n\nEven for drivers that have decent shader optimization, GLSL optimizer could be useful to just strip away\ndead code, make shaders smaller and do uniform/input reflection offline.\n\nAlmost all actual code is [Mesa 3D's GLSL](http://cgit.freedesktop.org/mesa/mesa/log/)\ncompiler; all this library does is spits out optimized GLSL or Metal back, and adds GLES type precision\nhandling to the optimizer.\n\nThis GLSL optimizer is made for [Unity's](http://unity3d.com/) purposes and is built-in\nstarting with Unity 3.0.\n\nGLSL Optimizer is licensed according to the terms of the MIT license.\n\nSee [change log here](Changelog.md).\n\n\nUsage\n-----\n\nVisual Studio 2010 (Windows, x86/x64) and Xcode 5+ (Mac, i386) project files for a static\nlibrary are provided in `projects/vs2010/glsl_optimizer.sln` and `projects/xcode5/glsl_optimizer_lib`\nrespectively.\n\n\u003e Note: only the VS and Xcode project files are maintained and should work at any time.\n\u003e There's also a cmake and gyp build system for Linux et al., and some stuff in contrib folder -\n\u003e all that may or might not work.\n\nFor Linux you can use cmake. Just type \"cmake . \u0026\u0026 make\" in the root directory.\nThis will build the optimizer library and some executable binaries.\n\nInterface for the library is `src/glsl/glsl_optimizer.h`. General usage is:\n \n\tctx = glslopt_initialize(targetVersion);\n\tfor (lots of shaders) {\n\t\tshader = glslopt_optimize (ctx, shaderType, shaderSource, options);\n\t\tif (glslopt_get_status (shader)) {\n\t\t\tnewSource = glslopt_get_output (shader);\n\t\t} else {\n\t\t\terrorLog = glslopt_get_log (shader);\n\t\t}\n\t\tglslopt_shader_delete (shader);\n\t}\n\tglslopt_cleanup (ctx);\n\n\nTests\n-----\n\nThere's a testing suite for catching regressions, see `tests` folder. In VS, build\nand run `glsl_optimizer_tests` project; in Xcode use `projects/xcode5/glsl_optimizer_tests`\nproject. The test executable requires path to the `tests` folder as an argument.\n\nEach test comes as three text files; input, expected IR dump and expected optimized\nGLSL dump. GLES3 tests are also converted into Metal.\n\nIf you're making changes to the project and want pull requests accepted easier, I'd\nappreciate if there would be no test suite regressions. If you are implementing a\nfeature, it would be cool to add tests to cover it as well!\n\n\nNotes\n-----\n\n* GLSL versions 1.10 and 1.20 are supported. 1.10 is the default, use #version 120 to specify \n1.20. Higher GLSL versions might work, but aren't tested now.\n* GLSL ES versions 1.00 and 3.00 are supported.\n\n\nDev Notes\n---------\n\nPulling Mesa upstream:\n\n    git fetch upstream\n    git merge upstream/master\n    sh removeDeletedByUs.sh\n    # inspect files, git rm unneeded ones, fix conflicts etc.\n    # git commit\n    \nRebuilding flex/bison parsers:\n\n* When .y/.l files are changed, the parsers are *not* rebuilt automatically,\n* Run ./generateParsers.sh to do that. You'll need bison \u0026 flex (on Mac, do \"Install Command Line Tools\" from Xcode)\n* I use bison 2.3 and flex 2.5.35 (in OS X 10.8/10.9)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faras-p%2Fglsl-optimizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faras-p%2Fglsl-optimizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faras-p%2Fglsl-optimizer/lists"}