Debian Codegraph @

subprojects/Vulkan-Headers-1.4.346/include/vulkan/vulkan_shared.hpp

raw symbols SCIP
1 // Copyright 2015-2026 The Khronos Group Inc.
2 //
3 // SPDX-License-Identifier: Apache-2.0 OR MIT
4 //
5
6 // This header is generated from the Khronos Vulkan XML API Registry.
7
8 #ifndef VULKAN_SHARED_HPP
9 #define VULKAN_SHARED_HPP
10
11 #if !defined( VULKAN_HPP_CXX_MODULE )
12 # include <atomic> // std::atomic_size_t
13 # include <vulkan/vulkan.hpp>
14 #endif
15
16 VULKAN_HPP_EXPORT namespace VULKAN_HPP_NAMESPACE
17 {
18 #if !defined( VULKAN_HPP_NO_SMART_HANDLE )
19 template <typename HandleType>
20 class SharedHandleTraits;
21
22 class NoDestructor
23 {
24 };
25
26 template <typename HandleType, typename = void>
27 struct HasDestructorType : std::false_type
28 {
29 };
30
31 template <typename HandleType>
32 struct HasDestructorType<HandleType, decltype( (void)typename SharedHandleTraits<HandleType>::DestructorType() )> : std::true_type
33 {
34 };
35
36 template <typename HandleType, typename Enable = void>
37 struct GetDestructorType
38 {
39 using type = NoDestructor;
40 };
41
42 template <typename HandleType>
43 struct GetDestructorType<HandleType, typename std::enable_if<HasDestructorType<HandleType>::value>::type>
44 {
45 using type = typename SharedHandleTraits<HandleType>::DestructorType;
46 };
47
48 template <class HandleType>
49 using DestructorTypeOf = typename GetDestructorType<HandleType>::type;
50
51 template <class HandleType>
52 struct HasDestructor : std::integral_constant<bool, !std::is_same<DestructorTypeOf<HandleType>, NoDestructor>::value>
53 {
54 };
55
56 template <typename HandleType, typename = void>
57 struct HasPoolType : std::false_type
58 {
59 };
60
61 template <typename HandleType>
62 struct HasPoolType<HandleType, decltype( (void)typename SharedHandleTraits<HandleType>::deleter::PoolTypeExport() )> : std::true_type
63 {
64 };
65
66 template <typename HandleType, typename Enable = void>
67 struct GetPoolType
68 {
69 using type = NoDestructor;
70 };
71
72 template <typename HandleType>
73 struct GetPoolType<HandleType, typename std::enable_if<HasPoolType<HandleType>::value>::type>
74 {
75 using type = typename SharedHandleTraits<HandleType>::deleter::PoolTypeExport;
76 };
77
78 //=====================================================================================================================
79
80 template <typename HandleType>
81 class SharedHandle;
82
83 template <typename DestructorType, typename Deleter>
84 struct SharedHeader
85 {
86 SharedHeader( SharedHandle<DestructorType> parent, Deleter deleter VULKAN_HPP_DEFAULT_ASSIGNMENT( Deleter() ) ) VULKAN_HPP_NOEXCEPT
87 : parent( std::move( parent ) )
88 , deleter( std::move( deleter ) )
89 {
90 }
91
92 SharedHandle<DestructorType> parent;
93 Deleter deleter;
94 };
95
96 template <typename Deleter>
97 struct SharedHeader<NoDestructor, Deleter>
98 {
99 SharedHeader( Deleter deleter VULKAN_HPP_DEFAULT_ASSIGNMENT( Deleter() ) ) VULKAN_HPP_NOEXCEPT : deleter( std::move( deleter ) ) {}
100
101 Deleter deleter;
102 };
103
104 //=====================================================================================================================
105
106 template <typename HeaderType>
107 class ReferenceCounter
108 {
109 public:
110 template <typename... Args>
111 ReferenceCounter( Args &&... control_args ) : m_header( std::forward<Args>( control_args )... )
112 {
113 }
114
115 ReferenceCounter( ReferenceCounter const & ) = delete;
116 ReferenceCounter & operator=( ReferenceCounter const & ) = delete;
117
118 public:
119 size_t addRef() VULKAN_HPP_NOEXCEPT
120 {
121 // Relaxed memory order is sufficient since this does not impose any ordering on other operations
122 return m_ref_cnt.fetch_add( 1, std::memory_order_relaxed );
123 }
124
125 size_t release() VULKAN_HPP_NOEXCEPT
126 {
127 // A release memory order to ensure that all releases are ordered
128 return m_ref_cnt.fetch_sub( 1, std::memory_order_release );
129 }
130
131 public:
132 std::atomic_size_t m_ref_cnt{ 1 };
133 HeaderType m_header;
134 };
135
136 //=====================================================================================================================
137
138 template <typename HandleType, typename HeaderType, typename ForwardType = SharedHandle<HandleType>>
139 class SharedHandleBase
140 {
141 public:
142 SharedHandleBase() = default;
143
144 template <typename... Args>
145 SharedHandleBase( HandleType handle, Args &&... control_args )
146 : m_control( new ReferenceCounter<HeaderType>( std::forward<Args>( control_args )... ) ), m_handle( handle )
147 {
148 }
149
150 SharedHandleBase( SharedHandleBase const & o ) VULKAN_HPP_NOEXCEPT
151 {
152 o.addRef();
153 m_handle = o.m_handle;
154 m_control = o.m_control;
155 }
156
157 SharedHandleBase( SharedHandleBase && o ) VULKAN_HPP_NOEXCEPT
158 : m_control( o.m_control )
159 , m_handle( o.m_handle )
160 {
161 o.m_handle = nullptr;
162 o.m_control = nullptr;
163 }
164
165 SharedHandleBase & operator=( SharedHandleBase const & o ) VULKAN_HPP_NOEXCEPT
166 {
167 SharedHandleBase( o ).swap( *this );
168 return *this;
169 }
170
171 SharedHandleBase & operator=( SharedHandleBase && o ) VULKAN_HPP_NOEXCEPT
172 {
173 SharedHandleBase( std::move( o ) ).swap( *this );
174 return *this;
175 }
176
177 ~SharedHandleBase()
178 {
179 // only this function owns the last reference to the control block
180 // the same principle is used in the default deleter of std::shared_ptr
181 if ( m_control && ( m_control->release() == 1 ) )
182 {
183 // noop in x86, but does thread synchronization in ARM
184 // it is required to ensure that last thread is getting to destroy the control block
185 // by ordering all atomic operations before this fence
186 std::atomic_thread_fence( std::memory_order_acquire );
187 ForwardType::internalDestroy( getHeader(), m_handle );
188 delete m_control;
189 }
190 }
191
192 public:
193 HandleType get() const VULKAN_HPP_NOEXCEPT
194 {
195 return m_handle;
196 }
197
198 HandleType operator*() const VULKAN_HPP_NOEXCEPT
199 {
200 return m_handle;
201 }
202
203 explicit operator bool() const VULKAN_HPP_NOEXCEPT
204 {
205 return bool( m_handle );
206 }
207
208 # if defined( VULKAN_HPP_SMART_HANDLE_IMPLICIT_CAST )
209 operator HandleType() const VULKAN_HPP_NOEXCEPT
210 {
211 return m_handle;
212 }
213 # endif
214
215 HandleType const * operator->() const VULKAN_HPP_NOEXCEPT
216 {
217 return &m_handle;
218 }
219
220 HandleType * operator->() VULKAN_HPP_NOEXCEPT
221 {
222 return &m_handle;
223 }
224
225 void reset() VULKAN_HPP_NOEXCEPT
226 {
227 SharedHandleBase().swap( *this );
228 }
229
230 void swap( SharedHandleBase & o ) VULKAN_HPP_NOEXCEPT
231 {
232 std::swap( m_handle, o.m_handle );
233 std::swap( m_control, o.m_control );
234 }
235
236 template <typename T = HandleType>
237 typename std::enable_if<HasDestructor<T>::value, SharedHandle<DestructorTypeOf<HandleType>> const &>::type getDestructorType() const VULKAN_HPP_NOEXCEPT
238 {
239 return getHeader().parent;
240 }
241
242 protected:
243 template <typename T = HandleType>
244 static typename std::enable_if<!HasDestructor<T>::value, void>::type internalDestroy( HeaderType const & control, HandleType handle ) VULKAN_HPP_NOEXCEPT
245 {
246 control.deleter.destroy( handle );
247 }
248
249 template <typename T = HandleType>
250 static typename std::enable_if<HasDestructor<T>::value, void>::type internalDestroy( HeaderType const & control, HandleType handle ) VULKAN_HPP_NOEXCEPT
251 {
252 control.deleter.destroy( control.parent.get(), handle );
253 }
254
255 HeaderType const & getHeader() const VULKAN_HPP_NOEXCEPT
256 {
257 return m_control->m_header;
258 }
259
260 private:
261 void addRef() const VULKAN_HPP_NOEXCEPT
262 {
263 if ( m_control )
264 m_control->addRef();
265 }
266
267 protected:
268 ReferenceCounter<HeaderType> * m_control = nullptr;
269 HandleType m_handle{};
270 };
271
272 template <typename HandleType>
273 class SharedHandle : public SharedHandleBase<HandleType, SharedHeader<DestructorTypeOf<HandleType>, typename SharedHandleTraits<HandleType>::deleter>>
274 {
275 private:
276 using BaseType = SharedHandleBase<HandleType, SharedHeader<DestructorTypeOf<HandleType>, typename SharedHandleTraits<HandleType>::deleter>>;
277 using DeleterType = typename SharedHandleTraits<HandleType>::deleter;
278 friend BaseType;
279
280 public:
281 SharedHandle() = default;
282
283 template <typename T = HandleType, typename = typename std::enable_if<HasDestructor<T>::value && !HasPoolType<T>::value>::type>
284 explicit SharedHandle( HandleType handle,
285 SharedHandle<DestructorTypeOf<HandleType>> parent,
286 DeleterType deleter VULKAN_HPP_DEFAULT_ASSIGNMENT( DeleterType() ) ) VULKAN_HPP_NOEXCEPT
287 : BaseType( handle, std::move( parent ), std::move( deleter ) )
288 {
289 }
290
291 template <typename Dispatcher = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE,
292 typename T = HandleType,
293 typename = typename std::enable_if<HasDestructor<T>::value && HasPoolType<T>::value>::type>
294 explicit SharedHandle( HandleType handle,
295 SharedHandle<DestructorTypeOf<HandleType>> parent,
296 SharedHandle<typename GetPoolType<HandleType>::type> pool,
297 Dispatcher const & dispatch VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) VULKAN_HPP_NOEXCEPT
298 : BaseType( handle, std::move( parent ), DeleterType{ std::move( pool ), dispatch } )
299 {
300 }
301
302 template <typename T = HandleType, typename = typename std::enable_if<!HasDestructor<T>::value>::type>
303 explicit SharedHandle( HandleType handle, DeleterType deleter VULKAN_HPP_DEFAULT_ASSIGNMENT( DeleterType() ) ) VULKAN_HPP_NOEXCEPT
304 : BaseType( handle, std::move( deleter ) )
305 {
306 }
307
308 protected:
309 using BaseType::internalDestroy;
310 };
311
312 namespace detail
313 {
314 // Silence the function cast warnings.
315 # if defined( __GNUC__ ) && !defined( __clang__ ) && !defined( __INTEL_COMPILER )
316 # pragma GCC diagnostic push
317 # pragma GCC diagnostic ignored "-Wcast-function-type"
318 # elif defined( __clang__ ) && ( __clang_major__ >= 13 ) && !defined( __INTEL_COMPILER )
319 # pragma clang diagnostic push
320 # pragma clang diagnostic ignored "-Wcast-function-type"
321 # endif
322
323 template <typename HandleType, typename Dispatcher = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
324 class ObjectDestroyShared
325 {
326 public:
327 using DestructorType = typename SharedHandleTraits<HandleType>::DestructorType;
328
329 using DestroyFunctionPointerType =
330 typename std::conditional<HasDestructor<HandleType>::value,
331 void ( DestructorType::* )( HandleType, AllocationCallbacks const *, Dispatcher const & ) const,
332 void ( HandleType::* )( AllocationCallbacks const *, Dispatcher const & ) const>::type;
333
334 using SelectorType = typename std::conditional<HasDestructor<HandleType>::value, DestructorType, HandleType>::type;
335
336 ObjectDestroyShared( Optional<AllocationCallbacks const> allocationCallbacks VULKAN_HPP_DEFAULT_ASSIGNMENT( nullptr ),
337 Dispatcher const & dispatch VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT )
338 : m_destroy( reinterpret_cast<decltype( m_destroy )>( static_cast<DestroyFunctionPointerType>( &SelectorType::destroy ) ) )
339 , m_dispatch( &dispatch )
340 , m_allocationCallbacks( allocationCallbacks )
341 {
342 }
343
344 public:
345 template <typename T = HandleType>
346 typename std::enable_if<HasDestructor<T>::value, void>::type destroy( DestructorType parent, HandleType handle ) const VULKAN_HPP_NOEXCEPT
347 {
348 VULKAN_HPP_ASSERT( m_destroy && m_dispatch );
349 ( parent.*m_destroy )( handle, m_allocationCallbacks, *m_dispatch );
350 }
351
352 template <typename T = HandleType>
353 typename std::enable_if<!HasDestructor<T>::value, void>::type destroy( HandleType handle ) const VULKAN_HPP_NOEXCEPT
354 {
355 VULKAN_HPP_ASSERT( m_destroy && m_dispatch );
356 ( handle.*m_destroy )( m_allocationCallbacks, *m_dispatch );
357 }
358
359 private:
360 DestroyFunctionPointerType m_destroy = nullptr;
361 Dispatcher const * m_dispatch = nullptr;
362 Optional<AllocationCallbacks const> m_allocationCallbacks = nullptr;
363 };
364
365 template <typename HandleType, typename Dispatcher = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
366 class ObjectFreeShared
367 {
368 public:
369 using DestructorType = typename SharedHandleTraits<HandleType>::DestructorType;
370
371 using DestroyFunctionPointerType = void ( DestructorType::* )( HandleType, AllocationCallbacks const *, Dispatcher const & ) const;
372
373 ObjectFreeShared( Optional<AllocationCallbacks const> allocationCallbacks VULKAN_HPP_DEFAULT_ASSIGNMENT( nullptr ),
374 Dispatcher const & dispatch VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT )
375 : m_destroy( reinterpret_cast<decltype( m_destroy )>( static_cast<DestroyFunctionPointerType>( &DestructorType::free ) ) )
376 , m_dispatch( &dispatch )
377 , m_allocationCallbacks( allocationCallbacks )
378 {
379 }
380
381 public:
382 void destroy( DestructorType parent, HandleType handle ) const VULKAN_HPP_NOEXCEPT
383 {
384 VULKAN_HPP_ASSERT( m_destroy && m_dispatch );
385 ( parent.*m_destroy )( handle, m_allocationCallbacks, *m_dispatch );
386 }
387
388 private:
389 DestroyFunctionPointerType m_destroy = nullptr;
390 Dispatcher const * m_dispatch = nullptr;
391 Optional<AllocationCallbacks const> m_allocationCallbacks = nullptr;
392 };
393
394 template <typename HandleType, typename Dispatcher = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
395 class ObjectReleaseShared
396 {
397 public:
398 using DestructorType = typename SharedHandleTraits<HandleType>::DestructorType;
399
400 using DestroyFunctionPointerType = void ( DestructorType::* )( HandleType, Dispatcher const & ) const;
401
402 ObjectReleaseShared( Dispatcher const & dispatch VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT )
403 : m_destroy( reinterpret_cast<decltype( m_destroy )>( static_cast<DestroyFunctionPointerType>( &DestructorType::release ) ) ), m_dispatch( &dispatch )
404 {
405 }
406
407 public:
408 void destroy( DestructorType parent, HandleType handle ) const VULKAN_HPP_NOEXCEPT
409 {
410 VULKAN_HPP_ASSERT( m_destroy && m_dispatch );
411 ( parent.*m_destroy )( handle, *m_dispatch );
412 }
413
414 private:
415 DestroyFunctionPointerType m_destroy = nullptr;
416 Dispatcher const * m_dispatch = nullptr;
417 };
418
419 template <typename HandleType, typename PoolType, typename Dispatcher = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
420 class PoolFreeShared
421 {
422 public:
423 using DestructorType = typename SharedHandleTraits<HandleType>::DestructorType;
424
425 using PoolTypeExport = PoolType;
426
427 using ReturnType = decltype( std::declval<DestructorType>().free( PoolType(), 0u, nullptr, Dispatcher() ) );
428
429 using DestroyFunctionPointerType = ReturnType ( DestructorType::* )( PoolType, uint32_t, HandleType const *, Dispatcher const & ) const;
430
431 PoolFreeShared() = default;
432
433 PoolFreeShared( SharedHandle<PoolType> pool, Dispatcher const & dispatch VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT )
434 : m_destroy( reinterpret_cast<decltype( m_destroy )>( static_cast<DestroyFunctionPointerType>( &DestructorType::free ) ) )
435 , m_dispatch( &dispatch )
436 , m_pool( std::move( pool ) )
437 {
438 }
439
440 public:
441 void destroy( DestructorType parent, HandleType handle ) const VULKAN_HPP_NOEXCEPT
442 {
443 VULKAN_HPP_ASSERT( m_destroy && m_dispatch && m_pool );
444 ( parent.*m_destroy )( m_pool.get(), 1u, &handle, *m_dispatch );
445 }
446
447 private:
448 DestroyFunctionPointerType m_destroy = nullptr;
449 Dispatcher const * m_dispatch = nullptr;
450 SharedHandle<PoolType> m_pool{};
451 };
452
453 # if defined( __GNUC__ ) && !defined( __clang__ ) && !defined( __INTEL_COMPILER )
454 # pragma GCC diagnostic pop
455 # elif defined( __clang__ ) && ( __clang_major__ >= 13 ) && !defined( __INTEL_COMPILER )
456 # pragma clang diagnostic pop
457 # endif
458 } // namespace detail
459
460 //======================
461 //=== SHARED HANDLEs ===
462 //======================
463
464 //=== VK_VERSION_1_0 ===
465 template <>
466 class SharedHandleTraits<Instance>
467 {
468 public:
469 using DestructorType = NoDestructor;
470 using deleter = detail::ObjectDestroyShared<Instance>;
471 };
472
473 using SharedInstance = SharedHandle<Instance>;
474
475 template <>
476 class SharedHandleTraits<Device>
477 {
478 public:
479 using DestructorType = NoDestructor;
480 using deleter = detail::ObjectDestroyShared<Device>;
481 };
482
483 using SharedDevice = SharedHandle<Device>;
484
485 template <>
486 class SharedHandleTraits<DeviceMemory>
487 {
488 public:
489 using DestructorType = Device;
490 using deleter = detail::ObjectFreeShared<DeviceMemory>;
491 };
492
493 using SharedDeviceMemory = SharedHandle<DeviceMemory>;
494
495 template <>
496 class SharedHandleTraits<Fence>
497 {
498 public:
499 using DestructorType = Device;
500 using deleter = detail::ObjectDestroyShared<Fence>;
501 };
502
503 using SharedFence = SharedHandle<Fence>;
504
505 template <>
506 class SharedHandleTraits<Semaphore>
507 {
508 public:
509 using DestructorType = Device;
510 using deleter = detail::ObjectDestroyShared<Semaphore>;
511 };
512
513 using SharedSemaphore = SharedHandle<Semaphore>;
514
515 template <>
516 class SharedHandleTraits<QueryPool>
517 {
518 public:
519 using DestructorType = Device;
520 using deleter = detail::ObjectDestroyShared<QueryPool>;
521 };
522
523 using SharedQueryPool = SharedHandle<QueryPool>;
524
525 template <>
526 class SharedHandleTraits<Buffer>
527 {
528 public:
529 using DestructorType = Device;
530 using deleter = detail::ObjectDestroyShared<Buffer>;
531 };
532
533 using SharedBuffer = SharedHandle<Buffer>;
534
535 template <>
536 class SharedHandleTraits<Image>
537 {
538 public:
539 using DestructorType = Device;
540 using deleter = detail::ObjectDestroyShared<Image>;
541 };
542
543 using SharedImage = SharedHandle<Image>;
544
545 template <>
546 class SharedHandleTraits<ImageView>
547 {
548 public:
549 using DestructorType = Device;
550 using deleter = detail::ObjectDestroyShared<ImageView>;
551 };
552
553 using SharedImageView = SharedHandle<ImageView>;
554
555 template <>
556 class SharedHandleTraits<CommandPool>
557 {
558 public:
559 using DestructorType = Device;
560 using deleter = detail::ObjectDestroyShared<CommandPool>;
561 };
562
563 using SharedCommandPool = SharedHandle<CommandPool>;
564
565 template <>
566 class SharedHandleTraits<CommandBuffer>
567 {
568 public:
569 using DestructorType = Device;
570 using deleter = detail::PoolFreeShared<CommandBuffer, CommandPool>;
571 };
572
573 using SharedCommandBuffer = SharedHandle<CommandBuffer>;
574
575 template <>
576 class SharedHandleTraits<Event>
577 {
578 public:
579 using DestructorType = Device;
580 using deleter = detail::ObjectDestroyShared<Event>;
581 };
582
583 using SharedEvent = SharedHandle<Event>;
584
585 template <>
586 class SharedHandleTraits<BufferView>
587 {
588 public:
589 using DestructorType = Device;
590 using deleter = detail::ObjectDestroyShared<BufferView>;
591 };
592
593 using SharedBufferView = SharedHandle<BufferView>;
594
595 template <>
596 class SharedHandleTraits<ShaderModule>
597 {
598 public:
599 using DestructorType = Device;
600 using deleter = detail::ObjectDestroyShared<ShaderModule>;
601 };
602
603 using SharedShaderModule = SharedHandle<ShaderModule>;
604
605 template <>
606 class SharedHandleTraits<PipelineCache>
607 {
608 public:
609 using DestructorType = Device;
610 using deleter = detail::ObjectDestroyShared<PipelineCache>;
611 };
612
613 using SharedPipelineCache = SharedHandle<PipelineCache>;
614
615 template <>
616 class SharedHandleTraits<Pipeline>
617 {
618 public:
619 using DestructorType = Device;
620 using deleter = detail::ObjectDestroyShared<Pipeline>;
621 };
622
623 using SharedPipeline = SharedHandle<Pipeline>;
624
625 template <>
626 class SharedHandleTraits<PipelineLayout>
627 {
628 public:
629 using DestructorType = Device;
630 using deleter = detail::ObjectDestroyShared<PipelineLayout>;
631 };
632
633 using SharedPipelineLayout = SharedHandle<PipelineLayout>;
634
635 template <>
636 class SharedHandleTraits<Sampler>
637 {
638 public:
639 using DestructorType = Device;
640 using deleter = detail::ObjectDestroyShared<Sampler>;
641 };
642
643 using SharedSampler = SharedHandle<Sampler>;
644
645 template <>
646 class SharedHandleTraits<DescriptorPool>
647 {
648 public:
649 using DestructorType = Device;
650 using deleter = detail::ObjectDestroyShared<DescriptorPool>;
651 };
652
653 using SharedDescriptorPool = SharedHandle<DescriptorPool>;
654
655 template <>
656 class SharedHandleTraits<DescriptorSet>
657 {
658 public:
659 using DestructorType = Device;
660 using deleter = detail::PoolFreeShared<DescriptorSet, DescriptorPool>;
661 };
662
663 using SharedDescriptorSet = SharedHandle<DescriptorSet>;
664
665 template <>
666 class SharedHandleTraits<DescriptorSetLayout>
667 {
668 public:
669 using DestructorType = Device;
670 using deleter = detail::ObjectDestroyShared<DescriptorSetLayout>;
671 };
672
673 using SharedDescriptorSetLayout = SharedHandle<DescriptorSetLayout>;
674
675 template <>
676 class SharedHandleTraits<Framebuffer>
677 {
678 public:
679 using DestructorType = Device;
680 using deleter = detail::ObjectDestroyShared<Framebuffer>;
681 };
682
683 using SharedFramebuffer = SharedHandle<Framebuffer>;
684
685 template <>
686 class SharedHandleTraits<RenderPass>
687 {
688 public:
689 using DestructorType = Device;
690 using deleter = detail::ObjectDestroyShared<RenderPass>;
691 };
692
693 using SharedRenderPass = SharedHandle<RenderPass>;
694
695 //=== VK_VERSION_1_1 ===
696 template <>
697 class SharedHandleTraits<DescriptorUpdateTemplate>
698 {
699 public:
700 using DestructorType = Device;
701 using deleter = detail::ObjectDestroyShared<DescriptorUpdateTemplate>;
702 };
703
704 using SharedDescriptorUpdateTemplate = SharedHandle<DescriptorUpdateTemplate>;
705 using SharedDescriptorUpdateTemplateKHR = SharedHandle<DescriptorUpdateTemplate>;
706
707 template <>
708 class SharedHandleTraits<SamplerYcbcrConversion>
709 {
710 public:
711 using DestructorType = Device;
712 using deleter = detail::ObjectDestroyShared<SamplerYcbcrConversion>;
713 };
714
715 using SharedSamplerYcbcrConversion = SharedHandle<SamplerYcbcrConversion>;
716 using SharedSamplerYcbcrConversionKHR = SharedHandle<SamplerYcbcrConversion>;
717
718 //=== VK_VERSION_1_3 ===
719 template <>
720 class SharedHandleTraits<PrivateDataSlot>
721 {
722 public:
723 using DestructorType = Device;
724 using deleter = detail::ObjectDestroyShared<PrivateDataSlot>;
725 };
726
727 using SharedPrivateDataSlot = SharedHandle<PrivateDataSlot>;
728 using SharedPrivateDataSlotEXT = SharedHandle<PrivateDataSlot>;
729
730 //=== VK_KHR_surface ===
731 template <>
732 class SharedHandleTraits<SurfaceKHR>
733 {
734 public:
735 using DestructorType = Instance;
736 using deleter = detail::ObjectDestroyShared<SurfaceKHR>;
737 };
738
739 using SharedSurfaceKHR = SharedHandle<SurfaceKHR>;
740
741 //=== VK_KHR_swapchain ===
742 template <>
743 class SharedHandleTraits<SwapchainKHR>
744 {
745 public:
746 using DestructorType = Device;
747 using deleter = detail::ObjectDestroyShared<SwapchainKHR>;
748 };
749
750 using SharedSwapchainKHR = SharedHandle<SwapchainKHR>;
751
752 //=== VK_KHR_display ===
753 template <>
754 class SharedHandleTraits<DisplayKHR>
755 {
756 public:
757 using DestructorType = PhysicalDevice;
758 using deleter = detail::ObjectDestroyShared<DisplayKHR>;
759 };
760
761 using SharedDisplayKHR = SharedHandle<DisplayKHR>;
762
763 //=== VK_EXT_debug_report ===
764 template <>
765 class SharedHandleTraits<DebugReportCallbackEXT>
766 {
767 public:
768 using DestructorType = Instance;
769 using deleter = detail::ObjectDestroyShared<DebugReportCallbackEXT>;
770 };
771
772 using SharedDebugReportCallbackEXT = SharedHandle<DebugReportCallbackEXT>;
773
774 //=== VK_KHR_video_queue ===
775 template <>
776 class SharedHandleTraits<VideoSessionKHR>
777 {
778 public:
779 using DestructorType = Device;
780 using deleter = detail::ObjectDestroyShared<VideoSessionKHR>;
781 };
782
783 using SharedVideoSessionKHR = SharedHandle<VideoSessionKHR>;
784
785 template <>
786 class SharedHandleTraits<VideoSessionParametersKHR>
787 {
788 public:
789 using DestructorType = Device;
790 using deleter = detail::ObjectDestroyShared<VideoSessionParametersKHR>;
791 };
792
793 using SharedVideoSessionParametersKHR = SharedHandle<VideoSessionParametersKHR>;
794
795 //=== VK_NVX_binary_import ===
796 template <>
797 class SharedHandleTraits<CuModuleNVX>
798 {
799 public:
800 using DestructorType = Device;
801 using deleter = detail::ObjectDestroyShared<CuModuleNVX>;
802 };
803
804 using SharedCuModuleNVX = SharedHandle<CuModuleNVX>;
805
806 template <>
807 class SharedHandleTraits<CuFunctionNVX>
808 {
809 public:
810 using DestructorType = Device;
811 using deleter = detail::ObjectDestroyShared<CuFunctionNVX>;
812 };
813
814 using SharedCuFunctionNVX = SharedHandle<CuFunctionNVX>;
815
816 //=== VK_EXT_debug_utils ===
817 template <>
818 class SharedHandleTraits<DebugUtilsMessengerEXT>
819 {
820 public:
821 using DestructorType = Instance;
822 using deleter = detail::ObjectDestroyShared<DebugUtilsMessengerEXT>;
823 };
824
825 using SharedDebugUtilsMessengerEXT = SharedHandle<DebugUtilsMessengerEXT>;
826
827 //=== VK_EXT_descriptor_heap ===
828 template <>
829 class SharedHandleTraits<TensorARM>
830 {
831 public:
832 using DestructorType = Device;
833 using deleter = detail::ObjectDestroyShared<TensorARM>;
834 };
835
836 using SharedTensorARM = SharedHandle<TensorARM>;
837
838 //=== VK_KHR_acceleration_structure ===
839 template <>
840 class SharedHandleTraits<AccelerationStructureKHR>
841 {
842 public:
843 using DestructorType = Device;
844 using deleter = detail::ObjectDestroyShared<AccelerationStructureKHR>;
845 };
846
847 using SharedAccelerationStructureKHR = SharedHandle<AccelerationStructureKHR>;
848
849 //=== VK_EXT_validation_cache ===
850 template <>
851 class SharedHandleTraits<ValidationCacheEXT>
852 {
853 public:
854 using DestructorType = Device;
855 using deleter = detail::ObjectDestroyShared<ValidationCacheEXT>;
856 };
857
858 using SharedValidationCacheEXT = SharedHandle<ValidationCacheEXT>;
859
860 //=== VK_NV_ray_tracing ===
861 template <>
862 class SharedHandleTraits<AccelerationStructureNV>
863 {
864 public:
865 using DestructorType = Device;
866 using deleter = detail::ObjectDestroyShared<AccelerationStructureNV>;
867 };
868
869 using SharedAccelerationStructureNV = SharedHandle<AccelerationStructureNV>;
870
871 //=== VK_INTEL_performance_query ===
872 template <>
873 class SharedHandleTraits<PerformanceConfigurationINTEL>
874 {
875 public:
876 using DestructorType = Device;
877 using deleter = detail::ObjectDestroyShared<PerformanceConfigurationINTEL>;
878 };
879
880 using SharedPerformanceConfigurationINTEL = SharedHandle<PerformanceConfigurationINTEL>;
881
882 //=== VK_KHR_deferred_host_operations ===
883 template <>
884 class SharedHandleTraits<DeferredOperationKHR>
885 {
886 public:
887 using DestructorType = Device;
888 using deleter = detail::ObjectDestroyShared<DeferredOperationKHR>;
889 };
890
891 using SharedDeferredOperationKHR = SharedHandle<DeferredOperationKHR>;
892
893 //=== VK_NV_device_generated_commands ===
894 template <>
895 class SharedHandleTraits<IndirectCommandsLayoutNV>
896 {
897 public:
898 using DestructorType = Device;
899 using deleter = detail::ObjectDestroyShared<IndirectCommandsLayoutNV>;
900 };
901
902 using SharedIndirectCommandsLayoutNV = SharedHandle<IndirectCommandsLayoutNV>;
903
904 # if defined( VK_ENABLE_BETA_EXTENSIONS )
905 //=== VK_NV_cuda_kernel_launch ===
906 template <>
907 class SharedHandleTraits<CudaModuleNV>
908 {
909 public:
910 using DestructorType = Device;
911 using deleter = detail::ObjectDestroyShared<CudaModuleNV>;
912 };
913
914 using SharedCudaModuleNV = SharedHandle<CudaModuleNV>;
915
916 template <>
917 class SharedHandleTraits<CudaFunctionNV>
918 {
919 public:
920 using DestructorType = Device;
921 using deleter = detail::ObjectDestroyShared<CudaFunctionNV>;
922 };
923
924 using SharedCudaFunctionNV = SharedHandle<CudaFunctionNV>;
925 # endif /*VK_ENABLE_BETA_EXTENSIONS*/
926
927 # if defined( VK_USE_PLATFORM_FUCHSIA )
928 //=== VK_FUCHSIA_buffer_collection ===
929 template <>
930 class SharedHandleTraits<BufferCollectionFUCHSIA>
931 {
932 public:
933 using DestructorType = Device;
934 using deleter = detail::ObjectDestroyShared<BufferCollectionFUCHSIA>;
935 };
936
937 using SharedBufferCollectionFUCHSIA = SharedHandle<BufferCollectionFUCHSIA>;
938 # endif /*VK_USE_PLATFORM_FUCHSIA*/
939
940 //=== VK_EXT_opacity_micromap ===
941 template <>
942 class SharedHandleTraits<MicromapEXT>
943 {
944 public:
945 using DestructorType = Device;
946 using deleter = detail::ObjectDestroyShared<MicromapEXT>;
947 };
948
949 using SharedMicromapEXT = SharedHandle<MicromapEXT>;
950
951 //=== VK_ARM_tensors ===
952 template <>
953 class SharedHandleTraits<TensorViewARM>
954 {
955 public:
956 using DestructorType = Device;
957 using deleter = detail::ObjectDestroyShared<TensorViewARM>;
958 };
959
960 using SharedTensorViewARM = SharedHandle<TensorViewARM>;
961
962 //=== VK_NV_optical_flow ===
963 template <>
964 class SharedHandleTraits<OpticalFlowSessionNV>
965 {
966 public:
967 using DestructorType = Device;
968 using deleter = detail::ObjectDestroyShared<OpticalFlowSessionNV>;
969 };
970
971 using SharedOpticalFlowSessionNV = SharedHandle<OpticalFlowSessionNV>;
972
973 //=== VK_EXT_shader_object ===
974 template <>
975 class SharedHandleTraits<ShaderEXT>
976 {
977 public:
978 using DestructorType = Device;
979 using deleter = detail::ObjectDestroyShared<ShaderEXT>;
980 };
981
982 using SharedShaderEXT = SharedHandle<ShaderEXT>;
983
984 //=== VK_KHR_pipeline_binary ===
985 template <>
986 class SharedHandleTraits<PipelineBinaryKHR>
987 {
988 public:
989 using DestructorType = Device;
990 using deleter = detail::ObjectDestroyShared<PipelineBinaryKHR>;
991 };
992
993 using SharedPipelineBinaryKHR = SharedHandle<PipelineBinaryKHR>;
994
995 //=== VK_ARM_data_graph ===
996 template <>
997 class SharedHandleTraits<DataGraphPipelineSessionARM>
998 {
999 public:
1000 using DestructorType = Device;
1001 using deleter = detail::ObjectDestroyShared<DataGraphPipelineSessionARM>;
1002 };
1003
1004 using SharedDataGraphPipelineSessionARM = SharedHandle<DataGraphPipelineSessionARM>;
1005
1006 //=== VK_NV_external_compute_queue ===
1007 template <>
1008 class SharedHandleTraits<ExternalComputeQueueNV>
1009 {
1010 public:
1011 using DestructorType = Device;
1012 using deleter = detail::ObjectDestroyShared<ExternalComputeQueueNV>;
1013 };
1014
1015 using SharedExternalComputeQueueNV = SharedHandle<ExternalComputeQueueNV>;
1016
1017 //=== VK_EXT_device_generated_commands ===
1018 template <>
1019 class SharedHandleTraits<IndirectCommandsLayoutEXT>
1020 {
1021 public:
1022 using DestructorType = Device;
1023 using deleter = detail::ObjectDestroyShared<IndirectCommandsLayoutEXT>;
1024 };
1025
1026 using SharedIndirectCommandsLayoutEXT = SharedHandle<IndirectCommandsLayoutEXT>;
1027
1028 template <>
1029 class SharedHandleTraits<IndirectExecutionSetEXT>
1030 {
1031 public:
1032 using DestructorType = Device;
1033 using deleter = detail::ObjectDestroyShared<IndirectExecutionSetEXT>;
1034 };
1035
1036 using SharedIndirectExecutionSetEXT = SharedHandle<IndirectExecutionSetEXT>;
1037
1038 //=== VK_ARM_shader_instrumentation ===
1039 template <>
1040 class SharedHandleTraits<ShaderInstrumentationARM>
1041 {
1042 public:
1043 using DestructorType = Device;
1044 using deleter = detail::ObjectDestroyShared<ShaderInstrumentationARM>;
1045 };
1046
1047 using SharedShaderInstrumentationARM = SharedHandle<ShaderInstrumentationARM>;
1048
1049 // a number of SharedHandle specializations
1050 enum class SwapchainOwns
1051 {
1052 no,
1053 yes,
1054 };
1055
1056 struct ImageHeader : SharedHeader<DestructorTypeOf<Image>, typename SharedHandleTraits<Image>::deleter>
1057 {
1058 ImageHeader( SharedHandle<DestructorTypeOf<Image>> parent,
1059 typename SharedHandleTraits<Image>::deleter deleter VULKAN_HPP_DEFAULT_ASSIGNMENT( typename SharedHandleTraits<Image>::deleter() ),
1060 SwapchainOwns swapchainOwned = SwapchainOwns::no ) VULKAN_HPP_NOEXCEPT
1061 : SharedHeader<DestructorTypeOf<Image>, typename SharedHandleTraits<Image>::deleter>( std::move( parent ), std::move( deleter ) )
1062 , swapchainOwned( swapchainOwned )
1063 {
1064 }
1065
1066 SwapchainOwns swapchainOwned = SwapchainOwns::no;
1067 };
1068
1069 template <>
1070 class SharedHandle<Image> : public SharedHandleBase<Image, ImageHeader>
1071 {
1072 using BaseType = SharedHandleBase<Image, ImageHeader>;
1073 using DeleterType = typename SharedHandleTraits<Image>::deleter;
1074 friend BaseType;
1075
1076 public:
1077 SharedHandle() = default;
1078
1079 explicit SharedHandle( Image handle,
1080 SharedHandle<DestructorTypeOf<Image>> parent,
1081 SwapchainOwns swapchain_owned VULKAN_HPP_DEFAULT_ASSIGNMENT( SwapchainOwns::no ),
1082 DeleterType deleter VULKAN_HPP_DEFAULT_ASSIGNMENT( DeleterType() ) ) VULKAN_HPP_NOEXCEPT
1083 : BaseType( handle, std::move( parent ), std::move( deleter ), swapchain_owned )
1084 {
1085 }
1086
1087 protected:
1088 static void internalDestroy( ImageHeader const & control, Image handle ) VULKAN_HPP_NOEXCEPT
1089 {
1090 if ( control.swapchainOwned == SwapchainOwns::no )
1091 {
1092 control.deleter.destroy( control.parent.get(), handle );
1093 }
1094 }
1095 };
1096
1097 struct SwapchainHeader
1098 {
1099 SwapchainHeader( SharedHandle<SurfaceKHR> surface,
1100 SharedHandle<DestructorTypeOf<SwapchainKHR>> parent,
1101 typename SharedHandleTraits<SwapchainKHR>::deleter deleter
1102 VULKAN_HPP_DEFAULT_ASSIGNMENT( typename SharedHandleTraits<SwapchainKHR>::deleter() ) ) VULKAN_HPP_NOEXCEPT
1103 : surface( std::move( surface ) )
1104 , parent( std::move( parent ) )
1105 , deleter( std::move( deleter ) )
1106 {
1107 }
1108
1109 SharedHandle<SurfaceKHR> surface;
1110 SharedHandle<DestructorTypeOf<SwapchainKHR>> parent;
1111 typename SharedHandleTraits<SwapchainKHR>::deleter deleter;
1112 };
1113
1114 template <>
1115 class SharedHandle<SwapchainKHR> : public SharedHandleBase<SwapchainKHR, SwapchainHeader>
1116 {
1117 using BaseType = SharedHandleBase<SwapchainKHR, SwapchainHeader>;
1118 using DeleterType = typename SharedHandleTraits<SwapchainKHR>::deleter;
1119 friend BaseType;
1120
1121 public:
1122 SharedHandle() = default;
1123
1124 explicit SharedHandle( SwapchainKHR handle,
1125 SharedHandle<DestructorTypeOf<SwapchainKHR>> parent,
1126 SharedHandle<SurfaceKHR> surface,
1127 DeleterType deleter VULKAN_HPP_DEFAULT_ASSIGNMENT( DeleterType() ) ) VULKAN_HPP_NOEXCEPT
1128 : BaseType( handle, std::move( surface ), std::move( parent ), std::move( deleter ) )
1129 {
1130 }
1131
1132 public:
1133 SharedHandle<SurfaceKHR> const & getSurface() const VULKAN_HPP_NOEXCEPT
1134 {
1135 return getHeader().surface;
1136 }
1137
1138 protected:
1139 using BaseType::internalDestroy;
1140 };
1141
1142 template <typename HandleType, typename DestructorType>
1143 class SharedHandleBaseNoDestroy : public SharedHandleBase<HandleType, DestructorType>
1144 {
1145 public:
1146 using SharedHandleBase<HandleType, DestructorType>::SharedHandleBase;
1147
1148 DestructorType const & getDestructorType() const VULKAN_HPP_NOEXCEPT
1149 {
1150 return SharedHandleBase<HandleType, DestructorType>::getHeader();
1151 }
1152
1153 protected:
1154 static void internalDestroy( DestructorType const &, HandleType ) VULKAN_HPP_NOEXCEPT {}
1155 };
1156
1157 //=== VK_VERSION_1_0 ===
1158
1159 template <>
1160 class SharedHandle<PhysicalDevice> : public SharedHandleBaseNoDestroy<PhysicalDevice, SharedInstance>
1161 {
1162 friend SharedHandleBase<PhysicalDevice, SharedInstance>;
1163
1164 public:
1165 SharedHandle() = default;
1166
1167 explicit SharedHandle( PhysicalDevice handle, SharedInstance parent ) noexcept
1168 : SharedHandleBaseNoDestroy<PhysicalDevice, SharedInstance>( handle, std::move( parent ) )
1169 {
1170 }
1171 };
1172
1173 using SharedPhysicalDevice = SharedHandle<PhysicalDevice>;
1174
1175 template <>
1176 class SharedHandle<Queue> : public SharedHandleBaseNoDestroy<Queue, SharedDevice>
1177 {
1178 friend SharedHandleBase<Queue, SharedDevice>;
1179
1180 public:
1181 SharedHandle() = default;
1182
1183 explicit SharedHandle( Queue handle, SharedDevice parent ) noexcept : SharedHandleBaseNoDestroy<Queue, SharedDevice>( handle, std::move( parent ) ) {}
1184 };
1185
1186 using SharedQueue = SharedHandle<Queue>;
1187
1188 //=== VK_KHR_display ===
1189
1190 template <>
1191 class SharedHandle<DisplayModeKHR> : public SharedHandleBaseNoDestroy<DisplayModeKHR, SharedDisplayKHR>
1192 {
1193 friend SharedHandleBase<DisplayModeKHR, SharedDisplayKHR>;
1194
1195 public:
1196 SharedHandle() = default;
1197
1198 explicit SharedHandle( DisplayModeKHR handle, SharedDisplayKHR parent ) noexcept
1199 : SharedHandleBaseNoDestroy<DisplayModeKHR, SharedDisplayKHR>( handle, std::move( parent ) )
1200 {
1201 }
1202 };
1203
1204 using SharedDisplayModeKHR = SharedHandle<DisplayModeKHR>;
1205 #endif // !VULKAN_HPP_NO_SMART_HANDLE
1206 } // namespace VULKAN_HPP_NAMESPACE
1207 #endif // VULKAN_SHARED_HPP