A WIP Vulkan codebase
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build
docs
krust-examples
krust-io
krust-tests
krust
thirdparty
tools
.gitignore
BUILD.md
CMakeLists.txt
LICENSE.md
README.md

README.md

Krust

Note that this is a work in progress library, not yet ready for users, and this github repo is maybe best viewed as off-site backup for the developer for now. Having noted that, in a layered graphics stack, Krust seeks to solve problems one level up from the explicit GPU API Vulkan. There are currently three modules:

Building

See BUILD.md in this directory for instructions.

Using Krust

Struct Initializers

Vulkan has many structs to be passed into its API which are tagged with a long enumerant and have an extension void pointer which must always be set to null at present. The utility functions in krust/public-api/vulkan_struct_init.h make sure the enumerant always has the correct value and the extension pointer is null. There are variants which also ensure that every struct member is initialised and none are omitted. In addition there are initialisation functions for small structs used in the API.

Examples

Usage without the initialization functions:

 VkImageCreateInfo info;
 info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
 info.pNext = nullptr;
 info.flags = 0;
 info.imageType = VK_IMAGE_TYPE_2D;
 // ...

Usage with the first set which only set the standard first two members:

 auto info = ImageCreateInfo();
 info.flags = 0;
 info.imageType = VK_IMAGE_TYPE_2D;
 // ...

In the second example those first two lines of member initialization are saved and the enum is guaranteed correct.

Usage with the second set of initialisers which take parameters and guarantee that all members are set:

 auto info = ImageCreateInfo(
   0,
   VK_IMAGE_TYPE_2D,
   // ...
 );

Initialising a simple struct without these helpers:

  VkOffset2D offset;
  offset.x = 64;
  offset.y = 128;

Usage with these helpers:

auto offset = Offset2D(64, 128)

See krust-examples/clear/clear.cpp and krust-examples/clear2/clear2.cpp for more usage examples.

Developing Krust

Coding Standard

See the design docs here.

Adding a Header File to Krust

To add a public header to the core Krust project, edit the CMakeLists.txt for it which lives at: krust/public-api/CMakeLists.txt.

set(KRUST_PUBLIC_API_HEADER_FILES
  ${KRUST_PUBLIC_API_DIR}/krust.h
  ${KRUST_PUBLIC_API_DIR}/vulkan_struct_init.h
  ${KRUST_PUBLIC_API_DIR}/new_file.h) //< Add your file here