Est. 2015 Advanced

SPIR-V

A binary intermediate language defined by the Khronos Group that carries GPU shaders and compute kernels into Vulkan, OpenCL, and OpenGL, decoupling high-level shading languages from graphics drivers.

Created by The Khronos Group (specification editors John Kessenich and Boaz Ouriel)

Paradigm Intermediate representation; SSA-based, binary
Typing Static, Strong
First Appeared 2015
Latest Version SPIR-V 1.6 (2021)

SPIR-V (Standard Portable Intermediate Representation) is a binary intermediate language defined by the Khronos Group for representing GPU shaders and compute kernels. Rather than being written by hand, SPIR-V is the compiled form that high-level shading languages target: a compact, portable binary module that graphics drivers consume directly. Introduced in 2015, it sits at the center of the modern GPU programming stack, acting as the common currency between languages like GLSL and HLSL and APIs like Vulkan, OpenCL, and OpenGL.

History & Origins

SPIR-V is the successor to the original SPIR, which Khronos introduced in 2012 as an intermediate representation for OpenCL. That first SPIR was built on top of LLVM Intermediate Representation, which tied it to the details of an external, independently evolving IR format — a coupling that proved awkward as LLVM’s IR changed over time.

When Khronos set out to design the shader model for its next-generation graphics API, it took a different approach. A provisional SPIR-V specification was revealed at the Game Developers Conference in March 2015, and SPIR-V 1.0 was formally released on November 16, 2015, alongside OpenCL 2.1. The specification was edited by John Kessenich (Google), long associated with the GLSL reference compiler, and Boaz Ouriel (Intel).

The crucial design decision was that SPIR-V is not based on LLVM IR. It is a fully self-contained, Khronos-defined format with native constructs for both graphics and compute, giving it a stable, precisely specified representation that GPU vendors can implement without inheriting an external compiler’s internals.

Design Philosophy

SPIR-V’s purpose is to decouple shading languages from graphics drivers. Before it, an API like OpenGL required every driver to embed a full high-level language compiler (for GLSL) and parse shader source at runtime — a source of inconsistency, bugs, and slow load times across vendors. SPIR-V changes the contract:

  • Compile ahead of time. Developers compile their shaders to SPIR-V using their own tooling, then ship the binary. Drivers only need to consume a well-defined, low-level format.
  • Language independence. Because the driver no longer parses a specific source language, any front end that can emit SPIR-V works. This is why Vulkan can be programmed with GLSL, HLSL, or other languages interchangeably.
  • Precise, verifiable structure. SPIR-V is expressed using a control-flow graph and static single assignment (SSA) form, and it is designed to be validated, so malformed or unsafe modules can be rejected before they reach hardware.

Key Features

  • Binary word-stream format. A SPIR-V module is a sequence of 32-bit words: a fixed header followed by a stream of instructions, each identifying an operation (an Op... code) and its operands.
  • Typed, SSA-based instructions. Every result is given a unique id and an explicit type. Types, constants, and variables are all declared through instructions rather than a separate syntax.
  • Capabilities and extensions. A module declares the capabilities it relies on (for example, Shader for graphics or Kernel for compute), letting the same format scale from mobile GPUs to compute clusters while allowing consumers to reject features they do not support.
  • Multiple execution models. SPIR-V represents vertex, fragment, compute, geometry, tessellation, and (via extensions) ray-tracing and mesh shader stages, as well as OpenCL kernels.
  • A human-readable disassembly. While SPIR-V is fundamentally binary, its tooling can print an assembly-like textual form for inspection and debugging.

A short excerpt of that disassembled textual form for a trivial fragment shader looks like this:

; SPIR-V
; Version: 1.0
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %main "main" %color
               OpExecutionMode %main OriginUpperLeft
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
      %float = OpTypeFloat 32
    %v4float = OpTypeVector %float 4
%_ptr_Output = OpTypePointer Output %v4float
      %color = OpVariable %_ptr_Output Output

In practice, developers rarely read or write this directly; it is produced and consumed by compilers and tools.

Tooling

A substantial open-source ecosystem surrounds SPIR-V, much of it maintained by Khronos:

  • glslang — the reference GLSL/HLSL front end, whose glslangValidator compiles source shaders to SPIR-V.
  • SPIRV-Tools — a suite for assembling, disassembling, validating, and optimizing SPIR-V modules.
  • SPIRV-Cross — translates SPIR-V back into GLSL, HLSL, and Metal Shading Language, so engines can target platforms that do not natively consume SPIR-V.
  • SPIRV-LLVM-Translator — provides bidirectional translation between SPIR-V and LLVM IR, connecting SPIR-V to LLVM-based compiler pipelines.

Evolution

Since SPIR-V 1.0 in 2015, the specification has advanced in step with the APIs that consume it:

VersionReleasedContext
1.0Nov 16, 2015Initial release, with OpenCL 2.1
1.1Apr 18, 2016Added OpenCL-oriented features
1.2May 16, 2017Aligned with OpenCL 2.2
1.3Mar 7, 2018Shipped with Vulkan 1.1; subgroup operations
1.4May 7, 2019Broadened feature set
1.5Sep 13, 2020Aligned with Vulkan 1.2
1.6Dec 16, 2021Aligned with Vulkan 1.3; latest major version

Each Vulkan release maps to a maximum supported SPIR-V version, and features that begin life as extensions are periodically promoted into the core specification. As of 2026, 1.6 remains the latest major version.

Current Relevance

SPIR-V is a foundational, if largely invisible, part of contemporary GPU programming. Every Vulkan application in existence ships its shaders as SPIR-V, and the format is used across the OpenCL compute ecosystem and by OpenGL 4.6. Open-source graphics stacks such as Mesa 3D consume it, and newer frameworks — including the Rust WebGPU implementation wgpu with its naga translation library, and the rust-gpu project that compiles Rust to shaders — build on it.

The most significant recent development came in September 2024, when Microsoft announced that Direct3D would adopt SPIR-V as its shader interchange format, replacing the proprietary DXIL, starting with Shader Model 7. Microsoft committed to building SPIR-V↔DXIL translation tools and to working with Khronos and the LLVM project — a notable convergence that would make SPIR-V the common shader representation across the two dominant desktop graphics APIs.

Why It Matters

SPIR-V solved a long-standing problem in graphics programming: the tight, fragile coupling between shading languages and the drivers that had to compile them at runtime. By defining a stable, portable, validated binary format, it let developers choose their own source language and toolchain, moved compilation out of the driver, and gave GPU vendors a precise target to implement. In doing so it became the connective tissue between multiple Khronos APIs — and, with Direct3D’s planned adoption, potentially the industry-wide standard for how compiled shaders are delivered to the GPU.

Timeline

2012
Khronos introduces the original SPIR (Standard Portable Intermediate Representation) for OpenCL. This early form is built on top of LLVM Intermediate Representation, a design that ties it to LLVM's evolving IR format.
2015
A provisional SPIR-V specification is unveiled at the Game Developers Conference in March 2015. Unlike earlier SPIR, SPIR-V is a fresh, fully Khronos-defined binary format that is not based on LLVM IR and has native support for both graphics shaders and compute kernels.
2015
SPIR-V 1.0 is released on November 16, 2015, alongside OpenCL 2.1, establishing SPIR-V as a cross-API intermediate language. The specification is edited by John Kessenich (Google) and Boaz Ouriel (Intel).
2016
Vulkan 1.0 ships in February 2016 with SPIR-V as its sole shader ingestion format — Vulkan drivers accept only SPIR-V, not source GLSL. SPIR-V 1.1 follows on April 18, 2016, adding features for OpenCL such as named barriers and initializer/finalizer support.
2017
SPIR-V 1.2 is released on May 16, 2017 in conjunction with OpenCL 2.2. Later in 2017, OpenGL 4.6 adds the ability to ingest SPIR-V shaders, bringing the format to the older OpenGL API.
2018
SPIR-V 1.3 is released on March 7, 2018 together with Vulkan 1.1, adding subgroup operations and other features that expose modern GPU execution models.
2019
SPIR-V 1.4 is released on May 7, 2019, broadening features available to Vulkan and other clients.
2020
SPIR-V 1.5 is released on September 13, 2020, aligned with Vulkan 1.2, folding a number of previously optional extensions into the core specification.
2021
SPIR-V 1.6 is released on December 16, 2021, alongside Vulkan 1.3. It remains the latest major version of the specification.
2024
Microsoft announces on September 19, 2024 that Direct3D will adopt SPIR-V as its shader interchange format in place of the proprietary DXIL, beginning with Shader Model 7, and commits to building SPIR-V/DXIL translation tools and collaborating with Khronos and the LLVM project.

Notable Uses & Legacy

Vulkan

Khronos's low-overhead graphics and compute API accepts shaders exclusively as SPIR-V binary modules. Every Vulkan application ships its shaders precompiled to SPIR-V rather than as source, which is the format's largest deployment.

OpenCL

SPIR-V serves as a portable intermediate representation for compute kernels in OpenCL, supported as a core feature from OpenCL 2.1 onward, letting kernels be distributed in a device-independent binary form.

Mesa 3D

The open-source Linux graphics stack consumes SPIR-V in its Vulkan drivers and for OpenGL 4.6 SPIR-V ingestion, translating it into hardware-specific instructions for a range of GPUs.

SPIRV-Cross

A Khronos tool that translates SPIR-V back into GLSL, HLSL, and Apple's Metal Shading Language, enabling engines to author shaders once and retarget platforms such as Metal and Direct3D that do not natively consume SPIR-V.

wgpu and naga

The Rust WebGPU implementation and its naga shader-translation library ingest and emit SPIR-V, using it as one of the intermediate formats bridging WGSL, GLSL, and native graphics backends.

rust-gpu

A project that compiles Rust code directly to SPIR-V, allowing GPU shaders to be written in Rust and run on Vulkan-class hardware.

Language Influence

Influenced By

SPIR LLVM IR

Running Today

Run examples using the official Docker image:

docker pull
Last updated: