Saturn/src/Saturn/Vulkan/VulkanContext.cpp
SwapchainCreationData VulkanContext::GetSwapchainCreationData()
	{
		SwapchainCreationData Data;

		// Get surface formats.

		VK_CHECK( vkGetPhysicalDeviceSurfaceFormatsKHR( m_PhysicalDevice, m_Surface, &Data.FormatCount, 0 ) );

		Data.SurfaceFormats = std::vector<VkSurfaceFormatKHR>( Data.FormatCount );

		VK_CHECK( vkGetPhysicalDeviceSurfaceFormatsKHR( m_PhysicalDevice, m_Surface, &Data.FormatCount, Data.SurfaceFormats.data() ) );

		for( VkSurfaceFormatKHR& rFormat : Data.SurfaceFormats )
		{
			// Use most common format type.
			if( rFormat.format == VK_FORMAT_B8G8R8A8_UNORM && rFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR )
			{
				// Set context's format.
				if( m_SurfaceFormat.format != rFormat.format)
					m_SurfaceFormat = rFormat;

				Data.CurrentFormat = m_SurfaceFormat;
				break;
			}
		}

		// Query Surface Capabilities
		VK_CHECK( vkGetPhysicalDeviceSurfaceCapabilitiesKHR( m_PhysicalDevice, m_Surface, &Data.SurfaceCaps ) );

		Data.ImageCount = Data.SurfaceCaps.minImageCount + 1;

		if( Data.SurfaceCaps.maxImageCount > 0 && Data.ImageCount > Data.SurfaceCaps.maxImageCount )
		{
			Data.ImageCount = Data.SurfaceCaps.maxImageCount;
		}

		return Data;
	}
// Data required for the swapchain to be created
Data required for the swapchain to be created
Data required for the swapchain to be created
SwapchainCreationData VulkanContext::GetSwapchainCreationData()
	{
		SwapchainCreationData Data;
		VK_CHECK( vkGetPhysicalDeviceSurfaceFormatsKHR( m_PhysicalDevice, m_Surface, &Data.FormatCount, 0 ) );
		Data.SurfaceFormats = std::vector<VkSurfaceFormatKHR>( Data.FormatCount );
		VK_CHECK( vkGetPhysicalDeviceSurfaceFormatsKHR( m_PhysicalDevice, m_Surface, &Data.FormatCount, Data.SurfaceFormats.data() ) );
		for( VkSurfaceFormatKHR& rFormat : Data.SurfaceFormats )
		{
			if( rFormat.format == VK_FORMAT_B8G8R8A8_UNORM && rFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR )
			{
				if( m_SurfaceFormat.format != rFormat.format)
					m_SurfaceFormat = rFormat;
				Data.CurrentFormat = m_SurfaceFormat;
				break;
			}
		}
		VK_CHECK( vkGetPhysicalDeviceSurfaceCapabilitiesKHR( m_PhysicalDevice, m_Surface, &Data.SurfaceCaps ) );
		Data.ImageCount = Data.SurfaceCaps.minImageCount + 1;
		if( Data.SurfaceCaps.maxImageCount > 0 && Data.ImageCount > Data.SurfaceCaps.maxImageCount )
		{
			Data.ImageCount = Data.SurfaceCaps.maxImageCount;
		}
		return Data;
	}
SwapchainCreationData VulkanContext :: GetSwapchainCreationData ( ) { SwapchainCreationData Data ; VK_CHECK ( vkGetPhysicalDeviceSurfaceFormatsKHR ( m_PhysicalDevice , m_Surface , & Data . FormatCount , 0 ) ) ; Data . SurfaceFormats = std :: vector < VkSurfaceFormatKHR > ( Data . FormatCount ) ; VK_CHECK ( vkGetPhysicalDeviceSurfaceFormatsKHR ( m_PhysicalDevice , m_Surface , & Data . FormatCount , Data . SurfaceFormats . data ( ) ) ) ; for ( VkSurfaceFormatKHR & rFormat : Data . SurfaceFormats ) { if ( rFormat . format == VK_FORMAT_B8G8R8A8_UNORM && rFormat . colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR ) { if ( m_SurfaceFormat . format != rFormat . format ) m_SurfaceFormat = rFormat ; Data . CurrentFormat = m_SurfaceFormat ; break ; } } VK_CHECK ( vkGetPhysicalDeviceSurfaceCapabilitiesKHR ( m_PhysicalDevice , m_Surface , & Data . SurfaceCaps ) ) ; Data . ImageCount = Data . SurfaceCaps . minImageCount + 1 ; if ( Data . SurfaceCaps . maxImageCount > 0 && Data . ImageCount > Data . SurfaceCaps . maxImageCount ) { Data . ImageCount = Data . SurfaceCaps . maxImageCount ; } return Data ; }
Data required for the swapchain to be created
Data required for the swapchain to be created
// Get surface formats. // Use most common format type. // Set context's format. // Query Surface Capabilities