MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / ktxTexture_VkUploadEx_WithSuballocator

Function ktxTexture_VkUploadEx_WithSuballocator

lib/vkloader.c:813–1444  ·  view source on GitHub ↗

* @memberof ktxTexture * @~English * @brief Create a Vulkan image object from a ktxTexture object. * * Creates a VkImage with @c VkFormat etc. matching the KTX data and uploads * the images. Mipmaps will be generated if the @c ktxTexture's * @c generateMipmaps flag is set. Returns the handles of the created objects * and information about the texture in the @c ktxVulkanTexture pointed at b

Source from the content-addressed store, hash-verified

811 * @sa @ref ktxVulkanDeviceInfo::ktxVulkanDeviceInfo\_Construct "ktxVulkanDeviceInfo_Construct()"
812 */
813KTX_error_code
814ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vdi,
815 ktxVulkanTexture* vkTexture,
816 VkImageTiling tiling,
817 VkImageUsageFlags usageFlags,
818 VkImageLayout finalLayout,
819 ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks)
820{
821 KTX_error_code kResult;
822 VkFilter blitFilter = VK_FILTER_LINEAR;
823 VkFormat vkFormat;
824 VkImageType imageType;
825 VkImageViewType viewType;
826 VkImageCreateFlags createFlags = 0;
827 VkImageFormatProperties imageFormatProperties;
828 VkResult vResult;
829 VkCommandBufferBeginInfo cmdBufBeginInfo = {
830 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
831 .pNext = NULL
832 };
833 VkImageCreateInfo imageCreateInfo = {
834 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
835 .pNext = NULL
836 };
837 VkMemoryAllocateInfo memAllocInfo = {
838 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
839 .pNext = NULL,
840 .allocationSize = 0,
841 .memoryTypeIndex = 0
842 };
843 VkMemoryRequirements memReqs;
844 ktx_uint32_t numImageLayers, numImageLevels;
845 ktx_uint32_t elementSize = ktxTexture_GetElementSize(This);
846 ktx_bool_t canUseFasterPath;
847 ktx_bool_t useSuballocator = false;
848 if (subAllocatorCallbacks) {
849 if (subAllocatorCallbacks->allocMemFuncPtr &&
850 subAllocatorCallbacks->bindBufferFuncPtr &&
851 subAllocatorCallbacks->bindImageFuncPtr &&
852 subAllocatorCallbacks->memoryMapFuncPtr &&
853 subAllocatorCallbacks->memoryUnmapFuncPtr &&
854 subAllocatorCallbacks->freeMemFuncPtr)
855 useSuballocator = true;
856 else
857 return KTX_INVALID_VALUE;
858 }
859
860 if (!vdi || !This || !vkTexture) {
861 return KTX_INVALID_VALUE;
862 }
863
864 if (!This->pData && !ktxTexture_isActiveStream(This)) {
865 /* Nothing to upload. */
866 return KTX_INVALID_OPERATION;
867 }
868
869 /* _ktxCheckHeader should have caught this. */
870 assert(This->numFaces == 6 ? This->numDimensions == 2 : VK_TRUE);

Callers 4

ktxTexture_VkUploadExFunction · 0.85
TextureMethod · 0.85

Calls 11

assertFunction · 0.85
ktxTexture_GetVkFormatFunction · 0.85
ktxTexture_GetRowPitchFunction · 0.85
generateMipmapsFunction · 0.85
setImageLayoutFunction · 0.70
floorFunction · 0.50
log2Function · 0.50

Tested by

no test coverage detected