src/FNA3D_Driver_Vulkan.c
/* FIXME: remove code duplication here */
/* if no dedicated device exists, one that supports our features would be fine */
remove code duplication here
if no dedicated device exists, one that supports our features would be fine
remove code duplication here if no dedicated device exists one that supports our features would be fine
static uint8_t IsDeviceSuitable(
	FNAVulkanRenderer *renderer,
	VkPhysicalDevice physicalDevice,
	const char** requiredExtensionNames,
	uint32_t requiredExtensionNamesLength,
	VkSurfaceKHR surface,
	QueueFamilyIndices* queueFamilyIndices
) {
	queueFamilyIndices->graphicsFamily = UINT32_MAX;
	queueFamilyIndices->presentFamily = UINT32_MAX;
	if (!CheckDeviceExtensionSupport(renderer, physicalDevice, requiredExtensionNames, requiredExtensionNamesLength))
	{
		return 0;
	}
	VkPhysicalDeviceProperties deviceProperties;
	renderer->vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
	uint32_t queueFamilyCount;
	renderer->vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, NULL);
	SwapChainSupportDetails swapChainSupportDetails;
	if (!QuerySwapChainSupport(renderer, physicalDevice, surface, &swapChainSupportDetails))
	{
		SDL_free(swapChainSupportDetails.formats);
		SDL_free(swapChainSupportDetails.presentModes);
		return 0;
	}
	if (swapChainSupportDetails.formatsLength == 0 || swapChainSupportDetails.presentModesLength == 0)
	{
		SDL_free(swapChainSupportDetails.formats);
		SDL_free(swapChainSupportDetails.presentModes);
		return 0;
	}
	VkQueueFamilyProperties queueProps[queueFamilyCount];
	renderer->vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, queueProps);
	for (uint32_t i = 0; i < queueFamilyCount; i++) {
		VkBool32 supportsPresent;
		renderer->vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, i, surface, &supportsPresent);
		if (supportsPresent && (queueProps[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0) {
			queueFamilyIndices->graphicsFamily = i;
			queueFamilyIndices->presentFamily = i;
			return 1;
		}
	}
	return 0;
}
static uint8_t IsDeviceSuitable ( FNAVulkanRenderer * renderer , VkPhysicalDevice physicalDevice , const char * * requiredExtensionNames , uint32_t requiredExtensionNamesLength , VkSurfaceKHR surface , QueueFamilyIndices * queueFamilyIndices ) { queueFamilyIndices -> graphicsFamily = UINT32_MAX ; queueFamilyIndices -> presentFamily = UINT32_MAX ; if ( ! CheckDeviceExtensionSupport ( renderer , physicalDevice , requiredExtensionNames , requiredExtensionNamesLength ) ) { return 0 ; } VkPhysicalDeviceProperties deviceProperties ; renderer -> vkGetPhysicalDeviceProperties ( physicalDevice , & deviceProperties ) ; uint32_t queueFamilyCount ; renderer -> vkGetPhysicalDeviceQueueFamilyProperties ( physicalDevice , & queueFamilyCount , NULL ) ; SwapChainSupportDetails swapChainSupportDetails ; if ( ! QuerySwapChainSupport ( renderer , physicalDevice , surface , & swapChainSupportDetails ) ) { SDL_free ( swapChainSupportDetails . formats ) ; SDL_free ( swapChainSupportDetails . presentModes ) ; return 0 ; } if ( swapChainSupportDetails . formatsLength == 0 || swapChainSupportDetails . presentModesLength == 0 ) { SDL_free ( swapChainSupportDetails . formats ) ; SDL_free ( swapChainSupportDetails . presentModes ) ; return 0 ; } VkQueueFamilyProperties queueProps [ queueFamilyCount ] ; renderer -> vkGetPhysicalDeviceQueueFamilyProperties ( physicalDevice , & queueFamilyCount , queueProps ) ; for ( uint32_t i = 0 ; i < queueFamilyCount ; i ++ ) { VkBool32 supportsPresent ; renderer -> vkGetPhysicalDeviceSurfaceSupportKHR ( physicalDevice , i , surface , & supportsPresent ) ; if ( supportsPresent && ( queueProps [ i ] . queueFlags & VK_QUEUE_GRAPHICS_BIT ) != 0 ) { queueFamilyIndices -> graphicsFamily = i ; queueFamilyIndices -> presentFamily = i ; return 1 ; } } return 0 ; }
FIXME: remove code duplication here
if no dedicated device exists, one that supports our features would be fine
FIXME : remove code duplication here if no dedicated device exists one that supports our features would be fine