mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-17 12:16:41 +00:00
Vulkan: Destroy old swapchain on swapchain recreation (#3889)
* Destroy old swapchain on swapchain recreation * vkDeviceWaitIdle before DestroySwapchain * Update Ryujinx.Graphics.Vulkan/Window.cs Co-authored-by: gdkchan <gab.dark.100@gmail.com> * Avoid unsafe code on RecreateSwapchain() * Destroying old Swapchain on a queue. * Cleanup and fix on destroying old Swapchain. * Update Ryujinx.Graphics.Vulkan/Window.cs Co-authored-by: gdkchan <gab.dark.100@gmail.com> * Update Ryujinx.Graphics.Vulkan/Window.cs Co-authored-by: gdkchan <gab.dark.100@gmail.com> * Update Ryujinx.Graphics.Vulkan/Window.cs Co-authored-by: gdkchan <gab.dark.100@gmail.com> * Update Window.cs Done. Co-authored-by: gdkchan <gab.dark.100@gmail.com>
This commit is contained in:
parent
de3134adbe
commit
bb89e36fd8
@ -1,5 +1,6 @@
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Silk.NET.Vulkan;
|
||||
using Silk.NET.Vulkan.Extensions.KHR;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using VkFormat = Silk.NET.Vulkan.Format;
|
||||
@ -49,13 +50,19 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
private void RecreateSwapchain()
|
||||
{
|
||||
var oldSwapchain = _swapchain;
|
||||
int imageCount = _swapchainImageViews.Length;
|
||||
_vsyncModeChanged = false;
|
||||
|
||||
for (int i = 0; i < _swapchainImageViews.Length; i++)
|
||||
for (int i = 0; i < imageCount; i++)
|
||||
{
|
||||
_swapchainImageViews[i].Dispose();
|
||||
}
|
||||
|
||||
// Destroy old Swapchain.
|
||||
_gd.Api.DeviceWaitIdle(_device);
|
||||
_gd.SwapchainApi.DestroySwapchain(_device, oldSwapchain, Span<AllocationCallbacks>.Empty);
|
||||
|
||||
CreateSwapchain();
|
||||
}
|
||||
|
||||
@ -115,8 +122,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
PreTransform = capabilities.CurrentTransform,
|
||||
CompositeAlpha = CompositeAlphaFlagsKHR.OpaqueBitKhr,
|
||||
PresentMode = ChooseSwapPresentMode(presentModes, _vsyncEnabled),
|
||||
Clipped = true,
|
||||
OldSwapchain = oldSwapchain
|
||||
Clipped = true
|
||||
};
|
||||
|
||||
_gd.SwapchainApi.CreateSwapchain(_device, swapchainCreateInfo, null, out _swapchain).ThrowOnError();
|
||||
|
Loading…
Reference in New Issue
Block a user