forked from MeloNX/MeloNX
attempt to recreate surface if lost
This commit is contained in:
parent
ba8028d1d0
commit
5b9b17ef24
@ -842,6 +842,15 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
ScreenCaptured?.Invoke(this, bitmap);
|
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()
|
public unsafe void Dispose()
|
||||||
{
|
{
|
||||||
if (!_initialized)
|
if (!_initialized)
|
||||||
|
@ -14,10 +14,10 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
private const int SurfaceHeight = 720;
|
private const int SurfaceHeight = 720;
|
||||||
|
|
||||||
private readonly VulkanRenderer _gd;
|
private readonly VulkanRenderer _gd;
|
||||||
private readonly SurfaceKHR _surface;
|
|
||||||
private readonly PhysicalDevice _physicalDevice;
|
private readonly PhysicalDevice _physicalDevice;
|
||||||
private readonly Device _device;
|
private readonly Device _device;
|
||||||
private SwapchainKHR _swapchain;
|
private SwapchainKHR _swapchain;
|
||||||
|
private SurfaceKHR _surface;
|
||||||
|
|
||||||
private Image[] _swapchainImages;
|
private Image[] _swapchainImages;
|
||||||
private Auto<DisposableImageView>[] _swapchainImageViews;
|
private Auto<DisposableImageView>[] _swapchainImageViews;
|
||||||
@ -84,6 +84,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
CreateSwapchain();
|
CreateSwapchain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void SetSurface(SurfaceKHR surface)
|
||||||
|
{
|
||||||
|
_surface = surface;
|
||||||
|
RecreateSwapchain();
|
||||||
|
}
|
||||||
|
|
||||||
private unsafe void CreateSwapchain()
|
private unsafe void CreateSwapchain()
|
||||||
{
|
{
|
||||||
_gd.SurfaceApi.GetPhysicalDeviceSurfaceCapabilities(_physicalDevice, _surface, out var capabilities);
|
_gd.SurfaceApi.GetPhysicalDeviceSurfaceCapabilities(_physicalDevice, _surface, out var capabilities);
|
||||||
@ -313,6 +319,10 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
{
|
{
|
||||||
RecreateSwapchain();
|
RecreateSwapchain();
|
||||||
}
|
}
|
||||||
|
else if(acquireResult == Result.ErrorSurfaceLostKhr)
|
||||||
|
{
|
||||||
|
_gd.RecreateSurface();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
acquireResult.ThrowOnError();
|
acquireResult.ThrowOnError();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user