Introduction
Wyn is a minimal functional programming language designed for GPU shader programming. It generates SPIR-V code for use with modern graphics APIs like Vulkan and WebGPU. The language draws inspiration from Futhark’s array-oriented programming model while maintaining simplicity and focusing specifically on shader development.
Design Goals
- Shader-focused: Designed specifically for vertex, fragment, and compute shader programming
- Array-oriented: First-class support for multi-dimensional arrays and array operations
- Type-safe: Static type checking with explicit type annotations
- SPIR-V target: Direct compilation to SPIR-V for maximum compatibility
- Functional: Immutable data structures and expression-based computation
- Minimal: Small, focused language with essential features for shader development
Key Features
- Multi-dimensional array types with literal syntax
- Built-in functions for array-to-vector conversion (SPIR-V compatibility)
- Entry point declarations for vertex and fragment shaders
- Automatic semantic mapping (e.g.,
[4]f32→gl_Positionfor vertex shaders) - Static type checking with type inference
- Integration with GPU built-in variables (
gl_VertexIndex, etc.)
Language Overview
Wyn programs consist of:
- Global declarations: Constants and arrays defined with
letordef - Built-in function signatures: Polymorphic functions defined with
val - Shader entry points:
entrydeclarations with#[vertex],#[fragment], or#[compute]attributes