Skip to content

Shading Languages — Comparison ​

The synthesis of the catalog: what the five shading languages require of a complete replacement, how the single-source systems meet it, where the toolchain sets the ceiling, and where sparkles:shaders stands. It closes with a delta table and the recommendations the next specification work should start from. Terms are defined in Concepts; each claim here is grounded in the deep-dive it links to.

Last reviewed: October 17, 2026


The capability matrix ​

What each shading language can express, at the versions surveyed. "Ext." marks a feature reached only through an extension; "—" a feature the language does not have. The last column is sparkles:shaders with the toolchain of #659.

CapabilityGLSL 4.60 / Vulkan GLSLHLSL SM 6.9SlangWGSLMSL 4.1sparkles today
Vertex, fragment, computeyesyesyesyesyesfragment only
Geometry, tessellationyesyesyes—tessellation (post-tess vertex)—
Mesh, taskext. (GL_EXT_mesh_shader)yes (SM 6.5)yes—yes (object, mesh)—
Ray tracing pipelines, ray queryext.yes (DXR 1.1/1.2)yes—intersection functions, ray query—
Work graphs—yes (SM 6.8, D3D12 only)via HLSL/DXIL———
Scalar types beyond 32-bit floatint/uint/bool/double; 8/16/64-bit ext.16/64-bit (mandatory 6.9)allf16 ext.; no 64-bithalf, bfloat, no doublefloat; int as uniform only
Vectors, matricesyesyes; long vectors (6.9)yes, genericyesyes, plus simdgroup_matrixvec2–vec4 float; no matrices
User generics— (coopmat, vector built-ins only)templates (2021)interfaces + associated types—C++ templatesD templates (host and device)
Swizzlesread and writeread and writeread and writeread (write: requires ext.)read and writeread via UFCS functions
Uniform blocks, storage buffersstd140, std430, scalar (ext.)cbuffer, structured/byte buffersParameterBlock, alluniform, storageargument buffersloose uniforms only
Push constantsVulkan GLSL[[vk::push_constant]]yes—setBytes equivalent—
Bindless / descriptor indexingext. + nonuniformEXTResourceDescriptorHeapyesbinding arrays (ext.)argument buffers—
Device addressesbuffer_reference ext.vk::RawBufferLoadpointers—device T*GlobalPointer (compute kernels)
Images: sample, load/store, gatheryesyesyesyesyesSampler2D.sample only
Subgroup / wave operationsGL_KHR_shader_subgroup_*wave + quad (SM 6.0)yessubgroups ext.SIMD-group functionsvia raw llvm.spv.* intrinsics
Derivativesyes (coarse/fine)yes; in compute (6.6)yesyes (uniformity-checked)yesvia raw intrinsics
Discardterminate (demote ext.)demote semanticstarget-dependentdemoteterminate (pre-2.3)via raw intrinsics
Specialization constantsconstant_id[[vk::constant_id]]link-time constantsoverridefunction_constant—
Automatic differentiation——forward and backward———
Modules, separate compilation—DXIL librariesmodules, link-time specialisation—dynamic libraries, visible functionsD modules, one unit per package

Sources: GLSL, HLSL, Slang, WGSL, MSL, dcompute.

Two observations follow. First, the union is large but the core is shared: every language has vertex, fragment and compute stages, 32-bit scalar and vector types, uniform and storage buffers, sampled and storage images, barriers and derivatives; the remaining capabilities are reached by one or two languages, usually through an extension. Second, the languages are converging on generic programming — HLSL's templates, Slang's interfaces, GLSL's own coopmat and vector types, MSL's C++ — which D has had longest of all of them.


The single-source spectrum ​

How a host language reaches the GPU decides what of the host language survives:

ApproachExampleWhat survives of the host languageCost
Separate shading languageGLSL, HLSL, WGSL, MSLNothing; layouts and constants duplicated by handTwo implementations that drift — the problem sparkles:shaders exists to solve
Host subset translated to a shading languageTypeGPU, ComputeSharpExpressions and plain functions; the subset is what the generator understandsEach target's language becomes the ceiling; debugging is in generated code
Host compiler with a GPU back endrust-gpu, Zig, dcompute, Circle, JuliaTypes, generics, modules, compile-time code; one source treeThe back end must structure control flow and reject what shaders cannot do
Full host language, emulated on the GPUVcc and ShadyPointers, recursion, function pointersSlow (function pointers 20× CUDA's cost in the paper) and untranslatable by SPIRV-Cross
Offload modelCUDA and HIP, SYCLAll of C++ in kernels' callees, within device restrictionsCompute only; no graphics stages

The precedents that matter most for a D design sit in the third row. Each uses its host language's own type system for the shader's types and its attributes for the interface; each restricts the device subset; none of them owns the memory layout of host-and-device data (rust-gpu, Circle and Zig reuse the host struct layout and leave padding to the user), and none of them runs GPU-only built-ins on the CPU. Vcc shows the cost of not restricting: emulating C++ on Vulkan works, but the output reaches no translator and runs at a fraction of native speed, so the restriction belongs in the front end, reported at the source line.


Structured control flow ​

Every shading language is structured by construction; every host language is not. The four strategies seen in the catalog:

StrategyUsed byOutcome
Structurizer in the SPIR-V back endLLVM SPIR-V backend, Zig, rust-gpu, Lava.jlHeuristic; the LLVM one picks the first eligible successor as a merge block and fails ordinary early returns
Generic structurization before the back endsparkles (LLVM StructurizeCFG, from #659), AMDGPUNested single-entry, single-exit regions with flow blocks; every probe shape validates
Structured IR from the front endMLIR scf → spirv, naga, TintCorrect by construction; MLIR's SPIR-V dialect lacks graphics ops (derivatives, demote)
EmulationVcc and ShadyAny control flow, at a performance and translator cost

Structure matters beyond validity: subgroup operations and derivatives are defined by where control flow reconverges, and Vulkan's maximal-reconvergence and quad-control features (Roadmap 2024) let a shader rely on it. A design that serves subgroup code must therefore say where its reconvergence points are and keep the optimiser from moving them — Clang emits convergence tokens for this, and LDC's dcompute does not yet (Clang HLSL, LLVM SPIR-V backend).


CPU execution ​

Running a shader on the CPU with its GPU semantics intact is rare:

SystemModelBarriersSubgroups / quadsDerivatives
ISPCSPMD on SIMD: a gang of lanes in vector registers, masksnone inside a gangthe gang is the subgroup—
ILGPU v1.5.3One OS thread per lanereal barrierswarps emulated over threads—
ILGPU masterA group as SIMD lanes under an active maskgroup size ≤ SIMD widthlanes of one vector—
HIP-CPU (CUDA and HIP)One fiber per threadfiber switch per threademulated—
SYCL CPU backendsKernel compiled for CPU, work items as loop iterationskernel split at each barriersub-groups mapped to vector lanes—
rust-gpu, TypeGPU, ComputeSharpShared pure functions only—GPU built-ins panic or return default—

No surveyed system executes fragment shaders on the CPU with quads, helper lanes and derivatives. Two further lessons bear directly on the plan. SYCL removed its host device because no one could agree whether it was an emulator for testing or a fast CPU target (SYCL); a scalar reference executor and an SPMD executor are two products with two contracts. ISPC's masking is done in its front end from its uniform/varying types (ISPC); an LLVM-level executor for D needs a whole-function vectorizer (the RV vectorizer and DPC++'s Vecz are the precedents) with uniformity analysis, linearised divergent control flow and an all-lanes-active fast path — ISPC's own measurements put that path at a 0.73× slowdown when missing. ILGPU's two accelerators disagree on edge cases (an out-of-range shuffle source, a lane that returns before a barrier), which is the case for pinning those semantics in a conformance corpus run at several SIMD widths.


The translation ceiling ​

One SPIR-V module reaches only the targets its translators accept:

Feature in the SPIR-V moduleSPIRV-Cross → GLSL 3.30 / ES 3.00→ Vulkan GLSL→ HLSL→ MSLnaga → WGSLTint → WGSL
Vertex, fragment, computeyesyesyesyesyesyes
Geometry, tessellationyesyesgeometry onlytessellation (emulated)——
Mesh, task—yesyesyesparsed—
Ray tracing—yesray query onlyray query only——
OpTerminateInvocationyesyesyesyes—yes
OpDemoteToHelperInvocation—yesyes (SM 6.0)MSL 2.3+—— (emulated)
Buffer device addresses (OpPtrAccessChain)———yes——
Int64, Float644.0+ / —yesyes64-bit int onlyyes—
SPIR-V version acceptedanyanyanyanyany≤ 1.3 (Vulkan 1.1)
Linkage, Kernel, untyped pointers——————

Sources: SPIRV-Cross, naga, Tint; the demote and terminate rows are checked by the runnable translator_ceiling.d.

The table makes the case for target profiles: a set of capabilities a module may use, chosen per output and checked in the D front end before any SPIR-V is emitted. A "Vulkan" profile, a "GLSL ES 3.00" profile and a "WGSL through Tint" profile admit different features; buffer device addresses, for example, reach only Vulkan and MSL, and Tint takes nothing newer than SPIR-V 1.3. A design that emits one module and hopes fails late, in a translator, far from the source line.


The consensus standard ​

Across the catalog, the practices that recur in every mature system:

  1. Stages and interface as attributes on functions and parameters ([shader("pixel")], @fragment, #[spirv(fragment)], [[vk::binding]]).
  2. Resources as opaque typed handles (Texture2D<float4>, texture_2d<f32>, Image!(…)) whose methods are the texture operations.
  3. A portable core plus extensions or profiles, never one flat feature set: GLSL's extensions, HLSL's shader models, WGSL's enable/requires, Slang's capabilities and __target_switch.
  4. Structured control flow at the IR the driver sees, and an explicit uniformity or convergence story wherever derivatives and subgroups exist.
  5. Layout computed, not assumed, wherever data crosses to the host: std140/std430 rules in GLSL, cbuffer packing in HLSL, TypeGPU's schemas, ComputeSharp's generated packing.
  6. Reflection of the compiled interface to the host (Slang's reflection API, SPIRV-Reflect, naga's module info) rather than hand-kept binding tables.

Architectural trade-offs ​

ChoiceForAgainst
LLVM IR → SPIR-V (today)One front end for host and device; LLVM's optimiser; shared with Clang HLSLUnstructured IR; a young back end with a fixed stage and capability list
MLIR scf → spirvStructure kept from the source; capability inferenceMissing graphics ops; a second code generator in LDC; MLIR in the toolchain
Own SPIR-V emitter (Lava.jl, Zig, rust-gpu)Full control of output and stagesA large codebase to own (Lava's is ~13,500 lines)
One SPIR-V, many translatorsOne compiler; mature translatorsThe intersection of translators is the ceiling
Generate source languages directly (TypeGPU, ComputeSharp)Readable output; no translatorOne generator per target
DXIL via LLVM's DirectX back endReaches D3D-only features (work graphs, SER)A second device back end; validator signing on D3D12 unverified
CPU twin: shared pure functionsFree; exact agreement on mathNothing GPU-specific is testable on the CPU
CPU twin: lock-step executorSubgroups, quads, barriers and derivatives testable on the CPUA new subsystem; two executors if SPMD speed is wanted

Delta table ​

What the field offers, against sparkles:shaders with the toolchain of #659 (dcompute is the detailed account):

CapabilityFieldsparkles:shaders todayGap
Stagesall 14 (GLSL, HLSL, Slang)fragment; compute kernels via dcomputevertex in the fork; the rest need LLVM back-end work
Typesscalars to 64 bits, matrices, generic vectorsfloat vectors of 2–4; int uniformsinteger, bool, double, half vectors; matrices
One project vector type—shader vec* and sparkles.math.Vector differunify (decided)
Swizzlesread and writeread, through UFCSwrite swizzles need a struct vector
Resourcesblocks, buffers, images, samplers, push constants, bindlessloose uniforms, one Sampler2D kind, one shared samplerthe whole resource model
Layoutstd140, std430, scalarone layout (vec3 16 bytes) matching neitherCTFE-computed layouts
Built-ins~170 GLSL functions, subgroups, atomics, derivatives~15 math functions; samplethe library
Control flowstructured by constructionstructured since #659 (StructurizeCFG + structurizer fix)convergence tokens for subgroup code
Rejected device constructsper languagerecursion (since #659), module-scope variables, GC, stringsimmutable tables and workgroup memory are blocked by the module-variable ban
TargetsSPIR-V, DXIL, GLSL, HLSL, MSL, WGSLGLSL 3.30, ES 1.00 via SPIRV-CrossVulkan SPIR-V, ES 3.x, HLSL, MSL, WGSL; per-target profiles
Validationspirv-val per environmentuniversal SPIR-V 1.6 rulesVulkan validation once a Vulkan output exists
CPU executionISPC, ILGPU, HIP-CPU executorshost build of pure functionsscalar reference executor, then SPMD
ReflectionSlang, SPIRV-Reflect, naganames checked by the compiler; no reflection databinding tables for Vulkan hosts
Precision contractVulkan's table; most peers silentD12, checked by a GPU readbackextend to each new built-in

Recommendations ​

For the specification work that follows; each names the deep-dives it rests on.

  1. Define target profiles first. A profile is a set of SPIR-V capabilities and a SPIR-V version, checked in the D front end with the source line of the offending construct, and the delta of each translator (SPIRV-Cross, naga, Tint) becomes data instead of a late failure.
  2. Build the resource model and the Vulkan output together. Loose uniforms are valid only for OpenGL (uniform_shapes.d); a uniform block, push constants and descriptor bindings derived from D declarations are the prerequisite of every Vulkan feature (GLSL, HLSL, LLVM SPIR-V backend).
  3. Compute layouts at compile time. std140, std430 and scalar layouts from D structs, checked with static assert on both sides, are what no peer offers and what D's CTFE makes cheap (TypeGPU, ComputeSharp, rust-gpu).
  4. Name the three kinds of discard. Terminate and demote are different programs; a D vocabulary should spell both and lower demote by flag and masked writes where a target lacks it, as Tint does (Concepts, Tint).
  5. Emit convergence information. Before subgroup operations enter the vocabulary, the fork should emit the convergence tokens Clang emits, so reconvergence points survive optimisation (Clang HLSL, LLVM SPIR-V backend).
  6. Specify the scalar reference executor and the SPMD executor separately, with one semantics both are tested against, and pin the edge cases the precedents disagree on in the conformance corpus (ISPC, ILGPU, SYCL, CUDA and HIP).
  7. Treat MLIR as a contribution, not a migration. The SAoC milestone that lowers D to scf is the structure-preserving path shaders need; offering the corpus of control-flow shapes as its acceptance tests is worth more now than a second code generator (MLIR SPIR-V).
  8. Use Slang as the reference for generics over resources and for autodiff — the two areas where it leads the field and D has the mechanisms (templates, CTFE) but no design yet (Slang).

Sources ​

The deep-dives of this catalog; each carries its own pinned sources.