Comments (5)
That might be a good addition to the vk::handles... but they're already nothrow_move_constructible, as checked by a static_assertion in vulkan_static_assertions.hpp.
from vulkan-hpp.
Yes, but consider the following:
I have a Swapchain class, that contains a device and a swapchainKHR.
I want to have multiple windows, so each window require it swapchains. I will use the same device to create these swapchains.
Because of that, I will use vk::SharedDevice to store the device handle in the Swapchain class.
My swapchain class will own the swapchainKHR. Because I already have the device handle for shared ownership, I will use vk::Swapchain KHR instead of vk::UniqueSwapchainKHR, to not have an extra copy of the parent handle, as UniqueHandle does.
class Swapchain
{
public:
Swapchain() = default;
Swapchain(vk::SharedDevice device, ...);
~Swapchain() noexcept;
private:
vk::SharedDevice m_device;
vk::SwapchainKHR m_swapchain;
}
~Swapchain() noexcept
{
if (m_swapchain)
{
assert(m_device);
m_device->destroySwapchainKHR(m_swapchain);
}
}
Now consider what happens if I do Swapchain(Swapchain&&) = default;
SharedHandles provide move operators. So for that it's safe.
But because std::move(vk::SwapchainKHR) is a copy operation, it will discard the previous handle and now I have a leak and possibly a double call to m_device->destroy().
Because of that I need to implement a move constructor for the Swapchain class, which does std::swap.
Would be nice If I could just do = default instead.
from vulkan-hpp.
Or this is intended to be handled this way? Should vk::Handles be treated like regular pointers?
from vulkan-hpp.
Should vk::Handles be treated like regular pointers?
Yes, vk::Handles don't own anything. Otherwise, they would not be copyable.
If you want to manage ownership, you need to do it on your own or use something like vk::UniqueHandle, vk::SharedHandle, or vk::raii::Handle.
from vulkan-hpp.
Ok, then I misunderstood. Thanks for clarifying.
from vulkan-hpp.
Related Issues (20)
- Documentation: macOS with SIP, DYLD_LIBRARY_PATH is problematic
- Inconsistent behavior from ArrayWrapper1D's equality operator HOT 1
- Build Failure (Windows 11, VS 2022) HOT 2
- Question: VulkanHpp VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC usage with VulkanMemoryAllocator HOT 1
- Feature request: appending to a StructureChain HOT 4
- compilation error when including vulkan_enums.hpp by itself HOT 2
- Allow destructuring of ResultValue with std::tie HOT 3
- Including `vulkan.hpp` causes compilation error with Clang HOT 5
- Feature request: Specialize std::hash for most types HOT 1
- std::min clashes with macros in windows.h HOT 5
- 'vk::ObjectDestroyShared<vk::Image>': no appropriate default constructor available HOT 3
- LayerSettingEXT.setValues HOT 1
- ArrayProxy with designated initializers
- `Null non-type template argument must be cast to template parameter type` errors in vulkan_handles.hpp with SDK 1.3.283. HOT 5
- vk::PipelineLayoutCreateInfo and vk::raii::DescriptorSetLayout HOT 2
- C++20 module does not expose *Flags{KHR,EXT}
- Move semantics for non-raii handles HOT 1
- SharedCommandBuffer constructor without SharedCommandPool parameter causes assertion fail on destroy HOT 4
- [c++20 module] getDispatchLoaderStatic is not available HOT 2
- [c++20 module] functions from vk::detail:: pulled into vk:: HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vulkan-hpp.