Today we’re excited to announce that we’re open-sourcing part of the Microsoft Edge WebGL renderer – specifically, the GLSL to HLSL transpiler. We hope that the source code is useful for everybody working on similar WebGL projects, and that this will help performance, correctness and interoperability of WebGL.

You can find the code on the MicrosoftEdge WebGL GitHub repository.

What is a GLSL::HLSL transpiler?

WebGL web pages run ‘programs’ (shaders) on your GPU to render 3D content; these programs are written in the GLSL shading language. Microsoft Edge uses the DirectX subsystem in Windows (and HLSL, a different Windows-specific shading language) to render content.

Microsoft Edge converts WebGL content to DirectX equivalents to display it; the WebGL renderer converts WebGL calls into DirectX equivalents, and the transpiler converts GLSL shaders to HLSL shaders.

The ANGLE project – as used in Chrome and Firefox – has similar functionality.

As an example of this conversion, here’s a super-simple program that paints a red pixel:

GLSL:

void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); // r g b a }

HLSL:

float4 main() : SV_Target { return float4(1.0f, 0.0f, 0.0f, 1); // r g b a }

The transpiler (like any compiler) parses the GLSL program, checks for correctness and security constraints, and applies a conversion process to produce HLSL output.

What’s next?

We do plan to publish additional scripts and documentation over time. By making a first drop of the source available right away, we are immediately enabling engineers working on other WebGL / OpenGL / 3D implementations to inspect the code and improve interoperability across browsers.

Why just the transpiler?

The HLSL to GLSL transpiler is the most critical component of the WebGL stack from an interoperability perspective, so we started with that. We expect it to be the most interesting for the specialized audience of engineers who maintain WebGL implementations on different platforms. We may expand the scope of the release to other sub-components over time.

Does this mean you’re open-sourcing Microsoft Edge?

One natural question following this announcement is whether this signals a move to open-source Microsoft Edge. At this time we have no plans to open source Microsoft Edge or EdgeHTML, but we understand and value the importance of being more open with our roadmap and our core technologies.

Today’s announcement builds on our recent open-sourcing of Chakra, the JavaScript engine that powers Microsoft Edge, as well as initiatives like our open roadmap on Microsoft Edge Platform Status. We continue to be committed to even more transparency with the engineering of Microsoft Edge in the future.

We’re excited about this step to improve interoperability across WebGL implementations, and we look forward to seeing your feedback on and contributions to this good. Take a look and let us know what you think!

– Frank Olivier, Principal Program Manager Lead