attempt to recreate surface if lost

This commit is contained in:
Emmanuel Hansen 2023-06-28 09:21:05 +00:00
parent 5db7eda0e9
commit e08a49336c
2 changed files with 20 additions and 1 deletions

View File

@ -842,6 +842,15 @@ namespace Ryujinx.Graphics.Vulkan
ScreenCaptured?.Invoke(this, bitmap);
}
internal unsafe void RecreateSurface()
{
SurfaceApi.DestroySurface(_instance.Instance, _surface, null);
_surface = _getSurface(_instance.Instance, Api);
(_window as Window)?.SetSurface(_surface);
}
public unsafe void Dispose()
{
if (!_initialized)

View File

@ -14,10 +14,10 @@ namespace Ryujinx.Graphics.Vulkan
private const int SurfaceHeight = 720;
private readonly VulkanRenderer _gd;
private readonly SurfaceKHR _surface;
private readonly PhysicalDevice _physicalDevice;
private readonly Device _device;
private SwapchainKHR _swapchain;
private SurfaceKHR _surface;
private Image[] _swapchainImages;
private Auto<DisposableImageView>[] _swapchainImageViews;
@ -84,6 +84,12 @@ namespace Ryujinx.Graphics.Vulkan
CreateSwapchain();
}
internal void SetSurface(SurfaceKHR surface)
{
_surface = surface;
RecreateSwapchain();
}
private unsafe void CreateSwapchain()
{
_gd.SurfaceApi.GetPhysicalDeviceSurfaceCapabilities(_physicalDevice, _surface, out var capabilities);
@ -313,6 +319,10 @@ namespace Ryujinx.Graphics.Vulkan
{
RecreateSwapchain();
}
else if(acquireResult == Result.ErrorSurfaceLostKhr)
{
_gd.RecreateSurface();
}
else
{
acquireResult.ThrowOnError();