Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
foray::core::ManagedImage Class Reference

Wraps allocation and lifetime functionality of VkImage. More...

#include <foray_managedimage.hpp>

Inheritance diagram for foray::core::ManagedImage:
foray::core::VulkanResource< VkObjectType::VK_OBJECT_TYPE_IMAGE > foray::core::ManagedResource foray::NoMoveDefaults

Classes

struct  CreateInfo
 Combines all structs used for initialization. More...
 
struct  QuickTransition
 Helper struct translated to a VkImageMemoryBarrier2 struct for one-time layout transitions. More...
 

Public Member Functions

 ManagedImage ()
 
virtual ~ManagedImage ()
 
virtual void Create (Context *context, const CreateInfo &createInfo)
 Allocates image, creates image, creates imageview.
 
virtual void Resize (const VkExtent3D &newextent)
 Uses stored create info to recreate vulkan image with a new size.
 
virtual void Resize (const VkExtent2D &newextent)
 Uses stored create info to recreate vulkan image with a new size.
 
virtual void Create (Context *context, VkImageUsageFlags usage, VkFormat format, const VkExtent2D &extent, std::string_view name="Unnamed Image")
 Shorthand using common values. See CreateInfo for information.
 
virtual void TransitionLayout (ManagedImage::QuickTransition &quickTransition, VkCommandBuffer commandBuffer=VK_NULL_HANDLE)
 Simple layout transition.
 
void WriteDeviceLocalData (const void *data, size_t size, VkImageLayout layoutAfterWrite, VkBufferImageCopy &imageCopy)
 Creates a staging buffer, writes staging buffer, transitions image layout to transfer destination optimal, copies staging buffer to device local memory, transforms layout back to layoutAfterWrite parameter.
 
void WriteDeviceLocalData (HostSyncCommandBuffer &cmdBuffer, const void *data, size_t size, VkImageLayout layoutAfterWrite, VkBufferImageCopy &imageCopy)
 
void WriteDeviceLocalData (const void *data, size_t size, VkImageLayout layoutAfterWrite)
 See other overload for description. Omits image copy region and assumes a set of default values to write a simple image (no mimap, no layers) completely.
 
void WriteDeviceLocalData (HostSyncCommandBuffer &cmdBuffer, const void *data, size_t size, VkImageLayout layoutAfterWrite)
 
virtual void Destroy () override
 Destroy the resource.
 
virtual bool Exists () const override
 Return true, if the managed resource is allocated.
 
VkExtent2D GetExtent2D () const
 
virtual void SetName (std::string_view name) override
 Set a custom name for the object.
 
VkSampleCountFlagBits GetSampleCount () const
 
- Public Member Functions inherited from foray::core::VulkanResource< VkObjectType::VK_OBJECT_TYPE_IMAGE >
 VulkanResource ()
 
 VulkanResource (std::string_view name)
 
virtual std::string_view GetTypeName () const
 Returns <OBJECT_TYPE> stringified.
 
- Public Member Functions inherited from foray::core::ManagedResource
 ManagedResource ()
 Default constructor registers the resource.
 
 ManagedResource (std::string_view name)
 Registers the resource and sets its name.
 
virtual ~ManagedResource ()
 Unregisters the resource.
 
std::string_view GetName () const
 Return a custom name for the object.
 
std::string Print () const
 Print name and type in one string.
 
- Public Member Functions inherited from foray::NoMoveDefaults
 NoMoveDefaults ()=default
 
 NoMoveDefaults (const NoMoveDefaults &other)=delete
 
 NoMoveDefaults (NoMoveDefaults &&other)=default
 
NoMoveDefaultsoperator= (const NoMoveDefaults &other)=delete
 

Protected Member Functions

void CheckImageFormatSupport (const CreateInfo &createInfo)
 
void UpdateDebugNames ()
 
- Protected Member Functions inherited from foray::core::VulkanResource< VkObjectType::VK_OBJECT_TYPE_IMAGE >
virtual void SetObjectName (core::Context *context, const void *handle, std::string_view name, bool updateResourceName=true)
 Set the object name. Sets both ManagedResource::mName aswell as vulkan debug object name.
 

Protected Attributes

ContextmContext {}
 
CreateInfo mCreateInfo
 
VkImage mImage {}
 
VkImageView mImageView {}
 
VkFormat mFormat {}
 
VmaAllocation mAllocation {}
 
VmaAllocationInfo mAllocInfo {}
 
VkDeviceSize mSize {}
 
VkExtent3D mExtent3D {}
 
- Protected Attributes inherited from foray::core::ManagedResource
std::string mName
 This objects custom name.
 

Additional Inherited Members

- Static Public Member Functions inherited from foray::core::ManagedResource
static void sPrintAllocatedResources (bool printAsWarning)
 Print a list of all registered existing resources.
 
static const std::unordered_set< ManagedResource * > * GetTotalAllocatedResources ()
 

Detailed Description

Wraps allocation and lifetime functionality of VkImage.

Constructor & Destructor Documentation

◆ ManagedImage()

foray::core::ManagedImage::ManagedImage ( )
inline

◆ ~ManagedImage()

virtual foray::core::ManagedImage::~ManagedImage ( )
inlinevirtual

Member Function Documentation

◆ CheckImageFormatSupport()

void foray::core::ManagedImage::CheckImageFormatSupport ( const CreateInfo createInfo)
protected

◆ Create() [1/2]

virtual void foray::core::ManagedImage::Create ( Context context,
const CreateInfo createInfo 
)
virtual

Allocates image, creates image, creates imageview.

Parameters
contextRequires Allocator, DispatchTable, Device

◆ Create() [2/2]

virtual void foray::core::ManagedImage::Create ( Context context,
VkImageUsageFlags  usage,
VkFormat  format,
const VkExtent2D &  extent,
std::string_view  name = "Unnamed Image" 
)
virtual

Shorthand using common values. See CreateInfo for information.

Parameters
contextRequires Allocator, DispatchTable, Device

◆ Destroy()

virtual void foray::core::ManagedImage::Destroy ( )
overridevirtual

Destroy the resource.

Remarks
This method must be callable even if the resource has not been initialized yet. This method must call any Destroy() overloads of child objects and of base classes

Implements foray::core::ManagedResource.

◆ Exists()

virtual bool foray::core::ManagedImage::Exists ( ) const
inlineoverridevirtual

Return true, if the managed resource is allocated.

Example: Vulkan object stored could be nullptr or instantiated

Implements foray::core::ManagedResource.

◆ GetExtent2D()

VkExtent2D foray::core::ManagedImage::GetExtent2D ( ) const
inline

◆ GetSampleCount()

VkSampleCountFlagBits foray::core::ManagedImage::GetSampleCount ( ) const
inline

◆ Resize() [1/2]

virtual void foray::core::ManagedImage::Resize ( const VkExtent2D &  newextent)
virtual

Uses stored create info to recreate vulkan image with a new size.

◆ Resize() [2/2]

virtual void foray::core::ManagedImage::Resize ( const VkExtent3D &  newextent)
virtual

Uses stored create info to recreate vulkan image with a new size.

◆ SetName()

virtual void foray::core::ManagedImage::SetName ( std::string_view  name)
overridevirtual

Set a custom name for the object.

Reimplemented from foray::core::ManagedResource.

◆ TransitionLayout()

virtual void foray::core::ManagedImage::TransitionLayout ( ManagedImage::QuickTransition quickTransition,
VkCommandBuffer  commandBuffer = VK_NULL_HANDLE 
)
virtual

Simple layout transition.

Parameters
commandBufferIf set, writes the transition to the commandbuffer. If not set, uses host synchronized temporary command buffer instead (slow)

◆ UpdateDebugNames()

void foray::core::ManagedImage::UpdateDebugNames ( )
protected

◆ WriteDeviceLocalData() [1/4]

void foray::core::ManagedImage::WriteDeviceLocalData ( const void *  data,
size_t  size,
VkImageLayout  layoutAfterWrite 
)

See other overload for description. Omits image copy region and assumes a set of default values to write a simple image (no mimap, no layers) completely.

◆ WriteDeviceLocalData() [2/4]

void foray::core::ManagedImage::WriteDeviceLocalData ( const void *  data,
size_t  size,
VkImageLayout  layoutAfterWrite,
VkBufferImageCopy &  imageCopy 
)

Creates a staging buffer, writes staging buffer, transitions image layout to transfer destination optimal, copies staging buffer to device local memory, transforms layout back to layoutAfterWrite parameter.

Parameters
dataThe data to write
sizeSize of the image
layoutAfterWriteThe layout that the image is transitioned to after it has been written.
imageCopySpecify how exactly the image is copied.

◆ WriteDeviceLocalData() [3/4]

void foray::core::ManagedImage::WriteDeviceLocalData ( HostSyncCommandBuffer cmdBuffer,
const void *  data,
size_t  size,
VkImageLayout  layoutAfterWrite 
)

◆ WriteDeviceLocalData() [4/4]

void foray::core::ManagedImage::WriteDeviceLocalData ( HostSyncCommandBuffer cmdBuffer,
const void *  data,
size_t  size,
VkImageLayout  layoutAfterWrite,
VkBufferImageCopy &  imageCopy 
)

Member Data Documentation

◆ mAllocation

VmaAllocation foray::core::ManagedImage::mAllocation {}
protected

◆ mAllocInfo

VmaAllocationInfo foray::core::ManagedImage::mAllocInfo {}
protected

◆ mContext

Context* foray::core::ManagedImage::mContext {}
protected

◆ mCreateInfo

CreateInfo foray::core::ManagedImage::mCreateInfo
protected

◆ mExtent3D

VkExtent3D foray::core::ManagedImage::mExtent3D {}
protected

◆ mFormat

VkFormat foray::core::ManagedImage::mFormat {}
protected

◆ mImage

VkImage foray::core::ManagedImage::mImage {}
protected

◆ mImageView

VkImageView foray::core::ManagedImage::mImageView {}
protected

◆ mSize

VkDeviceSize foray::core::ManagedImage::mSize {}
protected

The documentation for this class was generated from the following file: