src/ktx/libktx/vkloader.c
/**
 * @memberof ktxVulkanDeviceInfo
 * @~English
 * @brief 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.
 *
 * @param  This            pointer to the ktxVulkanDeviceInfo object to
 *                        initialize.
 * @param  physicalDevice handle of the Vulkan physical device.
 * @param  device         handle of the Vulkan logical device.
 * @param  queue          handle of the Vulkan queue.
 * @param  cmdPool        handle of the Vulkan command pool.
 * @param  pAllocator     pointer to the allocator to use for the image
 *                        memory. If NULL, the default allocator will be used.
 *
 * @returns KTX_SUCCESS on success, KTX_OUT_OF_MEMORY if a command buffer could
 *          not be allocated.
 *
 * @sa ktxVulkanDeviceInfo_destruct()
 */
@memberof ktxVulkanDeviceInfo
@~English
@brief 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.

@param  This            pointer to the ktxVulkanDeviceInfo object to
initialize.
@param  physicalDevice handle of the Vulkan physical device.
@param  device         handle of the Vulkan logical device.
@param  queue          handle of the Vulkan queue.
@param  cmdPool        handle of the Vulkan command pool.
@param  pAllocator     pointer to the allocator to use for the image
memory. If NULL, the default allocator will be used.

@returns KTX_SUCCESS on success, KTX_OUT_OF_MEMORY if a command buffer could
not be allocated.


@memberof ktxVulkanDeviceInfo @~English @brief 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 . @param This pointer to the ktxVulkanDeviceInfo object to initialize . @param physicalDevice handle of the Vulkan physical device . @param device handle of the Vulkan logical device . @param queue handle of the Vulkan queue . @param cmdPool handle of the Vulkan command pool . @param pAllocator pointer to the allocator to use for the image memory . If NULL the default allocator will be used . @returns KTX_SUCCESS on success KTX_OUT_OF_MEMORY if a command buffer could not be allocated .
KTX_error_code
ktxVulkanDeviceInfo_Construct(ktxVulkanDeviceInfo* This,
                              VkPhysicalDevice physicalDevice, VkDevice device,
                              VkQueue queue, VkCommandPool cmdPool,
                              const VkAllocationCallbacks* pAllocator)
{
    VkCommandBufferAllocateInfo cmdBufInfo = {
        .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO
    };
    VkResult result;
#if defined(KTX_USE_FUNCPTRS_FOR_VULKAN)
    if (!ktxVulkanModuleHandle) {
        result = ktxLoadVulkanLibrary();
        if (result != KTX_SUCCESS)
            return result;
    }
#endif
    This->physicalDevice = physicalDevice;
    This->device = device;
    This->queue = queue;
    This->cmdPool = cmdPool;
    This->pAllocator = pAllocator;
    vkGetPhysicalDeviceMemoryProperties(physicalDevice,
                                        &This->deviceMemoryProperties);
    cmdBufInfo.commandPool = cmdPool;
    cmdBufInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
    cmdBufInfo.commandBufferCount = 1;
    result = vkAllocateCommandBuffers(device, &cmdBufInfo, &This->cmdBuffer);
    if (result != VK_SUCCESS) {
        return KTX_OUT_OF_MEMORY; 
    }
    return KTX_SUCCESS;
}
KTX_error_code ktxVulkanDeviceInfo_Construct ( ktxVulkanDeviceInfo * This , VkPhysicalDevice physicalDevice , VkDevice device , VkQueue queue , VkCommandPool cmdPool , const VkAllocationCallbacks * pAllocator ) { VkCommandBufferAllocateInfo cmdBufInfo = { . sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO } ; VkResult result ; #if defined ( KTX_USE_FUNCPTRS_FOR_VULKAN ) if ( ! ktxVulkanModuleHandle ) { result = ktxLoadVulkanLibrary ( ) ; if ( result != KTX_SUCCESS ) return result ; } #endif This -> physicalDevice = physicalDevice ; This -> device = device ; This -> queue = queue ; This -> cmdPool = cmdPool ; This -> pAllocator = pAllocator ; vkGetPhysicalDeviceMemoryProperties ( physicalDevice , & This -> deviceMemoryProperties ) ; cmdBufInfo . commandPool = cmdPool ; cmdBufInfo . level = VK_COMMAND_BUFFER_LEVEL_PRIMARY ; cmdBufInfo . commandBufferCount = 1 ; result = vkAllocateCommandBuffers ( device , & cmdBufInfo , & This -> cmdBuffer ) ; if ( result != VK_SUCCESS ) { return KTX_OUT_OF_MEMORY ; } return KTX_SUCCESS ; }
@memberof ktxVulkanDeviceInfo
 @~English
 @brief Construct a ktxVulkanDeviceInfo object.
@memberof ktxVulkanDeviceInfo @~English @brief Construct a ktxVulkanDeviceInfo object .
// Delay loading not supported so must do it ourselves. // Use a separate command buffer for texture loading. Needed for // submitting image barriers and converting tilings. // XXX Consider an equivalent to pGlError