Skip to content

Shading Languages and Single-Source GPU Programming ​

A survey of the languages GPU code is written in, the host languages that compile their own code for the GPU, and the toolchains between them — the evidence base for growing sparkles:shaders from a fragment-shader vocabulary into a complete single-source replacement for GLSL, HLSL, Slang, WGSL and MSL. It covers five shading languages, twelve single-source systems (D's own dcompute among them) and seven compilers and translators, each read from its source tree at a pinned revision.

The survey answers seven questions:

  1. What must a complete replacement express? The stages, types, resources and built-ins of the five shading languages, and where they diverge — GLSL, HLSL, Slang, WGSL, MSL, and the capability matrix.
  2. How do other host languages compile their own code for the GPU, and what do they restrict? rust-gpu, CUDA and HIP, SYCL, Circle, Vcc and Shady, TypeGPU, ComputeSharp, ILGPU, Julia, Zig; synthesis in the single-source spectrum.
  3. How do shaders run on a CPU with their GPU semantics? The SPMD-on-SIMD model of ISPC, ILGPU's two CPU accelerators, HIP-CPU's fibers, SYCL's abandoned host device; synthesis in CPU execution.
  4. What can the LLVM toolchain sparkles builds on emit, and what does it get wrong? LLVM's SPIR-V backend, Clang HLSL (which drives it), DXC as the reference it is measured against.
  5. What does each translator accept, and so which targets can one SPIR-V module reach? SPIRV-Cross, naga, Tint; synthesis in the translation ceiling.
  6. Would MLIR serve shaders better than LLVM IR? MLIR's SPIR-V dialect and the LDC MLIR effort.
  7. Where does sparkles stand against all of it? The delta table and the recommendations.

The vocabulary is defined once in Concepts; the deep-dives link to it.

Last reviewed: October 17, 2026

NOTE

Every GitHub citation is pinned to a commit, read from a local clone at that commit; non-GitHub sources (the Khronos registry, the W3C, Apple, Microsoft Learn, NVIDIA) are cited by URL. Claims a deep-dive could not verify against a pinned source say so where they are made. Three runnable examples compile D shaders with the toolchain sparkles ships and check claims this catalog makes about it.


Master catalog ​

Shading languages ​

LanguageOwnerLatest (at review)ReachesLink
GLSL (GL, ES, Vulkan)KhronosGLSL 4.60 rev 9, ES 3.20 rev 9; growth by extension onlyOpenGL/ES drivers; SPIR-V via glslangGLSL
HLSLMicrosoftShader Model 6.9 retail (DXC v1.9.2602, 2026-02-20); 6.10 previewDXIL (D3D12), SPIR-V (DXC -spirv, Clang)HLSL
SlangKhronos (ex-NVIDIA)v2026.20 (2026-10-16); language editions 2025, 2026SPIR-V, DXIL, Metal, WGSL, CUDA, C++, LLVMSlang
WGSLW3C GPU for the WebCandidate Recommendation Draft, 2026-09-21; no version numbersWebGPU (Tint, naga, WebKit) → SPIR-V, HLSL, MSLWGSL
Metal Shading LanguageAppleMSL 4.1 (2026-06-04), C++17-basedAIR / metallib (Apple GPUs)MSL

Single-source systems ​

SystemHost languageLatest (at review)Device targetsGraphics stagesCPU execution of device codeLink
dcompute + sparkles:shadersD (LDC)LDC v1.43.0; fork 64104a9aOpenCL SPIR-V, PTX; Vulkan SPIR-V (compute; fragment in fork)fragmenthost build of host-and-device modulesdcompute
rust-gpuRust (nightly)0.11.0 (2026-10-13)Vulkan/OpenGL SPIR-V; WGSL via nagaallshared crates; GPU built-ins panicrust-gpu
CUDA, HIPC++CUDA guide 13.4.2; HIP 7.13.0PTX, AMDGCN, SPIR-V (chipStar, amdgcnspirv)nonenone (HIP-CPU: one fiber per thread)CUDA and HIP
SYCLC++17/20SYCL 2020 rev 12; AdaptiveCpp v25.10.0Level Zero SPIR-V, PTX, AMDGCN, host CPU; Vulkan experimentalnoneCPU backends; host device removedSYCL
CircleC++20 + Circleunversioned; shaders repo to 2022-03-09Vulkan/OpenGL SPIR-V, DXIL (offline), PTXallsame AST lowers to x86-64Circle
Vcc / ShadyC/C++ (Clang)unreleased; commit dd2787a7 (2025-10-17)Vulkan SPIR-V; C11, GLSL, ISPC, CUDA dialectsvertex, fragment, compute, ray generationvia its C/ISPC backendsVcc and Shady
TypeGPUTypeScript0.12.8 (2026-10-16)WGSL; GLSL ES 3.00 (experimental)vertex, fragment, computeone invocation at a timeTypeGPU
ComputeSharpC#v3.2.0; 4.0.0 unreleasedHLSL → DXIL, DXBC (Direct2D)Direct2D pixelbuilt-ins return defaultComputeSharp
ILGPU.NET ILv1.5.3; master 2.0.0-beta1PTX, OpenCL C, CUDA C++, HIP, MSL, vectorized C#noneCPU accelerator: threads, or SIMD lanesILGPU
ISPCC dialectv1.32.0 (2026-10-13)x86 SSE2–AVX10.2, NEON, Intel Xe GPUsnoneis the CPU target (SPMD on SIMD)ISPC
Julia GPU stackJuliaGPUCompiler 2.15.1; Lava.jl 0.1.0PTX, AMDGCN, Metal AIR, SPIR-V; Vulkan SPIR-V (Lava, own emitter)Lava onlyKernelAbstractions CPU backendJulia
ZigZig0.17.0 (2026-10-01)Vulkan, OpenGL, OpenCL SPIR-Vvertex, fragment, compute, task, meshnative buildZig

Compilers and translators ​

ToolKindInput → outputLatest (at review)Link
LLVM SPIR-V backendcompiler back endLLVM IR → SPIR-V 1.0–1.6 (kernel and shader)LLVM main 27ba4937 (2026-09-19)LLVM SPIR-V
Clang HLSLfront end + two back endsHLSL 202x → DXIL (DirectX backend), SPIR-VLLVM main, not complete in a releaseClang HLSL
DXCfront end + two back endsHLSL → DXIL, SPIR-V (-spirv), Metal (via converter)v1.9.2609 (2026-09-16)DXC
MLIR spirv dialectIR + serializerMLIR (scf, gpu, …) → SPIR-VLLVM main 27ba4937MLIR SPIR-V
SPIRV-CrosstranslatorSPIR-V → GLSL, ESSL, HLSL, MSL, C++vulkan-sdk-1.4.357.0 (sparkles' pin)SPIRV-Cross
nagatranslator + validatorWGSL, SPIR-V, GLSL → WGSL, SPIR-V, GLSL, HLSL, MSLv30.0.1 (2026-08-21)naga
TintWGSL compiler + translatorWGSL, SPIR-V → SPIR-V, HLSL, MSL, GLSL, WGSLDawn main 67d4d6e6Tint

Taxonomies ​

By how device code is produced ​

ModelSystems
Separate shading language, its own compilerGLSL, HLSL, Slang, WGSL, MSL
Host compiler grows a GPU back end (from IR)dcompute, rust-gpu, Zig, Julia, Vcc, Circle
Host compiler, single-source C++ offload modelCUDA and HIP, SYCL
Host-language subset translated to a shading languageTypeGPU (→ WGSL), ComputeSharp (→ HLSL), ILGPU (IL → PTX, OpenCL C, MSL)
SPMD dialect for CPU SIMDISPC

By how structured control flow is recovered ​

ApproachSystems
Structured by construction (the source language)GLSL, HLSL (DXC), WGSL, MSL, Slang's own SPIR-V emitter, Tint, naga
Structurizer over an unstructured IRLLVM SPIR-V backend (+ sparkles' StructurizeCFG prelude), rust-gpu, Zig, Lava.jl
Structured IR from the front endMLIR (scf → spirv), Circle
Emulation of unstructured flowVcc and Shady (continuations, at a performance and translator cost)

By CPU execution of GPU semantics ​

ModelSystems
None: device code only runs on a GPUHLSL, GLSL, WGSL, MSL, CUDA
Pure functions shared; GPU built-ins absent on CPUrust-gpu, TypeGPU, ComputeSharp, sparkles today
Thread or fiber per invocation (reference)ILGPU v1.5.3, HIP-CPU (CUDA and HIP), SYCL CPU backends
SIMD lanes under masks (SPMD on SIMD)ISPC, ILGPU master's vectorized CPU target, Vcc's ISPC backend

Milestones ​

DateMilestoneWhere
2007CUDA 1.0: single-source __host__ __device__ C++ for GPUsCUDA and HIP
2012ISPC paper (InPar 2012): SPMD on SIMD for CPUsISPC
2015SPIR-V 1.0 published with Vulkan 1.0's provisional specConcepts
2017Shader Model 6.0 and DXIL: wave intrinsics; DXC open-sourcedHLSL, DXC
2020-07-24rust-gpu's first commit (Embark Studios); community-owned since 2024-08-12rust-gpu
2020Circle C++ shaders; SYCL 2020Circle, SYCL
2021SPIR-V 1.6: OpTerminateInvocation, demote in coreConcepts
2022–2023Vulkan Roadmap 2022 profile; mesh shaders (VK_EXT_mesh_shader)GLSL
2024Slang moves to Khronos; Roadmap 2024 (maximal reconvergence, quad control)Slang
2024–2025LLVM SPIR-V backend gains shader (Vulkan) support driven by Clang HLSLLLVM SPIR-V
2025Vcc presented (HPG 2025)Vcc and Shady
2026-02-20Shader Model 6.9 retailHLSL
2026-09-21WGSL Candidate Recommendation DraftWGSL
2026-10-16LDC builds against MLIR again (ldc#5300); sparkles' toolchain emits SPIR-V 1.6 with structured control flow (#659)MLIR SPIR-V, dcompute

NOTE

The SPIR-V, Vulkan, CUDA and Shader Model dates are the specifications' publication years; the others come from the deep-dives' cited histories. Where a deep-dive could not pin a date to a source it says so.


Runnable examples ​

Each compiles a D device module with the toolchain the dev and CI shells provide (ldc2-vulkan, spirv-val, spirv-cross), runs under ci examples standalone, and prints SKIP: where the tools are missing.

ExampleShows
structured_control_flow.dEarly returns, break and continue reach SPIR-V structured at -O0 and -O2
uniform_shapes.dA loose uniform is valid SPIR-V that Vulkan rejects (UniformConstant-04655)
translator_ceiling.dDemote reaches Vulkan GLSL and HLSL SM 6 but not GLSL 3.30, ES 3.00 or MSL 2.0; terminate reaches all

Suggested reading paths ​

Sources ​

The deep-dives carry their own sources. This page's facts come from them; the pinned clones are listed in each deep-dive's Sources section.