forked from MeloNX/MeloNX
attempt to recreate surface if lost
This commit is contained in:
parent
5db7eda0e9
commit
e08a49336c
@ -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)
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user