Skip to content

Conversation

@sharadhr
Copy link
Contributor

No description provided.

@asuessenbach
Copy link
Contributor

Is there a reason you want to rework the readme?

@sharadhr
Copy link
Contributor Author

sharadhr commented Nov 12, 2025

Hi @asuessenbach! I've been meaning to do this for a while, actually. I have a list of things that I found a little less than ideal with the current readme:

  • Be clear on what this repository is actually for (development of the Vulkan-Hpp generator); the actual generated headers can be downloaded from Vulkan-Headers.
  • More instructions on installation/usage from the Vulkan SDK, vcpkg, and Conan.
  • Rearranging some of the information to flow a bit better; e.g. start with basic Info structs, then move on to specific Vulkan types like Device, Image, etc
    • Some of the information is a bit scattershot; e.g. there are two sections for RAII best practices; these could be combined.
    • Subsume the RAII programming guide into the readme, or split the readme up altogether.
    • Also group together the language-side facilities that Vulkan-Hpp uses, e.g. [[nodiscard]], std::expected, std::optional, etc
  • Remove/edit deprecated information, especially pertaining to vulkan.cppm
  • Miscellaneous grammar, capitalisation, and formatting (e.g. as demonstrated, making all the configuration options demarcated ``in backticks`` makes it easy to avoid the \_stuff in the ToC.
    • Adhere to some Common Markdown best practices, e.g. spaces around lists, - instead of *, etc.
    • Also, the HTML hyperlinks are no longer necessary; as far as I understand, the Common Markdown specification provides a means to automatically generate a table of contents.

If you're OK with this, I can proceed with making these changes, naturally subject to your review at the end. I hope to improve the documentation at the end of this exercise.

@asuessenbach
Copy link
Contributor

You're more than welcome to rework the readme!
I'm pretty sure, any change will be an improvement.

- Remove HTML hyperlinks; markdown generates automatically
- Use backticks \` to demarcate config macros
- Remove `VULKAN_HPP_NO_STD_MODULE` option
- `-` instead of `*`
- Spaces around lists
@sharadhr
Copy link
Contributor Author

sharadhr commented Dec 15, 2025

@asuessenbach, this is still in progress (and hence in draft mode), but do feel free to have a look at the branch to see the direction I'm going in. Hopefully intend to complete this by the end of the year.

@M2-TE
Copy link
Contributor

M2-TE commented Dec 18, 2025

How about adding CMake's FetchContent to the "Installation and Usage" section?
Something akin to

include(FetchContent)
FetchContent_Declare(vulkan-hpp
    GIT_REPOSITORY "https://github.com/KhronosGroup/Vulkan-Hpp.git"
    GIT_TAG "v1.4.336" # release tag, commit hash or branch name
    GIT_SHALLOW ON)
FetchContent_MakeAvailable(vulkan-hpp)

@M2-TE
Copy link
Contributor

M2-TE commented Dec 18, 2025

For the "Build Instructions", it is likely best to separate header generation and sample/test building. At the very least, the build section should state that building is purely for those tasks and that headers can be used by just including them.

For merely using the headers (because e.g. they haven't landed in Vulkan-Headers yet), quickly showing how to link against Vulkan::Hpp in CMake would be sufficient for those users. Or showing minimal include_directories(...) usage.

@sharadhr
Copy link
Contributor Author

Both good points @M2-TE. I am focusing mostly on Usage for now (since that is where I see the biggest shortfall in documentation), but I will add these in to Building when I can.

- Rework flow; start with vulkan fundamentals
- Move things around
- Adhere to 1 sentence, 1 line
@sharadhr
Copy link
Contributor Author

sharadhr commented Jan 16, 2026

I'm much happier about the Usage document; probably a few final updates left for the last few sections. At this point, I'd like to ask you guys, @M2-TE and @asuessenbach to review what has been done; I have a lot of TODOs that you might want to search for and comment on. I suggest reading the document in a proper, top-down manner to ensure it flows correctly. I'd also love to note any missing features that have been recently added.


After that, I intend to work on migrating the RAII guide to Handles.md, and finally revise the building and installation sections.

Copy link
Contributor

@M2-TE M2-TE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really great PR, fantastic work!
I've added some comments/suggestions where relevant.

and finally revise the building and installation sections

woops, I also added some comments regarding those sections. If it's too early, just mark them as resolved and I'll revisit them once you have finished the section!


## Minimum requirements

The generator, samples, and tests requires a C++11 compiler. The following compilers are known to work, and tested during releases:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generator actually requires a C++20 compiler:

set_target_properties( VulkanHppGenerator PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON )


1. Install dependencies:
- Install CMake and git; ensure both are available from a shell.
- Install the LunarG Vulkan SDK.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SDK should not be needed for either the generators or the tests/samples. The headers and xml registry are fetched from the Vulkan-Headers submodule.
It might be worth noting here that, in order to build samples, you need additional deps on Ubuntu:

sudo apt-get update && sudo apt-get install lsb-release gpg software-properties-common wget


If a `clang-format` executable is found by CMake, the define `CLANG_FORMAT_EXECUTABLE` is set accordingly. In that case, the generated headers are formatted using the `.clang-format` file located in the root directory of this project; otherwise, the formatting is left as hard-coded in the generator.

Use `clang-format` version 21.1.0 to format the generated files.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line comes a bit out of nowhere after the previous paragraph; did you mean to say that you should use this version for PRs? It should probably say either that, or that it is the recommended version in general.


Vulkan-Hpp provides a `vk::SharedHandle<Type>` interface. For each Vulkan handle type `vk::Type` there is a shared handle `vk::SharedType` which will delete the underlying Vulkan resource upon destruction, e.g. `vk::SharedBuffer` is the shared handle for `vk::Buffer`.

Unlike `vk::UniqueHandle`, `vk::SharedHandle` takes shared ownership of the resource as well as its parent. This means that the parent handle will not be destroyed until all child resources are deleted. This is useful for resources that are shared between multiple threads or objects.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you were on the topic of multithreading, is it worth mentioning that shared handles are not thread safe? Handling mutexes (mutices?) is up to the user.

vk::SharingMode::eExclusive, 0, nullptr, vk::ImageLayout::eUndefined});
```

#### Designated initialisers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### Designated initialisers
#### Designated initializers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadge. I use British English...

Vulkan-Hpp provides a per-function dispatch mechanism where each function representing a Vulkan operation accepts as its last parameter a dispatch class.
This class must provide a callable type for each Vulkan function that is required.

<!-- TODO: What is this code sample exactly? -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it just a duplicate of the following section?
Instead of VULKAN_HPP_DEFAULT_DISPATCHER it uses vk::detail::DispatchLoaderDynamic directly, using dld and such, rather than defaultDispatchLoaderDynamic.

The information about vulkan-1 is still useful though, so perhaps best merged with the dynamic dispatch section below it?


- Use your own dynamic loader, which needs to provide a templated function `getProcAddress`. Refer to the implementation of `vk::detail::DynamicLoader` in `vulkan.hpp` for an example.

<!-- TODO: Add a skeleton implementation of `struct YourDynamicLoader`? -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a nice idea. Probably just a stripped down version from what we have in vulkan.hpp is sufficient.

Comment on lines +868 to +877
#if VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
#endif

auto main(int argc, char* const argv[]) -> int
{
#if ( VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 )
// initialize minimal set of function pointers
VULKAN_HPP_DEFAULT_DISPATCHER.init();
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
#endif
auto main(int argc, char* const argv[]) -> int
{
#if ( VULKAN_HPP_DISPATCH_LOADER_DYNAMIC == 1 )
// initialize minimal set of function pointers
VULKAN_HPP_DEFAULT_DISPATCHER.init();
#endif
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
auto main(int argc, char* const argv[]) -> int
{
// initialize minimal set of function pointers
VULKAN_HPP_DEFAULT_DISPATCHER.init();

Probably best to just use the dynamic dispatcher stuff directly. It's what the example is for, so no need to confuse readers with additional #ifdefs.

#endif

auto appInfo = vk::ApplicationInfo("My App", 1, "My Engine", 1, vk::makeApiVersion(1, 0, 0, 0));
// ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ...
// ...
// load function pointers with created instance
VULKAN_HPP_DEFAULT_DISPATCHER.init(instance);
// OPTIONAL: load function pointers specifically for a vk::device
VULKAN_HPP_DEFAULT_DISPATCHER.init(device);

Can't hurt to add the other two inits here as well, right?

Some functions might provide information that depends on the vulkan version.
As all functions here operate only on strings, the Vulkan versions are encoded by a string prefixed with "VK_VERSION_", followed by the major and the minor version, separated by an underscore, like this: `VK_VERSION_1_0`.

<!-- TODO: the descriptions in this table need to be reworded a bit, it's a little hard to follow. -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just use function names and parameters, then add a separate column for return values?
I'm not sure how much more readable that is exactly, but things like the constexpr macro can be stripped out (add another column with checkmarks for which funcs can be constexpr?).

@sharadhr
Copy link
Contributor Author

If it's too early, just mark them as resolved

No worries, I can collapse them and work on your suggestions for the usage doc first. Thanks for being so comprehensive :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants