2020-02-10 09:18:37 +00:00
|
|
|
#ifndef __QF_Vulkan_image_h
|
|
|
|
#define __QF_Vulkan_image_h
|
|
|
|
|
2022-05-04 04:55:56 +00:00
|
|
|
#ifndef VK_NO_PROTOTYPES
|
|
|
|
#define VK_NO_PROTOTYPES
|
|
|
|
#endif
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
|
2020-02-17 11:29:35 +00:00
|
|
|
#include "QF/darray.h"
|
2022-05-04 04:57:02 +00:00
|
|
|
#include "QF/image.h"
|
2020-02-17 11:29:35 +00:00
|
|
|
|
2021-02-14 02:35:06 +00:00
|
|
|
typedef struct qfv_imageset_s
|
|
|
|
DARRAY_TYPE (VkImage) qfv_imageset_t;
|
|
|
|
|
|
|
|
#define QFV_AllocImages(num, allocator) \
|
|
|
|
DARRAY_ALLOCFIXED (qfv_imageset_t, num, allocator)
|
|
|
|
|
|
|
|
typedef struct qfv_imageviewset_s
|
|
|
|
DARRAY_TYPE (VkImageView) qfv_imageviewset_t;
|
|
|
|
|
|
|
|
#define QFV_AllocImageViews(num, allocator) \
|
|
|
|
DARRAY_ALLOCFIXED (qfv_imageviewset_t, num, allocator)
|
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-03-24 10:20:53 +00:00
|
|
|
size_t QFV_GetImageSize (struct qfv_device_s *device, VkImage image);
|
|
|
|
|
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.
|
2021-12-13 15:45:37 +00:00
|
|
|
* \param layers The number of array layers in the base image.
|
2021-02-01 03:16:05 +00:00
|
|
|
*
|
|
|
|
* \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);
|
2021-02-01 15:04:45 +00:00
|
|
|
int QFV_MipLevels (int width, int height) __attribute__((const));
|
2021-02-01 03:16:05 +00:00
|
|
|
|
2022-05-04 04:57:02 +00:00
|
|
|
/** Convert QFFormat to VkFormat
|
|
|
|
*
|
|
|
|
* \param format The format to convert.
|
2022-05-08 05:15:20 +00:00
|
|
|
* \param srgb Select SRGB formats (non-zero) or UNORM (0).
|
2022-05-04 04:57:02 +00:00
|
|
|
* \return The corresponding VkFormat.
|
|
|
|
*
|
|
|
|
* \note For tex_palette, VK_FORMAT_R8_UINT is returned. If \a format is
|
|
|
|
* not a valid QFFormat, then VK_FORMAT_R8_SRGB is returned.
|
|
|
|
*/
|
2023-06-13 04:03:38 +00:00
|
|
|
VkFormat QFV_ImageFormat (QFFormat format, int srgb) __attribute__((const));
|
2022-05-04 04:57:02 +00:00
|
|
|
|
2020-02-10 09:18:37 +00:00
|
|
|
#endif//__QF_Vulkan_image_h
|