Esempio n. 1
0
        public SwapChain(PresentQueue _presentableQueue, uint width = 800, uint height = 600, VkFormat format = VkFormat.B8g8r8a8Unorm, VkPresentModeKHR presentMode = VkPresentModeKHR.FifoKHR)
            : base(_presentableQueue.dev)
        {
            presentQueue = _presentableQueue;
            createInfos  = VkSwapchainCreateInfoKHR.New();

            VkSurfaceFormatKHR[] formats = Dev.phy.GetSurfaceFormats(presentQueue.Surface);
            for (int i = 0; i < formats.Length; i++)
            {
                if (formats[i].format == format)
                {
                    createInfos.imageFormat     = format;
                    createInfos.imageColorSpace = formats[i].colorSpace;
                    break;
                }
            }
            if (createInfos.imageFormat == VkFormat.Undefined)
            {
                throw new Exception("Invalid format for swapchain: " + format);
            }

            VkPresentModeKHR[] presentModes = Dev.phy.GetSurfacePresentModes(presentQueue.Surface);
            for (int i = 0; i < presentModes.Length; i++)
            {
                if (presentModes[i] == presentMode)
                {
                    createInfos.presentMode = presentMode;
                    break;
                }
            }
            if (createInfos.presentMode != presentMode)
            {
                throw new Exception("Invalid presentMode for swapchain: " + presentMode);
            }

            createInfos.surface          = presentQueue.Surface;
            createInfos.imageExtent      = new VkExtent2D(width, height);
            createInfos.imageArrayLayers = 1;
            createInfos.imageUsage       = VkImageUsageFlags.ColorAttachment;
            createInfos.imageSharingMode = VkSharingMode.Exclusive;
            createInfos.compositeAlpha   = VkCompositeAlphaFlagsKHR.OpaqueKHR;
            createInfos.presentMode      = presentMode;
            createInfos.clipped          = 1;
        }
Esempio n. 2
0
 /// <summary>
 /// override this method to create additional queue. Dedicated queue of the requested type will be selected first, created queues may excess
 /// available physical queues.
 /// </summary>
 protected virtual void createQueues()
 {
     presentQueue = new PresentQueue(dev, VkQueueFlags.Graphics, hSurf);
 }