public SoftwareFormSurface(SoftwareInstance instance, VkWin32SurfaceCreateInfoKHR createInfo) { this.m_Formats = new List <VkSurfaceFormatKHR>() { VkSurfaceFormatKHR.Create(VkFormat.VK_FORMAT_B8G8R8A8_UNORM, VkColorSpaceKHR.VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) }; this.m_PresentModes = new List <VkPresentModeKHR>() { VkPresentModeKHR.VK_PRESENT_MODE_IMMEDIATE_KHR }; this.m_instance = instance; this.m_createInfo = createInfo; foreach (Form form in Application.OpenForms) { if (form.Handle == createInfo.hwnd) { m_Form = form; } } if (m_Form == null) { throw new ArgumentException(string.Format("Form not found for the handle informed on the field {0}.{1}", nameof(VkWin32SurfaceCreateInfoKHR), nameof(VkWin32SurfaceCreateInfoKHR.hwnd))); } var m_OriginalExtents = VkExtent2D.Create(GetWidth(), GetHeight()); m_CurrentSurfaceExtents = m_OriginalExtents; this.m_Capabilities = new VkSurfaceCapabilitiesKHR(); this.m_Capabilities.currentExtent = m_OriginalExtents; this.m_Capabilities.maxImageExtent = m_OriginalExtents; this.m_Capabilities.minImageExtent = m_OriginalExtents; this.m_Capabilities.minImageCount = 1; this.m_Capabilities.maxImageCount = 8; this.m_Capabilities.maxImageArrayLayers = 1; this.m_Capabilities.supportedTransforms = VkSurfaceTransformFlagBitsKHR.VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; this.m_Capabilities.currentTransform = VkSurfaceTransformFlagBitsKHR.VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; this.m_Capabilities.supportedCompositeAlpha = VkCompositeAlphaFlagBitsKHR.VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; this.m_Capabilities.supportedUsageFlags = VkImageUsageFlags.VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; this.m_SurfacePresentMode = FormSurfacePresentMode.DibBitmapBitBlt; InternalResize(); m_Form.Resize += Form_Resize; }
private VkSurfaceFormatKHR chooseSwapSurfaceFormat(VkSurfaceFormatKHR[] availableFormats) { if (availableFormats.Length == 1 && availableFormats[0].format == VkFormat.VK_FORMAT_UNDEFINED) { return(VkSurfaceFormatKHR.Create(VkFormat.VK_FORMAT_B8G8R8A8_UNORM, VkColorSpaceKHR.VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)); } foreach (var availableFormat in availableFormats) { if (availableFormat.format == VkFormat.VK_FORMAT_B8G8R8A8_UNORM && availableFormat.colorSpace == VkColorSpaceKHR.VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) { return(availableFormat); } } return(availableFormats[0]); }