Nyar

← All projects

IIRENDERER experimental

Nyar

A real-time Vulkan 1.3 renderer, built as a separate module for Nodens as a learning exercise. It starts from the Khronos "Drawing a triangle" tutorial and is refactored step by step into a clean rendering API.

  • 01 · Shaders

    Slang to SPIR-V

    Shaders are written in Slang, a shading language, and compiled to SPIR-V (the format Vulkan loads) by a custom CMake target.

  • 02 · Pipeline

    Modern Vulkan 1.3

    Uses Vulkan's current features: dynamic rendering (no render pass objects), synchronization2 and extended dynamic state.

  • 03 · Direction

    Nodens integration

    Packaged as a C++ module (export module nyar;) that Nodens applications import as their rendering backend.

hello-triangle · vertMain → fragMain
shaders/shader.slang slangc → spirv_1_4

                    

Where it is today

Nyar is at the start of its path. The code that runs now is the Khronos Drawing a triangle tutorial, adapted to run inside a Nodens application as nyar-test-app. It is a known-good baseline and not yet the renderer. The public renderer boundary, src/nyar.cppm, holds only the module declaration for now.

The plan is to finish the tutorial, then refactor and morph that working code step by step into a dedicated renderer API that Nodens applications import.

Working with Nodens

  • 01 · Nodens owns

    The platform

    Nodens creates the Vulkan instance, surface and logical device, picks the physical device, and owns the swapchain. It also acquires each image and presents it.

  • 02 · Nyar borrows

    The handles

    A Nodens layer borrows the device, swapchain images and views, extent, format and the active command buffer. It never destroys them.

  • 03 · Nyar records

    The scene

    The scene pass is recorded inside a Nodens layer. Nodens finishes the frame afterwards, so other renderers can append work after Nyar's pass.

What the baseline requires

Checked when a GPU is picked, so an unsuitable device is rejected up front.

RequirementWhy
Vulkan 1.3The baseline for dynamic rendering and synchronization2
dynamicRenderingRender passes without render pass or framebuffer objects
synchronization2Clearer barrier and submission structures
extendedDynamicStateMore pipeline state set at record time
shaderDrawParametersLets the vertex shader read SV_VertexID, which the triangle shader uses

Presentation and debugging

  • 01 · Surface

    sRGB colour

    The swapchain prefers B8G8R8A8 with an sRGB non-linear colour space.

  • 02 · Present

    Mailbox, else FIFO

    It uses mailbox presentation when the GPU offers it, and falls back to FIFO, which is always available.

  • 03 · Debug

    Validation on

    A debug messenger reports validation, performance and general messages at warning level and above.

Shaders in the build

  • A CMake function, add_slang_shader_target, runs slangc on the Slang sources.
  • It targets SPIR-V 1.4 directly, keeps the entry-point names, and emits one slang.spv holding both vertMain and fragMain.
  • Because it is an ordinary CMake target, shaders rebuild whenever their sources change and a normal build keeps them current.
shader target

Build and run

Linux with the shared dev container is the supported setup.

StepCommand
Configurecmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
Build the test appcmake --build build --target nyar-test-app
Run./build/examples/nyar-test-app/nyar-test-app

What it is built on

Nyar needs CMake 3.30 or newer for import std, the slangc compiler, GLFW and the Vulkan SDK. It fetches Nodens with CMake. The Vulkan-Hpp module comes from Nodens when it provides one, and from the Vulkan SDK otherwise.

Follow along

References

  • Akenine-Möller, T., Haines, E., Hoffman, N., Pesce, A., Iwanicki, M., & Hillaire, S. (2019). Real-time rendering (4th ed.). CRC Press.
  • Castorina, M., & Sassone, G. (2023). Mastering graphics programming with Vulkan: Develop a modern rendering engine from first principles to state-of-the-art techniques. Packt Publishing.
  • Eisemann, E. (Ed.). (2012). Real-time shadows. CRC Press.
  • Gregory, J. (2019). Game engine architecture (3rd ed.). CRC Press.
  • Lengyel, E. (2019). Foundations of game engine development: Vol. 2. Rendering. Terathon Software.
  • Marrs, A., Shirley, P., & Wald, I. (Eds.). (2021). Ray tracing gems II: Next generation real-time rendering with DXR, Vulkan, and OptiX. Apress. https://doi.org/10.1007/978-1-4842-7185-8
  • Pharr, M., Jakob, W., & Humphreys, G. (2017). Physically based rendering: From theory to implementation (3rd ed.). Morgan Kaufmann. https://www.pbr-book.org/
  • Vulkan Documentation Project. (n.d.). Vulkan documentation. https://docs.vulkan.org/spec/latest/index.html
  • Woo, A., & Poulin, P. (2019). Shadow algorithms data miner. CRC Press.