private unsafe void CreateSwapchainImages() { DestroyCurrentImageViews(); Size = new PixelSize((int)_swapchainExtent.Width, (int)_swapchainExtent.Height); uint imageCount = 0; _swapchainExtension.GetSwapchainImages(_device.InternalHandle, _swapchain, &imageCount, null); _swapchainImages = new Image[imageCount]; fixed(Image *pSwapchainImages = _swapchainImages) { _swapchainExtension.GetSwapchainImages(_device.InternalHandle, _swapchain, &imageCount, pSwapchainImages); } _swapchainImageViews = new ImageView[imageCount]; var surfaceFormat = SurfaceFormat; for (var i = 0; i < imageCount; i++) { _swapchainImageViews[i] = CreateSwapchainImageView(_swapchainImages[i], surfaceFormat.Format); } }
private void FramebufferResize(Vector2D <int> obj) { if (obj.X <= 0 || obj.Y <= 0) { return; } _khrSwapchain.DestroySwapchain(_logicalDevice, _swapchain, null); _khrSwapchain.CreateSwapchain(_logicalDevice, new SwapchainCreateInfoKHR(surface: _surface, minImageCount: 3, imageFormat: _swapchainFormat, imageColorSpace: _swapchainColorSpace, imageExtent: new Extent2D((uint)obj.X, (uint)obj.Y), imageArrayLayers: 1, imageUsage: ImageUsageFlags.ImageUsageTransferDstBit | ImageUsageFlags.ImageUsageStorageBit, imageSharingMode: SharingMode.Exclusive, queueFamilyIndexCount: 0, pQueueFamilyIndices: null, // ignored due to SharingMode.Exclusive presentMode: _presentMode, clipped: false, preTransform: SurfaceTransformFlagsKHR.SurfaceTransformIdentityBitKhr, compositeAlpha: CompositeAlphaFlagsKHR.CompositeAlphaOpaqueBitKhr), null, out _swapchain) .ThrowCode(); uint swapchainCount = 0; _khrSwapchain.GetSwapchainImages(_logicalDevice, _swapchain, ref swapchainCount, null).ThrowCode(); _swapchainImages = new Image[swapchainCount]; fixed(Image *p = _swapchainImages) _khrSwapchain.GetSwapchainImages(_logicalDevice, _swapchain, ref swapchainCount, p).ThrowCode(); _renderGraph.ChangeTargetImages((Vector2D <uint>)obj, _swapchainImages, _swapchainFormat, _swapchainColorSpace); }