HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_VKImage Class Reference

#include <RV_VKImage.h>

Classes

struct  Region
 

Public Member Functions

const RV_VKImageCreateInfogetInfo () const
 The image properties. More...
 
VkImage getVkImage ()
 
RV_VKMemorygetMemory ()
 
RV_VKSamplergetSampler ()
 
VkImageLayout getLayout () const
 
const RV_ResourceIDgetID () const
 
const UT_StringHoldergetName () const
 
VE_Result< SYS_HandlegetExternalHandle ()
 
RV_VKImageViewgetFullView ()
 
RV_VKImageViewgetPrimaryView ()
 
RV_VKImageView createView ()
 Create new VkImageView for whole VkImage range. More...
 
RV_VKImageView createView (const VkImageSubresourceRange &subres)
 Create new VkImageView for specific VkImage subresource range. More...
 
RV_VKImageView createView (const VkImageSubresourceRange &subres, VkImageViewType type)
 Create new VkImageView for specific VkImage subresource range, with type. More...
 
RV_VKImageView createView (VkImageViewType type)
 Create new VkImageView for specific type, trying to use full subresource range. More...
 
void transitionImage (RV_VKCommandBuffer *cb, VkImageLayout new_layout, VkImageUsageFlags new_usage, bool keep_data=true, VkImageSubresourceRange subres=VkImageSubresourceRange{})
 Record a command to transition image into new layout. More...
 
void transitionToSampling (RV_VKCommandBuffer *cb, bool force=false)
 Record a command to transition the image for sampling in a shader. More...
 
bool fillData (RV_Render *render, float r, float g, float b, float a, int index=0)
 
bool fillData (RV_Render *render, int r, int g, int b, int a, int index=0)
 
bool fillData (RV_Render *render, uint r, uint g, uint b, uint a, int index=0)
 
template<typename T , typename std::enable_if<!std::is_pointer< T >::value, int >::type = 0>
bool uploadData (RV_Render *r, const T &data, int level=0, int index=0)
 Upload data to the image. Must be in a state for upload. More...
 
template<typename T , typename std::enable_if<!std::is_pointer< T >::value, int >::type = 0>
bool uploadSubData (RV_Render *r, const T &data, const Region &region, int level=0, int index=0)
 
bool uploadData (RV_Render *r, const void *data, exint data_size, int level=0, int index=0)
 
bool uploadData (RV_Instance *inst, RV_VKCommandBuffer *cb, const void *data, exint data_size, int level=0, int index=0)
 
bool uploadSubData (RV_Render *r, const void *data, exint data_size, const Region &region, int level=0, int index=0)
 
bool uploadSubData (RV_Instance *inst, RV_VKCommandBuffer *cb, const void *data, exint data_size, const Region &dst_region, int level=0, int index=0)
 
bool uploadData (RV_Render *r, RV_VKBuffer *src_buf, int level=0, int index=0, exint buf_offset=0, exint buf_size=-1)
 Copy image data to this image from buffer. More...
 
bool uploadData (RV_Instance *inst, RV_VKCommandBuffer *cb, RV_VKBuffer *src_buf, int level=0, int index=0, exint buf_offset=0, exint buf_size=-1)
 
bool uploadSubData (RV_Render *r, RV_VKBuffer *src_buf, const Region &dst_region, int level=0, int index=0, exint buf_offset=0, exint buf_size=-1)
 
bool uploadSubData (RV_Instance *inst, RV_VKCommandBuffer *cb, RV_VKBuffer *src_buf, const Region &dst_region, int level=0, int index=0, exint buf_offset=0, exint buf_size=-1)
 
bool copyData (RV_Render *r, RV_VKImage *src_img, int dest_layer=0)
 
bool copySubData (RV_Render *r, RV_VKImage *src_img, const Region &dst_region, int dest_layer=0)
 
bool resolveData (RV_Render *r, RV_VKImage *src_img)
 
void generateMipmaps (RV_Render *r)
 Generate higher mipmap levels from the base level. More...
 
bool downloadData (RV_Render *r, void *dst_data, exint data_size, int level=0, int index=0, bool primary_aspect=true)
 Download image data into data. More...
 
bool downloadSubData (RV_Render *r, void *dst_data, exint data_size, const Region &dst_region, int level=0, int index=0, bool primary_aspect=true)
 Download image data into data, from a subregion of this image. More...
 
bool downloadData (RV_Render *r, RV_VKBuffer *dst_buf, int level=0, int index=0, bool primary_aspect=true)
 Download image data into buf. More...
 
bool downloadSubData (RV_Render *r, RV_VKBuffer *dst_buf, const Region &dst_region, int level=0, int index=0, bool primary_aspect=true)
 Download image data into buf, from a subregion of this image. More...
 
void writeToFile (RV_Render *r, const char *filepath)
 
void destroy (RV_Instance *)
 
virtual ~RV_VKImage ()
 
void print () const
 Debug print out of image properties (not image data). More...
 

Static Public Member Functions

static RV_VKImagePtr allocateImage (RV_Instance *inst, RV_VKImageCreateInfo *info, const char *name=nullptr)
 Creates new Image based on create info. More...
 
static RV_VKImagePtr createFromImage (RV_Instance *inst, VkImage vk_image, const VkImageCreateInfo *info, const char *name=nullptr)
 
static UT_UniquePtr< RV_VKSamplerallocateSampler (RV_Instance *inst, const RV_VKImageCreateInfo *img_info)
 
static bool queryIsUsable (RV_Instance *inst, RV_VKImageCreateInfo *info)
 

Public Attributes

UT_StringHolder myName
 
VkImageLayout myLastLayout = VK_IMAGE_LAYOUT_UNDEFINED
 
VkAccessFlags myLastAccess = 0
 
VkImageUsageFlags myLastUsage = 0
 
VkPipelineStageFlags myLastStage = 0
 
uint32_t myLastQueueFam = 0
 
RV_StageGroup myWaitingBarrierStage = RV_STAGE_NONE
 

Protected Member Functions

 RV_VKImage (RV_Instance *inst, const RV_VKImageCreateInfo *img_info, VkImage vk_img, RV_VKMemoryPtr mem, RV_VKImageViewPtr view, RV_VKImageViewPtr primary_view, RV_VKSamplerPtr sampler)
 

Static Protected Member Functions

static RV_VKImagePtr createRVImage (RV_Instance *inst, VkImage vk_img, RV_VKMemoryPtr mem, const RV_VKImageCreateInfo *info, const char *name=nullptr)
 

Protected Attributes

RV_InstancemyInst = nullptr
 
VkImage myVkImg = VK_NULL_HANDLE
 
RV_ResourceID myId
 
UT_UniquePtr< const
RV_VKImageCreateInfo
myCreateInfo
 
UT_UniquePtr< RV_VKImageViewmyView
 
UT_UniquePtr< RV_VKImageViewmyPrimaryView
 
UT_UniquePtr< RV_VKMemorymyMemory
 
UT_UniquePtr< RV_VKSamplermySampler
 

Friends

class RV_VKImageCreateInfo
 

Detailed Description

Class hodling VkImage handle and bound Memory allocation cleans up resources on destruction

Definition at line 388 of file RV_VKImage.h.

Constructor & Destructor Documentation

virtual RV_VKImage::~RV_VKImage ( )
virtual
RV_VKImage::RV_VKImage ( RV_Instance inst,
const RV_VKImageCreateInfo img_info,
VkImage  vk_img,
RV_VKMemoryPtr  mem,
RV_VKImageViewPtr  view,
RV_VKImageViewPtr  primary_view,
RV_VKSamplerPtr  sampler 
)
protected

Member Function Documentation

static RV_VKImagePtr RV_VKImage::allocateImage ( RV_Instance inst,
RV_VKImageCreateInfo info,
const char *  name = nullptr 
)
static

Creates new Image based on create info.

static UT_UniquePtr<RV_VKSampler> RV_VKImage::allocateSampler ( RV_Instance inst,
const RV_VKImageCreateInfo img_info 
)
static

Allocate a new Image Sampler using parameters from img_info, ignoring non-sampler parameters

bool RV_VKImage::copyData ( RV_Render r,
RV_VKImage src_img,
int  dest_layer = 0 
)

Copy image data from other into this image. images MUST have same size and format

bool RV_VKImage::copySubData ( RV_Render r,
RV_VKImage src_img,
const Region dst_region,
int  dest_layer = 0 
)
static RV_VKImagePtr RV_VKImage::createFromImage ( RV_Instance inst,
VkImage  vk_image,
const VkImageCreateInfo info,
const char *  name = nullptr 
)
static

Creates an image from an already existing VkImage, and takes ownership of the VkImage but not the memory object

static RV_VKImagePtr RV_VKImage::createRVImage ( RV_Instance inst,
VkImage  vk_img,
RV_VKMemoryPtr  mem,
const RV_VKImageCreateInfo info,
const char *  name = nullptr 
)
staticprotected
RV_VKImageView RV_VKImage::createView ( )

Create new VkImageView for whole VkImage range.

RV_VKImageView RV_VKImage::createView ( const VkImageSubresourceRange subres)

Create new VkImageView for specific VkImage subresource range.

RV_VKImageView RV_VKImage::createView ( const VkImageSubresourceRange subres,
VkImageViewType  type 
)

Create new VkImageView for specific VkImage subresource range, with type.

RV_VKImageView RV_VKImage::createView ( VkImageViewType  type)

Create new VkImageView for specific type, trying to use full subresource range.

void RV_VKImage::destroy ( RV_Instance )
bool RV_VKImage::downloadData ( RV_Render r,
void dst_data,
exint  data_size,
int  level = 0,
int  index = 0,
bool  primary_aspect = true 
)

Download image data into data.

bool RV_VKImage::downloadData ( RV_Render r,
RV_VKBuffer dst_buf,
int  level = 0,
int  index = 0,
bool  primary_aspect = true 
)

Download image data into buf.

bool RV_VKImage::downloadSubData ( RV_Render r,
void dst_data,
exint  data_size,
const Region dst_region,
int  level = 0,
int  index = 0,
bool  primary_aspect = true 
)

Download image data into data, from a subregion of this image.

bool RV_VKImage::downloadSubData ( RV_Render r,
RV_VKBuffer dst_buf,
const Region dst_region,
int  level = 0,
int  index = 0,
bool  primary_aspect = true 
)

Download image data into buf, from a subregion of this image.

bool RV_VKImage::fillData ( RV_Render render,
float  r,
float  g,
float  b,
float  a,
int  index = 0 
)

Sets the entire image to the specified values. This signature is for colour images. RGBA values beyond the format's tuple size are ignored. Must be in a state for upload.

bool RV_VKImage::fillData ( RV_Render render,
int  r,
int  g,
int  b,
int  a,
int  index = 0 
)

Sets the entire image to the specified values. This signature is for signed integer images. RGBA values beyond the format's tuple size are ignored. Must be in a state for upload.

bool RV_VKImage::fillData ( RV_Render render,
uint  r,
uint  g,
uint  b,
uint  a,
int  index = 0 
)

Sets the entire image to the specified values. This signature is for unsigned integer images. RGBA values beyond the format's tuple size are ignored. Must be in a state for upload.

void RV_VKImage::generateMipmaps ( RV_Render r)

Generate higher mipmap levels from the base level.

VE_Result<SYS_Handle> RV_VKImage::getExternalHandle ( )

On linux, the returned handle is owned by the caller. The caller can either use it to import the texture into another API; or they must close it when they're done with it. On windows, the returned handle can only be used to import the texture into another API–the caller must never close it themself! See documentation for VE_Memory::getExternalHandle() for more information.

RV_VKImageView& RV_VKImage::getFullView ( )
inline

Definition at line 438 of file RV_VKImage.h.

const RV_ResourceID& RV_VKImage::getID ( ) const
inline

Definition at line 426 of file RV_VKImage.h.

const RV_VKImageCreateInfo& RV_VKImage::getInfo ( ) const
inline

The image properties.

Definition at line 419 of file RV_VKImage.h.

VkImageLayout RV_VKImage::getLayout ( ) const
inline

Definition at line 425 of file RV_VKImage.h.

RV_VKMemory& RV_VKImage::getMemory ( )
inline

Definition at line 423 of file RV_VKImage.h.

const UT_StringHolder& RV_VKImage::getName ( ) const
inline

Definition at line 427 of file RV_VKImage.h.

RV_VKImageView& RV_VKImage::getPrimaryView ( )
inline

Definition at line 439 of file RV_VKImage.h.

RV_VKSampler* RV_VKImage::getSampler ( )
inline

Definition at line 424 of file RV_VKImage.h.

VkImage RV_VKImage::getVkImage ( )
inline

Definition at line 422 of file RV_VKImage.h.

void RV_VKImage::print ( ) const

Debug print out of image properties (not image data).

static bool RV_VKImage::queryIsUsable ( RV_Instance inst,
RV_VKImageCreateInfo info 
)
static

check whether the format info in pInfo can create a valid Vulkan image

bool RV_VKImage::resolveData ( RV_Render r,
RV_VKImage src_img 
)

Resolves image data from Multisample other into this image. images MUST have same size and format, and MUST be color images, and this MUST be a single-sample image

void RV_VKImage::transitionImage ( RV_VKCommandBuffer cb,
VkImageLayout  new_layout,
VkImageUsageFlags  new_usage,
bool  keep_data = true,
VkImageSubresourceRange  subres = VkImageSubresourceRange{} 
)

Record a command to transition image into new layout.

void RV_VKImage::transitionToSampling ( RV_VKCommandBuffer cb,
bool  force = false 
)
inline

Record a command to transition the image for sampling in a shader.

Definition at line 464 of file RV_VKImage.h.

template<typename T , typename std::enable_if<!std::is_pointer< T >::value, int >::type = 0>
bool RV_VKImage::uploadData ( RV_Render r,
const T data,
int  level = 0,
int  index = 0 
)
inline

Upload data to the image. Must be in a state for upload.

Definition at line 514 of file RV_VKImage.h.

bool RV_VKImage::uploadData ( RV_Render r,
const void data,
exint  data_size,
int  level = 0,
int  index = 0 
)
bool RV_VKImage::uploadData ( RV_Instance inst,
RV_VKCommandBuffer cb,
const void data,
exint  data_size,
int  level = 0,
int  index = 0 
)
bool RV_VKImage::uploadData ( RV_Render r,
RV_VKBuffer src_buf,
int  level = 0,
int  index = 0,
exint  buf_offset = 0,
exint  buf_size = -1 
)

Copy image data to this image from buffer.

bool RV_VKImage::uploadData ( RV_Instance inst,
RV_VKCommandBuffer cb,
RV_VKBuffer src_buf,
int  level = 0,
int  index = 0,
exint  buf_offset = 0,
exint  buf_size = -1 
)
template<typename T , typename std::enable_if<!std::is_pointer< T >::value, int >::type = 0>
bool RV_VKImage::uploadSubData ( RV_Render r,
const T data,
const Region region,
int  level = 0,
int  index = 0 
)
inline

Definition at line 524 of file RV_VKImage.h.

bool RV_VKImage::uploadSubData ( RV_Render r,
const void data,
exint  data_size,
const Region region,
int  level = 0,
int  index = 0 
)
bool RV_VKImage::uploadSubData ( RV_Instance inst,
RV_VKCommandBuffer cb,
const void data,
exint  data_size,
const Region dst_region,
int  level = 0,
int  index = 0 
)
bool RV_VKImage::uploadSubData ( RV_Render r,
RV_VKBuffer src_buf,
const Region dst_region,
int  level = 0,
int  index = 0,
exint  buf_offset = 0,
exint  buf_size = -1 
)
bool RV_VKImage::uploadSubData ( RV_Instance inst,
RV_VKCommandBuffer cb,
RV_VKBuffer src_buf,
const Region dst_region,
int  level = 0,
int  index = 0,
exint  buf_offset = 0,
exint  buf_size = -1 
)
void RV_VKImage::writeToFile ( RV_Render r,
const char *  filepath 
)

Friends And Related Function Documentation

friend class RV_VKImageCreateInfo
friend

Definition at line 717 of file RV_VKImage.h.

Member Data Documentation

UT_UniquePtr<const RV_VKImageCreateInfo> RV_VKImage::myCreateInfo
protected

Definition at line 694 of file RV_VKImage.h.

RV_ResourceID RV_VKImage::myId
protected

Definition at line 693 of file RV_VKImage.h.

RV_Instance* RV_VKImage::myInst = nullptr
protected

Definition at line 691 of file RV_VKImage.h.

VkAccessFlags RV_VKImage::myLastAccess = 0

Definition at line 710 of file RV_VKImage.h.

VkImageLayout RV_VKImage::myLastLayout = VK_IMAGE_LAYOUT_UNDEFINED

Definition at line 709 of file RV_VKImage.h.

uint32_t RV_VKImage::myLastQueueFam = 0

Definition at line 713 of file RV_VKImage.h.

VkPipelineStageFlags RV_VKImage::myLastStage = 0

Definition at line 712 of file RV_VKImage.h.

VkImageUsageFlags RV_VKImage::myLastUsage = 0

Definition at line 711 of file RV_VKImage.h.

UT_UniquePtr<RV_VKMemory> RV_VKImage::myMemory
protected

Definition at line 698 of file RV_VKImage.h.

UT_StringHolder RV_VKImage::myName

Definition at line 706 of file RV_VKImage.h.

UT_UniquePtr<RV_VKImageView> RV_VKImage::myPrimaryView
protected

Definition at line 697 of file RV_VKImage.h.

UT_UniquePtr<RV_VKSampler> RV_VKImage::mySampler
protected

Definition at line 699 of file RV_VKImage.h.

UT_UniquePtr<RV_VKImageView> RV_VKImage::myView
protected

Definition at line 696 of file RV_VKImage.h.

VkImage RV_VKImage::myVkImg = VK_NULL_HANDLE
protected

Definition at line 692 of file RV_VKImage.h.

RV_StageGroup RV_VKImage::myWaitingBarrierStage = RV_STAGE_NONE

Definition at line 715 of file RV_VKImage.h.


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