Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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]f32gl_Position for 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 let or def
  • Built-in function signatures: Polymorphic functions defined with val
  • Shader entry points: entry declarations with #[vertex], #[fragment], or #[compute] attributes