Home

Awesome

vk-samples

Samples for vk (Common Lisp/CFFI bindings for the Vulkan API).

Requirements

Supported implementations & Operating systems

See vk for supported CL implementations.

vk-samples has currently only been tested on Linux, but Windows should work as well. Some of the samples might also work on MacOS, but currently it is not guaranteed that samples using a window are run on the main thread (which is required for graphics applications on MacOS), so you might need to wrap them in a (trivial-main-thread:with-body-in-main-thread).

CL dependencies

Quicklisp

Not on Quicklisp (yet)

All of the following dependencies can be loaded via Quicklisp when they are cloned to one of your ql:*local-project-directories*.

External dependencies

Samples

The following table shows all currently available samples. You can either run them individually (e.g. (vk-samples:01-init-instance)) or run all of them except for ray-tracing using (vk-samples:run-all-samples). As with the original VulkanSamples by LunarG all samples prefixed with a number represent the progression from initializing a Vulkan instance to drawing a cube on screen. For the most part the things shown in the samples have also been refactored into the package vk-samples/utils, so later sample don't repeat too much from the earlier samples.

NameDescription
01-init-instanceShows how to create and destroy a Vulkan instance.
02-enumerate-devicesShows how to enumerate physical devices.
03-init-deviceShows how to create and destroy a Vulkan device.
04-init-command-bufferShows how to create and destroy a command pool and allocate and free command buffers.
05-init-swapchainShows how to initialize a Vulkan swapchain.
06-init-depth-bufferShows how to create and destroy a depth buffer.
07-init-uniform-bufferShows how to create and destroy a uniform buffer and how to write and read memory from it.
08-init-pipeline-layoutShows how to create and destroy a Vulkan pipeline layout.
09-init-descriptor-setsShows how to allocate descriptor sets and how to write to them.
10-init-render-passShows how to create and destroy a Vulkan render pass with a color and a depth attachment.
11-init-shadersShows how to create and destroy Vulkan shader modules from SPIR-V binaries.
12-init-frame-buffersShows how to create and destroy Vulkan framebuffers.
13-init-vertex-bufferShows how to create, fill and destroy a vertex buffer and how to record commands and submit them to a queue.
14-init-pipelineShows how to create and destroy a Vulkan graphics pipeline.
15-draw-cubeThis puts everything from the previous samples together and shows how to finally draw a cube onto a window.
create-debug-utils-messengerShows how to create and destroy a debug callback.
create-debug-utils-messenger-nextShows how to use the NEXT slot of a VK:INSTANCE-CREATE-INFO to create and destroy a debug callback alongside a Vulkan instance.
compile-shaders-from-replThis is the same as 15-draw-cube, but it compiles the shaders at runtime using shaderc.
compile-shaders-from-replThis is the same as compile-shaders-from-repl, but the shaders are written in Vari. The shaders are slightly different, because the earliest GLSL version Varjo can produce shaders targeted at Vulkan (i.e. SPIR-V compilation) for.
ray-tracingShows how to use the Vk_KHR_ray_tracing extension. This sample is not run by run-all-samples.

Ray Tracing Sample

Run (vk-samples:ray-tracing) to start the sample. Note that VK_KHR_ray_tracing needs to be supported on the device. In contrast to all other samples, this sample starts an infinite loop that has to be terminated by the user by closing the window, or by pressing Q or ESCAPE. The sample renderes a bunch of textured cubes using ray tracing or standard rasterization. Pressing R switches the rendering pipeline used. When using the ray tracing pipeline, shadows are computed using secondary rays. The camera can be moved by pressing the left or right mouse button while moving the mouse or by using the scroll wheel. Use M to cycle through camera modes and CTRL, SHIFT, and ALT while moving to change the movement type.

Acknowledgements

The samples in this repository closely follows the VulkanSamples by LunarG as well as the samples for Vulkan-Hpp.