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