[!IMPORTANT]
The primary repository has moved to git.rosseaux.net/BeRo1985/pasvulkan.
This GitHub repository is kept up-to-date via push mirroring.
PasVulkan
A Vulkan-based game engine and application framework for Object Pascal.
PasVulkan started in 2016 as an auto-generated Vulkan header binding for Object Pascal. It has since grown into a complete, self-contained engine: a GPU-driven Vulkan renderer with clustered forward+ shading, several global illumination techniques, hardware ray tracing, a procedural planet renderer, a 2D canvas with signed-distance-field text rendering, a widget toolkit, a software audio mixer with HRTF spatialization, an asset pipeline, a scripting language, a physics engine, a networking library — and even an in-process RISC-V emulator and a local LLM inference engine.
Almost everything is written in Object Pascal from the ground up. There is no C/C++ middleware in the core: image loaders, font rasterization, audio mixing, video decoding, compression, physics and networking are all native Pascal implementations. The only mandatory runtime dependency is the Vulkan loader. On Windows the framework talks to the native Win32 APIs directly and needs nothing else, while SDL 2.x is used as the OS abstraction layer on Linux.
Contents
Status and scope
PasVulkan is an open source engine under continuous, active development, and free to use under the zlib license. It is not a packaged product though: there is no stable API promise, no versioned release cycle, and documentation is spread across the source code and the docs/ folder. Expect to read Pascal sources.
Development is driven by the games built with it — the ones in projects/ are the engine's own test bed, and features land when those games need them, not on a roadmap.
The Vulkan.pas binding header (and its vkxml2pas.dpr generator) is usable stand-alone and stays compatible even with the old Delphi 7 compiler. The PasVulkan.*.pas framework units are not — they use generics, operator overloading, advanced records and other modern Object Pascal syntax.
Feature overview
Vulkan bindings and framework
Vulkan.pas — a complete, C-API-style Vulkan header for Object Pascal, auto-generated from vk.xml by vkxml2pas.dpr, so it is always up to date. Currently tracks Vulkan 1.4 (VK_HEADER_VERSION 346), including all registered extensions.
PasVulkan.Framework.pas — an object-oriented abstraction over the raw API: instances, devices, queues, command buffers, swap chains, render passes, pipelines, descriptor sets, buffers, images, samplers, synchronization primitives and so on.
- Vulkan memory management — a best-fit red-black-tree-based sub-allocator that packs allocations into few large device memory blocks, keeping the live allocation count well below
maxMemoryAllocationCount, with allocation groups for budget tracking and a dedicated visualizer tool.
- Texture loading with native Pascal decoders — KTX, KTX2, DDS, HDR (Radiance), PNG (all types including 16-bit channels), JPEG, TGA, QOI and BMP — plus block-compressed formats (BC, ETC2, ASTC) passed straight through to the GPU, optional automatic GPU mipmap generation, and sRGB / additional-sRGB view handling.
- Screenshot and capture API for swap chain and framebuffer contents, with native PNG, JPEG and QOI writers.
- Transfer queue with asynchronous, batched uploads, and a buffer range allocator for suballocating within large shared buffers.
- Ray tracing (
PasVulkan.Raytracing.pas) — BLAS/TLAS construction and management, compaction, build queues, instance and geometry info management, and a cull-mask system.
PasVulkan.FrameGraph.pas — a render graph that resolves pass dependencies, allocates and aliases transient resources, and inserts the required barriers and layout transitions automatically, across multiple queues.
Application framework
PasVulkan.Application.pas — a Vulkan-optimized application/screen framework whose overall design mixes VCL/LCL/FCL and libGDX concepts. It handles the whole lifecycle: device selection, swap chain creation and recreation, frame pacing, input, and screen/state management.
- The OS backend is chosen per platform behind the framework's own abstraction. Windows uses the native Win32 APIs directly — own window class and message loop, Win32 GameInput for controllers, MMSYSTEM WaveOut (a thin WASAPI wrapper on Windows 10 and newer) for audio output — so no SDL is involved there. Linux uses SDL 2.x, Android has its own path, and a headless mode exists for tools and tests.
- Automatic recovery from
VK_ERROR_SURFACE_LOST_KHR, VK_ERROR_OUT_OF_DATE_KHR and VK_SUBOPTIMAL_KHR. Critical situations such as VK_ERROR_DEVICE_LOST remain the application's responsibility.
- Single-window by design, for maximum cross-platform friendliness.
PasVulkan.Win32.GameInput.pas for Windows GameInput controller support, and PasVulkan.VirtualReality.pas with an OpenVR backend plus a VR-aware screen class.
Scene3D: the GPU-driven 3D renderer
PasVulkan.Scene3D*.pas implements a strict GPU-driven, clustered forward+ renderer built around an "everything-in-one-single-buffer" design: all vertex, index and material data lives in one buffer per data type, accessed bindlessly, which is what makes GPU culling, single-draw-call batching and hardware ray tracing over the same data possible. See docs/renderer_design.md for the full rationale.
Geometry and culling
- Compute-shader mesh preprocessing (skinning, morph targets, normals/tangents) into a double-buffered vertex buffer, which also yields motion vectors for free.
- Hi-Z two-pass occlusion culling with temporal-coherence visibility, supporting both standard-Z and reversed-Z depth conventions.
- Meshlets with optional mesh/task shader pipelines, plus meshlet bounds and cone culling.
- A GPU-driven LOD system with temporal and immediate modes.
- Virtual instances — automatic, temporally stable sharing of GPU resources between similar instances (
docs/scene3d_virtualinstances.md).
- Frustum cluster grid build and light assignment compute passes for forward+ light culling.
Materials and lighting
- Full glTF 2.0 material support: metallic-roughness, specular-glossiness and unlit shading models, with
KHR_materials_clearcoat, _sheen, _transmission, _diffuse_transmission, _volume, _ior, _specular, _iridescence, _anisotropy, _dispersion, _emissive_strength, KHR_texture_transform, KHR_texture_basisu, KHR_lights_punctual, KHR_animation_pointer and KHR_node_visibility.
- Precomputed GGX, Charlie and sheen-E BRDF lookup tables, plus image-based lighting with cubemap IBL filtering, spherical harmonics, reflection probes and gradient environments.
- Shadows: cascaded shadow maps with PCF, DPCF, PCSS and MSM filtering, plus blur and resolve passes, reflective shadow maps and a top-down sky occlusion map.
- Global illumination, selectable at runtime:
EnvironmentMap — static IBL environment.
CameraReflectionProbe — a per-frame updated cubemap around the camera.
CascadedRadianceHints — RSM-injected cascaded radiance hints with bounce passes.
CascadedVoxelConeTracing — cascaded voxelization with cone tracing over voxel mipmaps.
DynamicUnifiedGlobalIllumination (DUGI) — a cascaded probe grid traced against the ray tracing TLAS, storing irradiance as spherical harmonics or an octahedral atlas plus an octahedral mean/mean-squared distance term for Chebyshev visibility, which avoids the light leaking of radiance hints. Requires hardware ray tracing.
- Decals — order-stable projected decals with group masks (
docs/scene3d_decals.md).
- A GPU particle system with its own BVH build pass.
Transparency
Eight selectable order-independent transparency modes: Direct, spinlock and interlock per-pixel linked-list OIT, LOOPOIT, weighted-blended OIT (WBOIT), moment-based OIT (MBOIT), and deep & fast approximate OIT in spinlock and interlock variants.
Antialiasing, upscaling and post-processing
- Antialiasing:
None, DSAA, FXAA, SMAA, SMAA T2x, MSAA, MSAA+SMAA and TAA.
- Resampling with Lanczos or FSR EASU/RCAS, plus a CNN-based upscaler (2× / 4×, three quality levels).
- Ground-truth ambient occlusion (GTAO) with depth mip-chain and blur passes.
- Depth of field in five variants: half-res separate near/far, half-res bruteforce, full-res hexagon bokeh and full-res bruteforce, with an auto-focus compute pass.
- Tile-based motion blur, radial blur, volumetric scattering (raymarch, blur, compose), fog, lens flares/dirt/star, lens rain, screen rain and wetness maps.
- Luminance histogram, average and adaptation passes for auto-exposure.
- 18 tone mapping operators including ACES, Uncharted 2, Uchimura, Lottes, AMD, AgX (Rec.709 and Rec.2020, in base, golden and punchy looks) and Khronos PBR Neutral, plus HDR display output with faithful and BT.2390-style display mapping, and a parametric color grading stage (exposure, night adaptation, white balance, channel mixer, shadows/midtones/highlights, ASC CDL, curves, contrast, vibrance, saturation, hue) that loads and saves its settings as JSON.
- GPU picking, selection masks and selection outlines.
Planet and atmosphere rendering
PasVulkan.Scene3D.Planet.pas is a full procedural planet system: GPU heightmap terrain with brush-based editing, blend map layers, tiled LOD, grass rendering with age maps, and a pipe-model water simulation (with FP16/FP32 shader variants selected per GPU) covering flow, settling, shore foam, whitecaps, Gerstner wave displacement, rain splashes and caustics.
PasVulkan.Scene3D.Atmosphere.pas provides a physically based atmosphere with Rayleigh/Mie scattering and absorption, volumetric clouds with coverage/type/wetness maps and cloud shadows, precipitation, and support for multiple atmospheres (double-precision transforms, so several planets can coexist).
2D rendering, text and UI
PasVulkan.Canvas.pas — a batched 2D canvas with paths, strokes, fills, gradients, clipping, blend modes and transformation stacks, usable stand-alone or composited into the 3D pipeline.
PasVulkan.TrueTypeFont.pas / PasVulkan.Font.pas — a native TrueType/OpenType loader with experimental PostScript-flavoured (CFF Type 2) support and a TrueType hinting bytecode interpreter, plus on-the-fly parallelized high-quality 2D signed distance field generation (Practical Analytic 2D SDF Generation, parallelized with PasMP).
PasVulkan.VectorPath.pas and PasVulkan.SignedDistanceField2D.pas — vector path handling and SDF generation for shapes and glyphs.
- Sprites and sprite atlases built on the fly into array textures, with automatic trimming, padding, trimmed hull vectors, and sprites generated directly from vector paths or SVG path data as signed distance fields — so no external atlas packing tool is needed.
PasVulkan.GUI.pas — a retained-mode widget toolkit with a vector-based skin: windows, dialogs, popups, menus, buttons, checkboxes, single- and multi-line text edits, scrollbars, sliders, progress bars, panels, tabs, list boxes, combo boxes, splitters, color wheel/picker, list views, tree views and file dialogs, with fill/box/group/grid/advanced-grid/flow layouts.
PasVulkan.Console.pas, PasVulkan.TextEditor.pas (a rope-based text editor core with undo/redo and UTF-8 line cache) and PasTerm-based terminal emulation.
PasVulkan.PasHTMLDownCanvasRenderer.pas