All Projects → zeux → Volk

zeux / Volk

Licence: mit
Meta loader for Vulkan API

Programming Languages

c
50402 projects - #5 most used programming language

Labels

Projects that are alternatives of or similar to Volk

Island
🌋🐎 Project Island is an experimental, hot-reloading Vulkan renderer/proto-engine for Linux, written in C/C++.
Stars: ✭ 441 (-19.96%)
Mutual labels:  vulkan
Engine Native
Native engine for Cocos Creator
Stars: ✭ 488 (-11.43%)
Mutual labels:  vulkan
Xenia
Xbox 360 Emulator Research Project
Stars: ✭ 5,404 (+880.76%)
Mutual labels:  vulkan
Graphicsfuzz
A testing framework for automatically finding and simplifying bugs in graphics shader compilers.
Stars: ✭ 448 (-18.69%)
Mutual labels:  vulkan
Vk raytracing tutorial khr
Ray tracing examples and tutorials using VK_KHR_ray_tracing
Stars: ✭ 461 (-16.33%)
Mutual labels:  vulkan
Gfx
[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
Stars: ✭ 5,045 (+815.61%)
Mutual labels:  vulkan
Oreon Engine
OpenGL/Vulkan Java 3D Engine
Stars: ✭ 431 (-21.78%)
Mutual labels:  vulkan
Vkquake2
id Software's Quake 2 v3.21 with mission packs and Vulkan support (Windows, Linux, MacOS, FreeBSD, Raspberry Pi 4)
Stars: ✭ 543 (-1.45%)
Mutual labels:  vulkan
Pmtech
Lightweight, multi-platform, data-oriented game engine.
Stars: ✭ 478 (-13.25%)
Mutual labels:  vulkan
Echo
A New Cross-Platform 2D 3D Game Engine
Stars: ✭ 520 (-5.63%)
Mutual labels:  vulkan
Rust Skia
Safe Skia Bindings for Rust
Stars: ✭ 450 (-18.33%)
Mutual labels:  vulkan
Vulkanscenegraph
Vulkan & C++17 based Scene Graph Project
Stars: ✭ 462 (-16.15%)
Mutual labels:  vulkan
Vulkan Forward Plus Renderer
Forward+ renderer in Vulkan using Compute Shader. An Upenn CIS565 final project.
Stars: ✭ 513 (-6.9%)
Mutual labels:  vulkan
Vulkan Cookbook
Code repository for Vulkan Cookbook by Packt
Stars: ✭ 442 (-19.78%)
Mutual labels:  vulkan
Bulllord Engine
lightspeed lightweight elegant game engine in pure c
Stars: ✭ 539 (-2.18%)
Mutual labels:  vulkan
Vulkan Gltf Pbr
Physical based rendering with Vulkan using glTF 2.0 models
Stars: ✭ 438 (-20.51%)
Mutual labels:  vulkan
Raytracinginvulkan
Implementation of Peter Shirley's Ray Tracing In One Weekend book using Vulkan and NVIDIA's RTX extension.
Stars: ✭ 487 (-11.62%)
Mutual labels:  vulkan
Rlsl
Rust to SPIR-V compiler
Stars: ✭ 546 (-0.91%)
Mutual labels:  vulkan
Silk.net
The high-speed OpenAL, OpenGL, Vulkan, and GLFW bindings library your mother warned you about.
Stars: ✭ 534 (-3.09%)
Mutual labels:  vulkan
Vkbasalt
a vulkan post processing layer for linux
Stars: ✭ 517 (-6.17%)
Mutual labels:  vulkan

🐺 volk Build Status

Purpose

volk is a meta-loader for Vulkan. It allows you to dynamically load entrypoints required to use Vulkan without linking to vulkan-1.dll or statically linking Vulkan loader. Additionally, volk simplifies the use of Vulkan extensions by automatically loading all associated entrypoints. Finally, volk enables loading Vulkan entrypoints directly from the driver which can increase performance by skipping loader dispatch overhead.

volk is written in C89 and supports Windows, Linux, Android and macOS (via MoltenVK).

Building

There are multiple ways to use volk in your project:

  1. You can just add volk.c to your build system. Note that the usual preprocessor defines that enable Vulkan's platform-specific functions (VK_USE_PLATFORM_WIN32_KHR, VK_USE_PLATFORM_XLIB_KHR, VK_USE_PLATFORM_MACOS_MVK, etc) must be passed as desired to the compiler when building volk.c.
  2. You can use volk in header-only fashion. Include volk.h whereever you want to use Vulkan functions. In exactly one source file, define VOLK_IMPLEMENTATION before including volk.h. Do not build volk.c at all in this case. This method of integrating volk makes it possible to set the platform defines mentioned above with arbitrary (preprocessor) logic in your code.
  3. You can use provided CMake files, with the usage detailed below.

Basic usage

To use volk, you have to include volk.h instead of vulkan/vulkan.h; this is necessary to use function definitions from volk. If some files in your application include vulkan/vulkan.h and don't include volk.h, this can result in symbol conflicts; consider defining VK_NO_PROTOTYPES when compiling code that uses Vulkan to make sure this doesn't happen.

To initialize volk, call this function first:

VkResult volkInitialize();

This will attempt to load Vulkan loader from the system; if this function returns VK_SUCCESS you can proceed to create Vulkan instance. If this function fails, this means Vulkan loader isn't installed on your system.

After creating the Vulkan instance using Vulkan API, call this function:

void volkLoadInstance(VkInstance instance);

This function will load all required Vulkan entrypoints, including all extensions; you can use Vulkan from here on as usual.

Optimizing device calls

If you use volk as described in the previous section, all device-related function calls, such as vkCmdDraw, will go through Vulkan loader dispatch code. This allows you to transparently support multiple VkDevice objects in the same application, but comes at a price of dispatch overhead which can be as high as 7% depending on the driver and application.

To avoid this, you have two options:

  1. For applications that use just one VkDevice object, load device-related Vulkan entrypoints directly from the driver with this function:
void volkLoadDevice(VkDevice device);
  1. For applications that use multiple VkDevice objects, load device-related Vulkan entrypoints into a table:
void volkLoadDeviceTable(struct VolkDeviceTable* table, VkDevice device);

The second option requires you to change the application code to store one VolkDeviceTable per VkDevice and call functions from this table instead.

Device entrypoints are loaded using vkGetDeviceProcAddr; when no layers are present, this commonly results in most function pointers pointing directly at the driver functions, minimizing the call overhead. When layers are loaded, the entrypoints will point at the implementations in the first applicable layer, so this is compatible with any layers including validation layers.

Since volkLoadDevice overwrites some function pointers with device-specific versions, you can choose to use volkLoadInstanceOnly instead of volkLoadInstance; when using table-based interface this can also help enforce the usage of the function tables as volkLoadInstanceOnly will leave device-specific functions as NULL.

CMake support

If your project uses CMake, volk provides you with targets corresponding to the different use cases:

  1. Target volk is a static library. Any platform defines can be passed to the compiler by setting VOLK_STATIC_DEFINES. Example:
if (WIN32)
   set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_WIN32_KHR)
elseif()
   ...
endif()
add_subdirectory(volk)
target_link_library(my_application PRIVATE volk)
  1. Target volk_headers is an interface target for the header-only style. Example:
add_subdirectory(volk)
target_link_library(my_application PRIVATE volk_headers)

and in the code:

/* ...any logic setting VK_USE_PLATFORM_WIN32_KHR and friends... */
#define VOLK_IMPLEMENTATION
#include "volk.h"

The above example use add_subdirectory to include volk into CMake's build tree. This is a good choice if you copy the volk files into your project tree or as a git submodule.

Volk also supports installation and config-file packages. Installation is disabled by default (so as to not pollute user projects with install rules), and can be disabled by passing -DVOLK_INSTALL=ON to CMake. Once installed, do something like find_package(volk CONFIG REQUIRED) in your project's CMakeLists.txt. The imported volk targets are called volk::volk and volk::volk_headers.

License

This library is available to anybody free of charge, under the terms of MIT License (see LICENSE.md).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].