Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional type conversion operators to the struct classes to make it easier to interoperate with the Vulkan C API #2087

Merged
merged 2 commits into from
Feb 24, 2025

Conversation

pdaniell-nv
Copy link
Contributor

These new operators allow the Vulkan-Hpp struct classes to be more easily used directly with the Vulkan C API.

For example, instead of this:

vk::BufferCreateInfo bufferInfo { .size{sizeof vertexData}, .usage{vk::BufferUsageFlagBits::eVertexBuffer} };
vmaCreateBuffer(allocator, &static_cast<VkBufferCreateInfo const &>(bufferInfo), &bufferAllocationInfo, &vertexBuffer, &vertexBufferAllocation, nullptr);

Apps can do this:

vk::BufferCreateInfo bufferInfo { .size{sizeof vertexData}, .usage{vk::BufferUsageFlagBits::eVertexBuffer} };
vmaCreateBuffer(allocator, bufferInfo, &bufferAllocationInfo, &vertexBuffer, &vertexBufferAllocation, nullptr);

This improves compatibility with the Vulkan C API so applications can
easily use the vulkan_structs.hpp classes with the C API seamlessly.
@asuessenbach
Copy link
Contributor

Yes, having both, pointer cast operators as well as reference cast operators (const and non-const) seems to be reasonable.

Thanks a lot for your contribution!

@asuessenbach asuessenbach merged commit 0236fba into main Feb 24, 2025
58 checks passed
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.

2 participants