Create texture images on a Vulkan device. More...
Create texture images on a Vulkan device.
VkFormat ktxTexture_GetVkFormat | ( | ktxTexture * | This | ) |
Return the VkFormat enum of a ktxTexture object.
KTX_error_code ktxTexture_VkUpload | ( | ktxTexture * | texture, |
ktxVulkanDeviceInfo * | vdi, | ||
ktxVulkanTexture * | vkTexture | ||
) |
Create a Vulkan image object from a ktxTexture object.
Calls ktxTexture_VkUploadEx() with the most commonly used options: VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT and VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL.
KTX_error_code ktxTexture_VkUploadEx | ( | ktxTexture * | This, |
ktxVulkanDeviceInfo * | vdi, | ||
ktxVulkanTexture * | vkTexture, | ||
VkImageTiling | tiling, | ||
VkImageUsageFlags | usageFlags, | ||
VkImageLayout | finalLayout | ||
) |
Create a Vulkan image object from a ktxTexture object.
Creates a VkImage with VkFormat
etc. matching the KTX data and uploads the images. Also creates a VkImageView object for accessing the image. Mipmaps will be generated if the ktxTexture's
generateMipmaps
flag is set. Returns the handles of the created objects and information about the texture in the ktxVulkanTexture
pointed at by vkTexture
.
usageFlags
and thus acceptable usage of the created image may be augmented as follows:
VK_IMAGE_USAGE_TRANSFER_DST_BIT
if tiling
is VK_IMAGE_TILING_OPTIMAL
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT
if generateMipmaps
is set in the ktxTexture
.Most Vulkan implementations support VK_IMAGE_TILING_LINEAR only for a very limited number of formats and features. Generally VK_IMAGE_TILING_OPTIMAL is preferred. The latter requires a staging buffer so will use more memory during loading.
[in] | This | pointer to the ktxTexture from which to upload. |
[in] | vdi | pointer to a ktxVulkanDeviceInfo structure providing information about the Vulkan device onto which to load the texture. |
[in,out] | vkTexture | pointer to a ktxVulkanTexture structure into which the function writes information about the created VkImage. |
[in] | tiling | type of tiling to use in the destination image on the Vulkan device. |
[in] | usageFlags | a set of VkImageUsageFlags bits indicating the intended usage of the destination image. |
[in] | finalLayout | a VkImageLayout value indicating the desired final layout of the created image. |
KTX_INVALID_VALUE | This , vdi or vkTexture is NULL . |
KTX_INVALID_OPERATION | The ktxTexture contains neither images nor an active stream from which to read them. |
KTX_INVALID_OPERATION | The combination of the ktxTexture's format, tiling and usageFlags is not supported by the physical device. |
KTX_INVALID_OPERATION | Requested mipmap generation is not supported by the physical device for the combination of the ktxTexture's format and tiling . |
KTX_OUT_OF_MEMORY | Sufficient memory could not be allocated on either the CPU or the Vulkan device. |
KTX_error_code ktxVulkanDeviceInfo_Construct | ( | ktxVulkanDeviceInfo * | This, |
VkPhysicalDevice | physicalDevice, | ||
VkDevice | device, | ||
VkQueue | queue, | ||
VkCommandPool | cmdPool, | ||
const VkAllocationCallbacks * | pAllocator | ||
) |
Construct a ktxVulkanDeviceInfo object.
Records the device information, allocates a command buffer that will be used to transfer image data to the Vulkan device and retrieves the physical device memory properties for ease of use when allocating device memory for the images.
Pass a valid ktxVulkanDeviceInfo* to any Vulkan KTX image loading function to provide it with the information.
This | pointer to the ktxVulkanDeviceInfo object to initialize. |
physicalDevice | handle of the Vulkan physical device. |
device | handle of the Vulkan logical device. |
queue | handle of the Vulkan queue. |
cmdPool | handle of the Vulkan command pool. |
pAllocator | pointer to the allocator to use for the image memory. If NULL, the default allocator will be used. |
ktxVulkanDeviceInfo * ktxVulkanDeviceInfo_Create | ( | VkPhysicalDevice | physicalDevice, |
VkDevice | device, | ||
VkQueue | queue, | ||
VkCommandPool | cmdPool, | ||
const VkAllocationCallbacks * | pAllocator | ||
) |
Create a ktxVulkanDeviceInfo object.
Allocates CPU memory for a ktxVulkanDeviceInfo object then calls ktxVulkanDeviceInfo_construct(). See it for documentation of the parameters.
void ktxVulkanDeviceInfo_Destroy | ( | ktxVulkanDeviceInfo * | This | ) |
Destroy a ktxVulkanDeviceInfo object.
Calls ktxVulkanDeviceInfo_destruct() then frees the ktxVulkanDeviceInfo.
This | pointer to the ktxVulkanDeviceInfo to destroy. |
void ktxVulkanDeviceInfo_Destruct | ( | ktxVulkanDeviceInfo * | This | ) |
Destruct a ktxVulkanDeviceInfo object.
Frees the command buffer.
This | pointer to the ktxVulkanDeviceInfo to destruct. |
void ktxVulkanTexture_Destruct | ( | ktxVulkanTexture * | vkTexture, |
VkDevice | device, | ||
const VkAllocationCallbacks * | pAllocator | ||
) |
Destructor for the object returned when loading a texture image.
Frees the Vulkan resources created when the texture image was loaded.
vkTexture | pointer to the ktxVulkanTexture to be destructed. |
device | handle to the Vulkan logical device to which the texture was loaded. |
pAllocator | pointer to the allocator used during loading. |