Template Class VulkanResource

Inheritance Relationships

Derived Types

Class Documentation

template<typename Handle>
class VulkanResource

CRTP base class for all Vulkan resource wrappers.

Provides handle storage, device back-references, debug naming, and move-only semantics. Uses CRTP to avoid virtual function overhead while providing common functionality.

Template Parameters:

Handle – The Vulkan handle type (vk::Buffer, vk::Image, vk::Pipeline, etc.)

Subclassed by portal::renderer::vulkan::allocation::Allocated< vk::Buffer >, portal::renderer::vulkan::allocation::Allocated< vk::Image >

Public Functions

inline explicit VulkanResource(Handle handle, const VulkanDevice *device)

Constructs a Vulkan resource wrapper.

Parameters:
  • handle – The Vulkan handle to wrap

  • device – Pointer to the creating device

VulkanResource(const VulkanResource&) = delete
VulkanResource &operator=(const VulkanResource&) = delete
inline VulkanResource(VulkanResource &&other) noexcept
inline VulkanResource &operator=(VulkanResource &&other) noexcept
virtual ~VulkanResource() = default
inline const std::string &get_debug_name() const

Gets the debug name assigned to this resource.

inline const VulkanDevice &get_device() const

Gets the device that created this resource.

Returns:

Reference to the VulkanDevice

inline Handle &get_handle()

Gets mutable reference to the Vulkan handle.

inline const Handle &get_handle() const

Gets const reference to the Vulkan handle.

inline uint64_t get_handle_u64() const

Converts handle to uint64_t for debug APIs.

Returns:

Handle as uint64_t (handles 32-bit non-dispatchable handles on 32-bit platforms)

inline vk::ObjectType get_object_type() const

Gets the Vulkan object type from the handle.

inline bool has_device() const

Checks if device pointer is valid.

inline bool has_handle() const

Checks if handle is valid (non-null)

inline void set_handle(Handle hdl)

Sets the Vulkan handle.

Parameters:

hdl – The new handle value

inline void set_debug_name(const std::string &name)

Sets debug name and propagates to GPU debuggers.

Parameters:

name – The debug name (appears in RenderDoc, NSight, etc.)

Protected Attributes

std::string debug_name