GLSL (Khronos / OpenGL, OpenGL ES, Vulkan)
The C-shaped shading language of OpenGL, OpenGL ES and WebGL, and — through GL_KHR_vulkan_glsl and glslang — still the most common way to write Vulkan SPIR-V; the language sparkles:shaders generates today and the first one its D vocabulary has to replace.
| Field | Value |
|---|---|
| Language | GLSL 4.60 (OpenGL 4.6), GLSL ES 1.00 / 3.00 / 3.10 / 3.20 (OpenGL ES 2.0–3.2, WebGL 1/2), Vulkan GLSL (GL_KHR_vulkan_glsl + GL_EXT_* / GL_KHR_* extensions) |
| License | Specification and extension sources: CC-BY-4.0 (KhronosGroup/GLSL); glslang: BSD-3-Clause and others (LICENSE.txt) |
| Repository | KhronosGroup/GLSL (spec source + Vulkan-era extensions) · KhronosGroup/glslang (reference front end and SPIR-V generator) |
| Documentation | GLSL 4.60 spec · GLSL ES 3.20 spec · GLSL ES 1.00 spec · OpenGL 4.6 core spec (block layouts) · Vulkan SPIR-V environment |
| Category | Language (source); the reference input to glslang, the reference output of SPIRV-Cross |
| Latest version | GLSL 4.60 revision 9 and GLSL ES 3.20 revision 9 (core.adoc at the pin); new features land only as extensions (e.g. GL_EXT_long_vector, 2025-12-08) |
| Targets | OpenGL/ES drivers (source); SPIR-V for Vulkan or OpenGL 4.6 (ARB_gl_spirv) via glslang |
| Pins | KhronosGroup/GLSL at 0099bf83 (2026-09-11); KhronosGroup/glslang at 5cf91e73 (2026-10-16, after 16.6.0 of 2026-09-10) |
Overview
What it solves
GLSL is the per-invocation program the OpenGL pipeline runs at each programmable stage: a main() per stage, global in/out variables for the stage interface, uniform variables and blocks for host data, and a large set of built-in functions and variables (texture, dFdx, gl_FragCoord). The same source text serves three dialects that are not subsets of one another:
| Dialect | Spelled | Consumer | What distinguishes it |
|---|---|---|---|
| Desktop GLSL | #version 330 … #version 460 | OpenGL driver | loose uniforms, atomic_uint, subroutines, double, implicit conversions |
| GLSL ES | #version 100, 300 es, 310 es, 320 es | OpenGL ES / WebGL driver | precision qualifiers are semantic; no implicit conversions; ES 1.00 is a much smaller language |
| Vulkan GLSL | #version 140+ or 310 es+, compiled by glslang -V | SPIR-V for Vulkan | descriptor sets, push constants, separate textures/samplers, specialization constants; no loose uniforms |
sparkles:shaders emits the first two today — <entry>.frag in GLSL 3.30 and <entry>.es.frag in GLSL ES 1.00 (SPEC.md SHP5) — by translating SPIR-V with SPIRV-Cross (see spirv-cross.md). To replace "the latest GLSL" it must reach the third as well, and cover the extension surface Vulkan GLSL has grown since 2016.
Design philosophy
The core specification is deliberately small and stable; the Vulkan mapping is an overlay. Its own introduction makes SPIR-V, not GLSL, normative for the bytes (chapters/introduction.adoc):
"While this specification and the {apispec} are normative for {slname}, for SPIR-V generation it is still the SPIR-V specification and the SPIR-V client API specification that are normative for the generated SPIR-V."
and makes the front end, not the driver, the capability gate:
"{slabbrev} -> SPIR-V compilers must be directed as to what SPIR-V Capabilities are legal at run-time and give errors for {slabbrev} feature use outside those capabilities."
GL_KHR_vulkan_glsl (extensions/khr/GL_KHR_vulkan_glsl.txt, revision 49, 2023-12-12) is explicit that it is not a language version but a compilation mode:
"This extension is not enabled with a #extension as other extensions are. It is also not enabled through use of a profile or #version. […] Instead, use of this extension is an effect of using a GLSL front-end in a mode that has it generate SPIR-V for Vulkan."
Everything since — subgroups, ray tracing, mesh shading, buffer references, cooperative matrices — arrived the same way: as an extension text file in KhronosGroup/GLSL that describes a GLSL spelling for an existing SPIR-V capability. The repository README says as much: it holds the extensions "notably for Vulkan" that "do not live in the Khronos registries for OpenGL or OpenGL ES" (README.adoc). GLSL in 2026 is therefore GLSL 4.60 plus a catalogue of SPIR-V spellings, with glslang as the reference implementation whose README rates its GLSL/ESSL front end "Virtually complete, with results carrying similar weight as the specifications" (README.md).
How it works
A shader is one stage per compilation unit, its interface declared at global scope and its execution modes as layout qualifiers on in/out:
#version 460
#extension GL_EXT_nonuniform_qualifier : require
layout(local_size_x = 64) in; // execution mode
layout(constant_id = 0) const uint STRIDE = 4; // specialization constant
layout(set = 0, binding = 0, std430) readonly buffer In { vec4 src[]; };
layout(set = 0, binding = 1, std430) writeonly buffer Out { vec4 dst[]; };
layout(set = 1, binding = 0) uniform texture2D textures[]; // bindless
layout(set = 1, binding = 1) uniform sampler smp;
layout(push_constant) uniform Push { uint texIndex; } pc;
void main() {
uint i = gl_GlobalInvocationID.x;
vec4 t = textureLod(sampler2D(textures[nonuniformEXT(pc.texIndex)], smp), vec2(0.5), 0.0);
dst[i] = src[i * STRIDE] * t;
}Every identifier above maps to one SPIR-V construct, and the spec's non-normative mapping chapter (chapters/spirvmappings.adoc) lists them: layout(constant_id) → OpSpecConstant + SpecId; push_constant → PushConstant storage class; texture2D → OpTypeImage, sampler → OpTypeSampler, sampler2D(t, s) → OpSampledImage; mediump/lowp → RelaxedPrecision; precise → NoContraction.
The pipeline from source to driver has two shapes:
- OpenGL / ES source path. The application hands GLSL text to the driver, which compiles it; uniforms and attributes are bound by name (
glGetUniformLocation), or bylayout(location)/layout(binding)from GLSL 3.30/4.20 (ES 3.00/3.10). - SPIR-V path. glslang parses to an AST, checks it against the target's capabilities and resource limits, and emits SPIR-V (
glslangValidator -Vfor Vulkan,-Gfor OpenGL 4.6). The README records that glslang's HLSL front end is "Deprecated as of April 2026" (README.md), leaving glslang a GLSL-only tool.
Function calls are copy-in/copy-out, not by reference (chapters/statements.adoc):
"Functions are called by value-return. This means input arguments are copied into the function at call time, and output arguments are copied back to the caller before function exit. Because the function works with local copies of parameters, there are no issues regarding aliasing of variables within a function."
That rule matters for a D vocabulary: D ref aliases, GLSL inout does not, so f(a, a) can differ between the CPU and the GPU unless the D side copies.
Execution model and stages
| Stage | Desktop GLSL | GLSL ES | Vulkan GLSL | Execution-mode syntax |
|---|---|---|---|---|
| Vertex, fragment | 1.10 | 1.00 | core | layout(early_fragment_tests) in, layout(depth_greater) out float gl_FragDepth; |
| Geometry | 1.50 | 3.20 | geometryShader feature | layout(triangles) in; layout(triangle_strip, max_vertices = 3) out; |
| Tessellation control / eval | 4.00 | 3.20 | tessellationShader feature | layout(vertices = 3) out;, layout(triangles, fractional_odd_spacing) in; |
| Compute | 4.30 | 3.10 | core | layout(local_size_x = 8, local_size_y = 8) in;, local_size_x_id |
| Task / mesh | — | — | GLSL_EXT_mesh_shader | layout(max_vertices = 64, max_primitives = 126, triangles) out; |
| Ray generation … callable | — | — | GLSL_EXT_ray_tracing (6 stages) | payloads: layout(location = 0) rayPayloadEXT T p; |
GLSL has exactly one entry point, main(), per compilation unit; SPIR-V permits many OpEntryPoints per module, which is the shape LDC emits. The stage interface is global: in/out variables, built-in blocks (gl_PerVertex), and stage-specific arrays (in vec3 n[] in geometry and tessellation). A D design that models stage inputs as function parameters — the WGSL and HLSL shape sparkles:shaders already uses (SHF2) — must therefore generate the globals; it cannot take GLSL's interface shape as its own.
The invocation group and uniform control flow are defined once, in chapters/basics.adoc: "Uniform control flow is the initial state at the entry into main(), and lasts until a conditional branch takes different control paths for different invocations". Unlike WGSL, GLSL defines the term but does not require a front end to prove anything: barrier() and implicit-LOD sampling outside uniform control flow are simply undefined. Subgroups (GL_KHR_shader_subgroup, ratified 2017-10-27, GL_KHR_shader_subgroup.txt) add a second scope, and GL_EXT_maximal_reconvergence adds void main() [[maximally_reconverges]], which "maps to the MaximallyReconvergesKHR execution mode" — a promise about reconvergence after divergent branches that an LLVM-based producer must not break by tail-merging or jump-threading across subgroup operations.
Type system and generic programming
| Family | Core | Extension types |
|---|---|---|
| Scalars | bool, int, uint (1.30 / ES 3.00), float, double (4.00, desktop only) | int8_t…uint64_t, float16_t, float64_t (GL_EXT_shader_explicit_arithmetic_types); bfloat16_t, floate4m3_t/floate5m2_t |
| Vectors | vecN, ivecN, uvecN, bvecN, dvecN, N = 2–4 | f16vecN, i8vecN, …; vector<T, N> with N > 4 (GLSL_EXT_long_vector, 2025-12-08) |
| Matrices | matN, matCxR (column-major values; row_major affects only memory) | f16matCxR, f64matCxR |
| Aggregates | structs (no member functions), fixed arrays, arrays of arrays (4.30 / ES 3.10), runtime-sized SSBO tail | unsized descriptor arrays (GL_EXT_nonuniform_qualifier) |
| Opaque | sampler2D family, image2D family, atomic_uint | Vulkan: texture2D, sampler, subpassInput; accelerationStructureEXT, rayQueryEXT, hitObjectEXT, coopmat<…> |
| References | — | layout(buffer_reference) buffer Node { … }; — a 64-bit pointer type (GLSL_EXT_buffer_reference) |
There is no user-level generic programming. Built-ins are overloaded over genFType/genIType/… families; user functions overload by parameter type; there are no templates, no interfaces, no operator overloading, and no function pointers (desktop subroutine uniforms are the one dispatch mechanism, removed in Vulkan GLSL). The only parameterised types are recent extension types — coopmat<float16_t, gl_ScopeSubgroup, 16, 8, gl_MatrixUseA> in GLSL_KHR_cooperative_matrix (2023-07-21) and vector<T, N> in GL_EXT_long_vector — whose parameters must be constant expressions or specialization constants. GLSL is converging on what D's templates already express; the D side's job is to keep the GLSL spelling (vec3, mix, fract) while replacing the preprocessor and copy-paste overloads with templates and CTFE.
Implicit conversions are a dialect difference: desktop GLSL 4.x converts int→uint→float→double; GLSL ES converts nothing ("WGSL has very limited implicit conversions" is WGSL's answer to the same problem, see wgsl.md). The D vocabulary should mirror GLSL's result types exactly and emit every conversion explicitly, which serves both dialects.
Resources, interfaces and memory layout
| Resource | Desktop GLSL | GLSL ES 1.00 | Vulkan GLSL |
|---|---|---|---|
Loose uniform float t; | yes, bound by name or location | yes, by name only | removed (opaque types excepted) |
| Uniform block (UBO) | 1.40, std140/shared/packed | — | std140 default; std430 with uniformBufferStandardLayout; scalar (GL_EXT_scalar_block_layout) |
| Storage block (SSBO) | 4.30, std430 | — | std430, scalar; runtime-sized last member |
| Push constants | — | — | layout(push_constant) uniform |
| Binding | layout(binding = N) (4.20) | none | layout(set = S, binding = N) |
| Textures | combined sampler2D | combined sampler2D | combined or separate texture2D + sampler |
| Specialization constants | via glSpecializeShader (SPIR-V only) | — | layout(constant_id = N) const … |
| Device addresses | — | — | buffer_reference (Vulkan 1.3 requires BDA) |
| Bindless | — | — | textures[nonuniformEXT(i)] (descriptor indexing) |
GL_KHR_vulkan_glsl lists what it removes — "default uniforms (uniform variables not inside a uniform block), except for opaque types", "atomic-counters", "subroutines", "shared and packed block layouts", "gl_VertexID and gl_InstanceID" — and what changes: "arrays of uniforms and buffer blocks take only one binding number for the entire object, not one per array element" and "the default origin is origin_upper_left instead of origin_lower_left" (GL_KHR_vulkan_glsl.txt). The GL and Vulkan dialects thus need a translation layer even for basic shaders; gl_VertexIndex includes the base vertex where gl_VertexID did not.
Block layouts are defined by the OpenGL specification (glspec46.core.pdf §7.6.2.2), not the GLSL one:
| Layout | Scalar | vec2 | vec3 | vec4 | Array stride / struct alignment | Matches D natural layout? |
|---|---|---|---|---|---|---|
std140 | 4 | 8 | 16 (size 12) | 16 | rounded up to 16 | no |
std430 | 4 | 8 | 16 (size 12) | 16 | element alignment | only without vec3 |
scalar | 4 | 4 | 4 (size 12) | 4 | component alignment | yes (with align(4)) |
A scalar may occupy the padding after a vec3 under std140 and std430 (offset 12), which no C or D struct reproduces; sparkles:shaders already records this as the reason its host vec3 is a 16-byte struct but not std140 (decisions.md D9). Only scalar equals natural layout, and it is an optional Vulkan 1.2 feature with no GL or ES counterpart.
GLSL ES 1.00 — the floor sparkles:shaders targets for GLES 2 — is a different language. Its Appendix A (revision 17, 2009-05-12) restricts loops to "constant iteration loops": "There is one loop index", the condition "has the form loop_index relational_operator constant_expression", and "Support for while and do-while is not mandated." Uniform arrays in the fragment shader may be indexed only by constant-index-expressions (constants and loop indices), the remainder operator % and the shift operators are "reserved" (illegal), and there is no uint. Fragment outputs are gl_FragColor/gl_FragData[], and linking between stages is by name.
Built-in library and intrinsics
The core library (GLSL 4.60 §8, chapters/builtinfunctions.adoc) has roughly 170 function names across angle/trigonometry, exponential, common (mix, step, smoothstep, fract, mod, fma, frexp), packing (packUnorm4x8, packHalf2x16), geometric, matrix, vector-relational (lessThan, any, all — because < on vectors is illegal and == reduces to one bool), integer (bitfieldExtract, findMSB, uaddCarry), texture (texture, textureLod, textureGrad, texelFetch, textureGather, textureSize), image (imageLoad, imageStore, imageAtomic*), atomics, derivatives (dFdx, dFdxFine, fwidth), interpolation (interpolateAtSample), geometry (EmitVertex), and barriers (barrier, memoryBarrier*).
| Extension | Adds | Vulkan status |
|---|---|---|
GL_KHR_shader_subgroup (+ _rotate) | subgroupAdd, subgroupBallot, subgroupShuffle, subgroupQuadBroadcast, clustered/inclusive/exclusive scans | 1.1 core (basic in compute); rotate 1.4 |
GL_KHR_memory_scope_semantics | atomicAdd(x, v, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelease), atomicLoad/Store, controlBarrier | Vulkan memory model, 1.3 required |
GLSL_EXT_ray_tracing / GLSL_EXT_ray_query | traceRayEXT, reportIntersectionEXT, ignoreIntersectionEXT;, rayQueryInitializeEXT + ~20 getters | VK_KHR_ray_tracing_pipeline / _ray_query |
GLSL_EXT_mesh_shader | SetMeshOutputsEXT, EmitMeshTasksEXT, gl_MeshVerticesEXT[], perprimitiveEXT, taskPayloadSharedEXT | VK_EXT_mesh_shader |
GLSL_KHR_cooperative_matrix | coopMatLoad, coopMatStore, coopMatMulAdd | VK_KHR_cooperative_matrix |
GLSL_EXT_demote_to_helper_invocation / GL_EXT_terminate_invocation | demote;, helperInvocationEXT(); terminateInvocation; | both required by Vulkan 1.3 |
GLSL_EXT_debug_printf | debugPrintfEXT("%d", x) through NonSemantic.DebugPrintf | validation layer |
GLSL_EXT_spirv_intrinsics | spirv_instruction(set, id), spirv_decorate, spirv_execution_mode — a raw SPIR-V escape hatch | — |
Two library facts constrain the D vocabulary directly. First, constant-expression arguments: texel offsets (textureOffset), the gather component, cluster sizes and ray payload locations must be compile-time constants — exactly what a D template value parameter expresses and a runtime argument cannot. Second, by-reference built-ins: atomicAdd, interpolateAtSample and imageAtomic* take a variable (an lvalue in a particular storage class), not a value, so their D signatures need ref plus a storage-class check.
Precision is the third. The GLSL spec defines highp as IEEE binary32 but leaves most functions unspecified ("The rounding mode cannot be set and is undefined but must not affect the result by more than 1 ULP", chapters/variables.adoc); the Vulkan environment's table (spirvenv.html) fills the gap (sin/cos absolute 2⁻¹¹ on [−π, π], atan 4096 ULP). sparkles:shaders already judges CPU/GPU agreement by that table (D12).
Control flow, memory model and restrictions
| Rule | Source |
|---|---|
| No recursion, static or dynamic | "Static, and hence dynamic, recursion is not allowed." (statements.adoc) |
No goto, no function pointers | the grammar has neither; subroutine is desktop-only and absent from Vulkan |
| Out-of-bounds access is undefined unless robustness is on | "any out-of-bounds access produced undefined behavior" (operators.adoc) |
| Barriers and implicit derivatives in uniform control flow | defined in basics.adoc, not checked |
| ES 1.00 loops and indexing | Appendix A, above |
discard meaning | under SPIR-V 1.6 OpKill is deprecated; GLSL discard maps to terminate, HLSL's to demote — the names differ by language |
The memory model comes in two layers: the legacy coherent/volatile/restrict/readonly/writeonly qualifiers plus memoryBarrier*(), and the Vulkan memory model of GL_KHR_memory_scope_semantics, which adds scopes (gl_ScopeWorkgroup, gl_ScopeDevice, gl_ScopeQueueFamily), storage classes and acquire/release semantics to every atomic and barrier. A D API built like core.atomic — atomicOp!"+="(ref x, v) with a MemoryOrder — maps onto the second layer once a Scope template parameter is added.
Control flow in GLSL source is always structured, which is why SPIRV-Cross can reconstruct it from SPIR-V merge instructions; LLVM IR is not, which is why LDC's SPIR-V must be structurised before any translation (see concepts.md).
Compilation pipeline and targets
┌──────────── OpenGL / ES driver (compiles source at run time)
GLSL source ────────┤
└── glslang ── SPIR-V ── Vulkan driver
│
D (sparkles) ── LDC ── SPIR-V ── spirv-opt ── SPIRV-Cross ── GLSL 3.30 / ESSL 1.00 ── glslangValidatorsparkles:shaders uses GLSL as an output language. Its build step (apps/shader-compile, app.d) validates the LDC module with spirv-val --target-env spv1.6, optimises with spirv-opt -O, translates each fragment entry with spirv-cross --version 330 and --es --version 100, renames the combined sampler back to the D parameter's name, and validates every file with glslangValidator (SHP4–SHP6). Two gaps in that chain are GLSL facts rather than tool bugs:
- glslang's default resource limits are permissive for ES 1.00:
nonInductiveForLoops,whileLoops,generalUniformIndexing,generalSamplerIndexingandgeneralVariableIndexingare all1inResourceLimits.cpp(lines 149–157), so the validation step does not enforce Appendix A unless a configuration file sets them to0. - SPIRV-Cross emits
%,<<and&verbatim for ES 1.00 although ES 1.00 reserves them (seespirv-cross.md); the D front end must reject them for that target.
To target Vulkan GLSL the build would add --vulkan-semantics, keep descriptor sets and push constants, and drop the combined-sampler rewrite; to target OpenGL 4.6 SPIR-V directly it could skip translation altogether.
Host integration and CPU execution
GLSL has no host-language integration: the host sees strings (source) or words (SPIR-V) and binds by name, location or set/binding, all of it reflected separately (glslang's reflector, SPIRV-Cross --reflect, SPIRV-Reflect). There is no CPU execution path in the language or its reference tooling — glslang compiles, it does not run — so CPU fallbacks are re-implementations, which is the drift sparkles:shaders exists to remove (SPEC.md §1). The closest CPU stories are software rasterisers (SwiftShader, Mesa's llvmpipe/lavapipe) that run the shader at the API level, not as a callable function.
The #define VULKAN 100 predefine and #ifdef dialect switching shown in GL_KHR_vulkan_glsl is the GLSL idiom for one source, several targets; in D it becomes version/static if, and the generated text carries only the resolved #version and #extension lines.
Lessons for sparkles:shaders
- Adopt GLSL's names and result types, not its interface shape. Keep
vec3,mix,fract,smoothstepand GLSL's overload result types (the currentSHV1vocabulary), but keep stage I/O as D function parameters (SHF2) and let the emitter generatein/outglobals,gl_FragData, and Vulkan'sgl_VertexIndexversus GL'sgl_VertexID. - Express constant-expression arguments as template value parameters:
tex.sampleOffset!(ivec2(1, 0))(uv),gather!(Component.g),subgroupClusteredAdd!4(x). A runtime parameter cannot carry GLSL's "must be a constant expression" rule; a template does, and lowers to the SPIR-V constant operand directly. - Match
inoutsemantics with copies, notref. A D helper takingrefaliases where GLSL copies in and out; either forbid passing the same lvalue twice in device code or lowerrefto a copy-in/copy-out temporary, and testf(a, a)on both sides in the conformance corpus. - Make the block layout a declared property with a CTFE checker. A
@layout(Layout.std140 | std430 | scalar)UDA on a block struct, anoffsetOf!(S, Layout, field)computed at compile time, and astatic assertthat the D struct's natural layout matches — or a generated padded mirror.vec3followed by a scalar is the test case that separates the three. - Model each GLSL feature as a capability record and check it per target. Every construct carries the SPIR-V capability, Vulkan feature, and GLSL
#version/#extensionit needs; a target profile (gles100,gl330,gl460,vulkan13) rejects code that needs more. ES 1.00's Appendix A becomes a front-end rule set (oneint/floatloop index, constant bounds, no%/shift/uint, constant indexing of fragment uniform arrays), plus a glslang configuration with the Appendix A limits set to0as a second check. - Name
discard,demoteandterminateseparately (discard()typednoreturnas terminate,demote()returning normally), because SPIR-V 1.6 deprecatedOpKilland GLSL and HLSL now mean different things bydiscard. - Avoid a preprocessor and avoid copying GLSL's missing generics.
version (Vulkan),static ifand mixins replace#ifdef VULKAN; templates replacegenFTypeoverload sets; only the emitted text needs#version/#extension.
Strengths
- Ubiquity: the only source language every OpenGL, OpenGL ES and WebGL driver accepts; GLSL ES 1.00 still reaches GLES 2 devices nothing else reaches.
- A precise SPIR-V mapping: every Vulkan GLSL construct is a documented spelling of a SPIR-V capability, so GLSL is the most faithful human-readable view of SPIR-V — which is why SPIRV-Cross targets it.
- A reference implementation with specification weight (glslang) and an extension repository that tracks new hardware within months (descriptor heap, long vectors, float8 in 2025–2026).
- Simple, stable core: GLSL 4.60's language delta from 4.50 is small (draw parameters, group votes, atomic-counter operations, SPIR-V); code written in 2017 still compiles.
Weaknesses
- Three dialects, no common subset by construction: loose uniforms,
atomic_uint, subroutines andgl_VertexIDexist in one and not another; ES has no implicit conversions; ES 1.00 is a separate language. - No generic programming: no templates, interfaces or operator overloading; reuse is the preprocessor and
#include(GL_GOOGLE_include_directive, a glslang extension). - Global interface state: stage inputs, outputs and resources are globals, which makes a shader impossible to call as a function and hard to test.
- Undefined behaviour without diagnostics: out-of-bounds access, non-uniform barriers and derivatives, shift counts and signed
%are undefined, and nothing requires a front end to report them. - Layout rules that match no host language (
std140's 16-byte array stride, scalars packed intovec3padding). - No CPU execution story.
Key design decisions and trade-offs
| Decision | Rationale | Trade-off |
|---|---|---|
Vulkan support as a compilation mode (GL_KHR_vulkan_glsl), not a #version | one language serves GL, ES and Vulkan; the front end selects semantics | the same text means different things (gl_VertexIndex, origin, binding of arrays) per mode |
| New features only as SPIR-V-shaped extensions | features ship as fast as SPIR-V capabilities do; no language revision needed | ~100 extension texts to read; feature availability is a matrix, not a version |
| Copy-in/copy-out parameters | no aliasing inside functions; simple compilers | inout differs from C/D references; large arguments are copied unless the compiler elides it |
| Global stage interface | maps one-to-one onto the fixed-function pipeline | shaders are not functions; no host-side reuse |
std140/std430 block layouts | portable across 2008-era hardware with vec4 registers | host structs need manual padding; only optional scalar matches C |
ES precision qualifiers (mediump, lowp) | let mobile GPUs run fp16 ALUs | output differs by device; sparkles:shaders had to force highp after a visible Adreno defect (D15) |
| No recursion, no function pointers | stackless hardware; every call inlines | no dynamic dispatch; generic code must be resolved at compile time |
Sources
KhronosGroup/GLSLrepository at0099bf83—README.adoc,core.adoc- GLSL spec source:
chapters/introduction.adoc,chapters/basics.adoc(uniform control flow),chapters/statements.adoc(calling conventions), recursion,chapters/operators.adoc(out-of-bounds),chapters/variables.adoc(precision),chapters/builtinfunctions.adoc,chapters/spirvmappings.adoc - Extensions:
GL_KHR_vulkan_glsl,GL_KHR_shader_subgroup,GL_KHR_memory_scope_semantics,GLSL_KHR_cooperative_matrix,GLSL_EXT_ray_tracing,GLSL_EXT_ray_query,GLSL_EXT_mesh_shader,GLSL_EXT_buffer_reference,GL_EXT_nonuniform_qualifier,GL_EXT_scalar_block_layout,GL_EXT_shader_explicit_arithmetic_types,GLSL_EXT_demote_to_helper_invocation,GL_EXT_terminate_invocation,GL_EXT_maximal_reconvergence,GLSL_EXT_long_vector,GLSL_EXT_debug_printf,GLSL_EXT_spirv_intrinsics - Khronos registry: GLSL 4.60, GLSL ES 3.20, GLSL ES 1.00 (Appendix A), OpenGL 4.6 core profile (§7.6.2.2 block layout), Vulkan SPIR-V environment and precision table
- glslang at
5cf91e73:README.md,ResourceLimits.cpp,CHANGES.md - sparkles:
SPEC.md,decisions.md,apps/shader-compile/src/app.d - Related: HLSL · WGSL · MSL · SPIRV-Cross · concepts · comparison · index