all the gpu stacks (cuda, opengl, vulkan, directx, metal, webgpu, opencl)
- CUDA stack: The CUDA API processes CUDA C++ source code, compiling it into the PTX intermediate representation which the driver then converts into final SASS machine code for the target NVIDIA GPU.
- OpenGL stack: The OpenGL API receives GLSL source code at runtime, which is then compiled directly by the vendor’s graphics driver into a vendor-specific binary.
- OpenGL ES stack: The OpenGL ES API accepts GLSL ES shader source code that is compiled by the mobile or embedded device’s driver into a vendor-specific binary.
- Vulkan stack: The Vulkan API requires shaders, written in high-level languages like GLSL or HLSL, to be pre-compiled into the mandatory SPIR-V intermediate representation before being passed to the driver.
- DirectX stack: The Direct3D API uses shaders written in HLSL, which are compiled into an intermediate representation like DXIL (for D3D12) or the older DXBC, before the driver creates the final vendor-specific binary.
- Metal stack: On Apple platforms, the Metal API uses shaders written in MSL (Metal Shading Language), which are pre-compiled into a Metal IR within a Metal Library (
.metallib
) for efficient final compilation by the driver.
- WebGPU stack: The WebGPU API uses its own WGSL shading language, which is translated by a browser implementation like Dawn or wgpu into a native backend format such as SPIR-V for Vulkan, MSL for Metal, or HLSL for DirectX.
- WebGL stack: The WebGL API processes GLSL ES shaders in the browser, often using a compatibility layer like ANGLE to translate the graphics calls and shaders into the host system’s native API like DirectX, Metal, or OpenGL.
- OpenCL stack: The OpenCL API compiles compute kernels from either OpenCL C source code at runtime or ingests pre-compiled SPIR-V binaries, which the driver then converts into a vendor-specific binary for the target device.
so in browsers the only options are webgpu+WGSL and WebGL+GLSL basically. Some stuff can compile into GLSL, eg HLSL
WebGPU on servers: Run GPU compute headless using Dawn (Google’s C++ implementation) or wgpu (Rust implementation) as standalone libraries without any browser.
WebGL on servers: Execute OpenGL ES operations via headless-gl (Node.js native implementation) or headless Chrome with software/hardware rendering.