Skip to content
Open-source universal shader translator

Write once. Run on every GPU.

CrossTL translates shaders and compute kernels through CrossGL, a universal IR that bridges Metal, DirectX, OpenGL, Vulkan, WebGPU, CUDA, HIP, Rust, Mojo, and more — in both directions.

$pip install crosstl
shader.cglCrossGL source

shader MainShader {

vertex { }

fragment { }

}

CrossGL IR
Metal
HLSL
GLSL
SPIR-V
WGSL
CUDA
Rust
Mojo
1 source→ every platform
Live translation

One source. Every backend.

Write CrossGL and switch targets instantly. Same shader, idiomatic output for each platform.

CrossGL Playground
main.cgl
shader MainShader {
  vertex {
    input vec3 position;
    input vec2 texCoord;
    output vec2 vUV;

    void main() {
      vUV = texCoord;
      gl_Position = vec4(position, 1.0);
    }
  }

  fragment {
    input vec2 vUV;
    output vec4 fragColor;

    void main() {
      vec3 col = vec3(vUV.x, vUV.y, 0.5);
      fragColor = vec4(col, 1.0);
    }
  }
}
#include <metal_stdlib>
using namespace metal;

struct VertexIn {
  float3 position [[attribute(0)]];
  float2 texCoord [[attribute(1)]];
};

struct VertexOut {
  float4 position [[position]];
  float2 vUV;
};

vertex VertexOut vertex_main(VertexIn in [[stage_in]]) {
  VertexOut out;
  out.vUV = in.texCoord;
  out.position = float4(in.position, 1.0);
  return out;
}

fragment float4 fragment_main(VertexOut in [[stage_in]]) {
  float3 col = float3(in.vUV.x, in.vUV.y, 0.5);
  return float4(col, 1.0);
}

Built for real GPU work

Not a transpiler toy — a production IR with lossless round-trips and full pipeline coverage.

One IR, twelve backends

Author in CrossGL once and emit idiomatic Metal, HLSL, GLSL, SPIR-V, WGSL, CUDA, HIP, Rust, Mojo, and Slang — graphics, compute, and systems targets from a single source.

12 targets

True bidirectional round-trips

DirectX, Metal, and OpenGL are first-class source and codegen backends. Import native shaders into CrossGL and back out losslessly — attributes, layouts, and semantics preserved.

Import + export

Full GPU pipeline coverage

Vertex, fragment, compute, geometry, tessellation, mesh/task, and full ray-tracing stages — with cbuffers, UAVs, argument buffers, structured buffers, wave ops, and atomics.

7 shader stages

Open source, battle-tested

Apache-2.0 and published on PyPI. 321 backend-parity tests keep DirectX, Metal, and GLSL round-trips verified. No CrossGL account or API key required for local use.

321 tests · $0
The pipeline

Five stages, one IR

01

Lex

Tokenize source shaders and kernels.

02

Parse

Build a typed abstract syntax tree.

03

Analyze

Type checking and scope resolution.

04

CrossGL IR

Lower into the universal intermediate representation.

05

Codegen

Emit idiomatic code for any backend.

Twelve targets and counting

Graphics, web, compute, and systems languages — with bidirectional support on the cornerstone APIs.

bi

Metal

Apple GPU

Graphics
bi

HLSL

DirectX 11 / 12

Graphics
bi

GLSL

OpenGL

Graphics
target

SPIR-V

Vulkan

Graphics
target

WGSL

WebGPU

Web
target

GLSL ES

WebGL 2.0

Web
target

Slang

Real-time shading

Graphics
target

CUDA

NVIDIA compute

Compute
target

HIP

AMD compute

Compute
target

Rust

GPU-oriented

Systems
target

Mojo

Compute modules

Systems
bi

CrossGL

.cgl IR

IR

bi = bidirectional (native import + codegen). WebGL and WGSL are currently codegen targets.

Beyond one shader

Port whole codebases, both ways

Import existing HLSL, Metal, or GLSL into CrossGL, then re-emit anywhere. For large repos, scan first, translate the project, and get a portability report with diagnostics, artifact provenance, and manual migration actions.

  • Reverse-translate native shaders into CrossGL
  • Scan repos for portability before you commit
  • Project reports with diagnostics and provenance
terminal
# scan a repo for portability
$ crosstl scan ./engine --target metal

# translate the whole project
$ crosstl translate-project ./engine \
    --target metal \
    --report out/report.json

✓ 128 shaders → Metal · 0 blocking issues

# import native HLSL back into CrossGL
$ crosstl translate pbr.hlsl --backend cgl

12

Backends

321

Parity tests

7

Shader stages

Apache-2.0

License

Ship one shader everywhere

Install the open-source package and translate across every major GPU platform — no CrossGL account or API key required.