gecko-dev/gfx/wr/glsl-to-cxx
Lee Salzman 7a0649e83c Bug 1703402 - Clamp RGB components after YUV conversion for SWGL blending. r=jrmuizel
This expands on an earlier fix from bug 1698009. It turns out we can occasionally find
YUV values which can still produce negative RGB values if only Y is clamped. The final
solution to this is just to clamp the output RGB values rather than input YUV values.

Since this is only used when we fall off the SWGL fast-paths (which properly handle
this clamping already), the performance impact of the extra clamping should be negligible.

Differential Revision: https://phabricator.services.mozilla.com/D111032
2021-04-07 01:25:34 +00:00
..
src Bug 1703402 - Clamp RGB components after YUV conversion for SWGL blending. r=jrmuizel 2021-04-07 01:25:34 +00:00
Cargo.toml Bug 1684334 - Fix glsl-to-cxx licensing. r=kvark 2020-12-28 14:05:17 +00:00
README.md Bug 1681870 - Fix markdown formatting of README. r=lsalzman 2020-12-11 04:13:04 +00:00

A GLSL to C++ translator.

Translates GLSL to vectorized C++. Intended for use with WebRender software backend.

Architecture

GLSL code is parsed by the glsl crate. In hir.rs we traverse the resulting AST and build a higher level representation by doing type checking and name resolution. The resulting hir tree is traversed by lib.rs to output C++ code.

The generated C++ code is 4x wider then the original glsl. i.e. a glsl 'float' becomes a C++ 'Float' which is represented by a xmm register (a vector of 4 floats). Likewise, a vec4 becomes a struct of 4 'Float's for a total of 4 xmm registers and 16 floating point values.

Vector branching is flattened to non-branching code that unconditionally runs both sides of the branch and combines the results with a mask based on the condition.

The compiler also supports scalarization. Values that are known to be the same across all vector lanes are translated to scalars instead of vectors. Branches on scalars are translated as actual branches.