src/FNA3D_Driver_Vulkan.c
/* we want a physical device that is dedicated and supports our features */
we want a physical device that is dedicated and supports our features
we want a physical device that is dedicated and supports our features
static uint8_t IsDeviceIdeal(
	FNAVulkanRenderer *renderer,
	VkPhysicalDevice physicalDevice,
	const char** requiredExtensionNames,
	uint32_t requiredExtensionNamesLength,
	VkSurfaceKHR surface,
	QueueFamilyIndices* queueFamilyIndices
) {
	queueFamilyIndices->graphicsFamily = UINT32_MAX;
	queueFamilyIndices->presentFamily = UINT32_MAX;
	VkPhysicalDeviceProperties deviceProperties;
	renderer->vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
	if (deviceProperties.deviceType != VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
	{
		return 0;
	}
	if (!CheckDeviceExtensionSupport(renderer, physicalDevice, requiredExtensionNames, requiredExtensionNamesLength))
	{
		return 0;
	}
	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 IsDeviceIdeal ( FNAVulkanRenderer * renderer , VkPhysicalDevice physicalDevice , const char * * requiredExtensionNames , uint32_t requiredExtensionNamesLength , VkSurfaceKHR surface , QueueFamilyIndices * queueFamilyIndices ) { queueFamilyIndices -> graphicsFamily = UINT32_MAX ; queueFamilyIndices -> presentFamily = UINT32_MAX ; VkPhysicalDeviceProperties deviceProperties ; renderer -> vkGetPhysicalDeviceProperties ( physicalDevice , & deviceProperties ) ; if ( deviceProperties . deviceType != VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU ) { return 0 ; } if ( ! CheckDeviceExtensionSupport ( renderer , physicalDevice , requiredExtensionNames , requiredExtensionNamesLength ) ) { return 0 ; } 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 ; }
we want a physical device that is dedicated and supports our features
we want a physical device that is dedicated and supports our features
/* FIXME: need better structure for checking vs storing support details */