2020-02-10 09:18:37 +00:00
|
|
|
#ifndef __QF_Vulkan_image_h
|
|
|
|
#define __QF_Vulkan_image_h
|
|
|
|
|
2020-02-17 11:29:35 +00:00
|
|
|
#include "QF/darray.h"
|
|
|
|
|
|
|
|
typedef struct qfv_imageset_s DARRAY_TYPE (VkImage) qfv_imageset_t;
|
|
|
|
typedef struct qfv_imageviewset_s DARRAY_TYPE (VkImageView) qfv_imageviewset_t;
|
2020-02-10 09:18:37 +00:00
|
|
|
|
2020-02-18 05:28:28 +00:00
|
|
|
typedef struct qfv_imageresource_s {
|
|
|
|
struct qfv_device_s *device;
|
|
|
|
VkImage image;
|
|
|
|
VkDeviceMemory object;
|
|
|
|
VkImageView view;
|
|
|
|
} qfv_imageresource_t;
|
|
|
|
|
2020-02-10 09:18:37 +00:00
|
|
|
typedef struct qfv_imagetransition_s {
|
2020-02-17 11:29:35 +00:00
|
|
|
VkImage image;
|
2020-02-10 09:18:37 +00:00
|
|
|
VkAccessFlags srcAccess;
|
|
|
|
VkAccessFlags dstAccess;
|
|
|
|
VkImageLayout oldLayout;
|
|
|
|
VkImageLayout newLayout;
|
|
|
|
uint32_t srcQueueFamily;
|
|
|
|
uint32_t dstQueueFamily;
|
|
|
|
VkImageAspectFlags aspect;
|
|
|
|
} qfv_imagetransition_t;
|
|
|
|
|
2020-02-17 11:29:35 +00:00
|
|
|
typedef struct qfv_imagetransitionset_s
|
|
|
|
DARRAY_TYPE (qfv_imagetransition_t) qfv_imagetransitionset_t;
|
|
|
|
typedef struct qfv_imagebarrierset_s
|
|
|
|
DARRAY_TYPE (VkImageMemoryBarrier) qfv_imagebarrierset_t;
|
2021-01-20 15:40:22 +00:00
|
|
|
#define QFV_AllocImageBarrierSet(num, allocator) \
|
|
|
|
DARRAY_ALLOCFIXED (qfv_imagebarrierset_t, num, allocator)
|
2020-02-10 09:18:37 +00:00
|
|
|
|
|
|
|
struct qfv_device_s;
|
2020-02-17 11:29:35 +00:00
|
|
|
VkImage QFV_CreateImage (struct qfv_device_s *device, int cubemap,
|
|
|
|
VkImageType type,
|
|
|
|
VkFormat format,
|
|
|
|
VkExtent3D size,
|
|
|
|
uint32_t num_mipmaps,
|
|
|
|
uint32_t num_layers,
|
2021-01-17 17:08:55 +00:00
|
|
|
VkSampleCountFlags samples,
|
2021-01-10 16:25:55 +00:00
|
|
|
VkImageUsageFlags usage_scenarios);
|
2020-02-17 11:29:35 +00:00
|
|
|
|
|
|
|
VkDeviceMemory QFV_AllocImageMemory (struct qfv_device_s *device,
|
|
|
|
VkImage image,
|
2020-02-10 09:18:37 +00:00
|
|
|
VkMemoryPropertyFlags properties,
|
|
|
|
VkDeviceSize size, VkDeviceSize offset);
|
|
|
|
|
2020-02-18 05:28:28 +00:00
|
|
|
int QFV_BindImageMemory (struct qfv_device_s *device, VkImage image,
|
|
|
|
VkDeviceMemory object, VkDeviceSize offset);
|
|
|
|
|
2020-02-10 09:18:37 +00:00
|
|
|
qfv_imagebarrierset_t *
|
2020-02-17 11:29:35 +00:00
|
|
|
QFV_CreateImageTransitionSet (qfv_imagetransition_t *transitions,
|
2020-02-10 09:18:37 +00:00
|
|
|
int numTransitions);
|
|
|
|
|
2020-02-17 11:29:35 +00:00
|
|
|
VkImageView QFV_CreateImageView (struct qfv_device_s *device,
|
|
|
|
VkImage image, VkImageViewType type,
|
|
|
|
VkFormat format, VkImageAspectFlags aspect);
|
2020-02-11 00:37:04 +00:00
|
|
|
|
2021-02-01 03:16:05 +00:00
|
|
|
/** Generate all mipmaps for a given texture down to a 1x1 pixel.
|
|
|
|
*
|
|
|
|
* Uses the GPU blit command from one mip level to the next, thus the base mip
|
|
|
|
* level data must have already been transfered to the image and the image is
|
|
|
|
* expected to be in VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL. This includes any
|
|
|
|
* array levels.
|
|
|
|
*
|
|
|
|
* \param device The device owning the command buffer.
|
|
|
|
* \param cmd The command buffer to which the barrier and blit commands
|
|
|
|
* will be written.
|
|
|
|
* \param image The image to be processed. All array layers of the base mip
|
|
|
|
* level must be initialized and in "transfer dst optimal"
|
|
|
|
* layout. All remaining mip levels must be in "undefined"
|
|
|
|
* oayout.
|
|
|
|
* \param mips The total number of mip levels of the processed image.
|
|
|
|
* \param width The pixel width of the base image.
|
|
|
|
* \param height The pixel height of the base image.
|
|
|
|
* \param layers The number of array layers in the mbase image.
|
|
|
|
*
|
|
|
|
* \note The processed image will be in "shader read only optimal" layout on
|
|
|
|
* completion.
|
|
|
|
*/
|
|
|
|
void QFV_GenerateMipMaps (struct qfv_device_s *device, VkCommandBuffer cmd,
|
|
|
|
VkImage image, unsigned mips,
|
|
|
|
unsigned width, unsigned height, unsigned layers);
|
|
|
|
|
2020-02-10 09:18:37 +00:00
|
|
|
#endif//__QF_Vulkan_image_h
|