示例#1
0
        void CreateSwapchain(SwapchainCreateInfo mInfo)
        {
            var info = new VkSwapchainCreateInfoKHR();

            info.sType            = VkStructureType.SwapchainCreateInfoKhr;
            info.surface          = mInfo.surface.Native;
            info.minImageCount    = mInfo.minImageCount;
            info.imageFormat      = mInfo.imageFormat;
            info.imageColorSpace  = mInfo.imageColorSpace;
            info.imageExtent      = mInfo.imageExtent;
            info.imageArrayLayers = mInfo.imageArrayLayers;
            info.imageUsage       = mInfo.imageUsage;
            info.imageSharingMode = mInfo.imageSharingMode;

            var indicesMarshalled = new NativeArray <uint>(mInfo.queueFamilyIndices);

            info.queueFamilyIndexCount = (uint)indicesMarshalled.Count;
            info.pQueueFamilyIndices   = indicesMarshalled.Address;

            info.preTransform   = mInfo.preTransform;
            info.compositeAlpha = mInfo.compositeAlpha;
            info.presentMode    = mInfo.presentMode;
            info.clipped        = mInfo.clipped ? 1u : 0u;

            if (mInfo.oldSwapchain != null)
            {
                info.oldSwapchain = mInfo.oldSwapchain.Native;
            }

            using (indicesMarshalled) {
                var result = Device.Commands.createSwapchain(Device.Native, ref info, Device.Instance.AllocationCallbacks, out swapchain);
                if (result != VkResult.Success)
                {
                    throw new SwapchainException(string.Format("Error creating swapchain: {0}", result));
                }
            }

            Format      = info.imageFormat;
            ColorSpace  = info.imageColorSpace;
            Extent      = info.imageExtent;
            ArrayLayers = info.imageArrayLayers;
            PresentMode = info.presentMode;
            Usage       = info.imageUsage;
            SharingMode = info.imageSharingMode;
        }
示例#2
0
        public Swapchain(Device device, SwapchainCreateInfo info)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }
            if (info.surface == null)
            {
                throw new ArgumentNullException(nameof(info.surface));
            }

            Surface = info.surface;
            Device  = device;

            getImages = Device.Commands.getSwapchainImages;

            CreateSwapchain(info);

            GetImages();
        }