Skip to content

mnerv/HelloVulkan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HelloVulkan

Learning Vulkan.

Screenshot of Hello Vulkan application

Resources

Development

git clone git@github.com:mnerv/HelloVulkan.git

Requirements

Dependencies are fetched automatically via CMake's FetchContent.

Build

Setup CMake with Ninja:

cmake -S . -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug

Build with Ninja:

ninja -C build

Compile Shaders

Use glslc to compile the shaders

glslc shader.vert -o shader.vert.spv
glslc shader.frag -o shader.frag.spv

Windows

Download and install the SDK and it'll add 2 Environment Variables in your System variables, VK_SDK_PATH and VULKAN_SDK. These 2 variables are used for finding the vulkan-1.lib library.

macOS

Install SDK for macOS, the installer will add VULKAN_SDK, DYLD_LIBRARY_PATH, VK_SDK_PATH and VK_ICD_FILENAMES to your environments, if not you'll need to add it manually.

Example: Environment variables

export VULKAN_SDK={PATH_TO_VULKAN_SDK}/macOS
export PATH=$VULKAN_SDK/bin:$PATH
export DYLD_LIBRARY_PATH=$VULKAN_SDK/lib:${DYLD_LIBRARY_PATH}
export VK_LAYER_PATH=$VULKAN_SDK/share/vulkan/explicit_layer.d
export VK_ICD_FILENAMES=$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json

NOTE: This setup is only for development, you can't ship it yet.

Notes

Check vk_layer_settings.txt in Vulkan SDK Config.

Operations in Vulkan requires command, such as uploading textures to be submitted to a queue. There are different type of queues for subset of commands.

Surface: is a list of image buffers that are eventually displayed to the user.

https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#boilerplate-wsi-header

Vulkan Graphics Pipeline

Typical graphics pipeline:

graphics_pipeline = [
  input_assembler,
  vertex_shader,
  tessellation_control_shader,
  tessellator,
  tessellation_evaluation_shader,
  geometry_shader,
  transform_feedback,
  rasterizer,
  fragment_shader,
  color_blend,
]

Some techniques also make use of compute shaders, which run outside the graphics pipeline:

[
  compute_shader,  // DLSS, ray tracing (VK_KHR_ray_tracing_pipeline), particle simulation,
                   // physics, culling, post-processing (bloom, SSAO)
]

Compute shaders don't insert into the pipeline - they run as separate dispatch calls. The typical order is:

frame = [
  compute_shader,    // before: culling, physics, build ray tracing acceleration structures
  ...graphics_pipeline,
  compute_shader,    // after: DLSS, bloom, SSAO, tone mapping
  present,
]

About

Learning Vulkan API!

Topics

Resources

Stars

Watchers

Forks

Contributors