I've built a demo of a single shared Rust codebase that runs on every major GPU platform:
CUDA for NVIDIA GPUs
for NVIDIA GPUs SPIR-V for Vulkan-compatible GPUs from AMD, Intel, NVIDIA, and Android devices
for Vulkan-compatible GPUs from AMD, Intel, NVIDIA, and Android devices Metal for Apple devices
for Apple devices DirectX 12 for Windows
for Windows WebGPU for browsers
for browsers CPU fallback for non-GPU systems
The same compute logic runs on all targets, written entirely in regular Rust. No shader or kernel languages are used.
The code is available on GitHub.
GPUs are typically programmed using specialized languages like WGSL, GLSL, MSL, HLSL, Slang, or Triton. These languages are GPU-specific and separate from the host application's language and tooling, increasing complexity and duplicating logic across CPU and GPU code.
... continue reading