npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mapbox-glsl-optimizer

v0.1.3

Published

GLSL optimizer

Downloads

44

Readme

GLSL optimizer

A C++ library that takes GLSL shaders, does some GPU-independent optimizations on them and outputs GLSL 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 GLSL 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.

Almost all actual code is Mesa 3D's GLSL compiler; all this library does is spits out optimized GLSL 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 badly maintained change log.

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();
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.

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.
  • 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)