mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-20 02:26:35 +00:00
headless: fix vulkan exclusive fullscreen ignored
Running in headless mode under wayland (e.g. Sway) compositor, it's not possible to set any resolution other than 1280x720. This is because Ryujinx was not updating default surface dimension when creating swapchain.
This commit is contained in:
parent
a2c0035013
commit
811d2e6d3b
2 changed files with 31 additions and 12 deletions
|
@ -10,8 +10,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
class Window : WindowBase, IDisposable
|
class Window : WindowBase, IDisposable
|
||||||
{
|
{
|
||||||
private const int SurfaceWidth = 1280;
|
private uint _surfaceWidth = 1280;
|
||||||
private const int SurfaceHeight = 720;
|
private uint _surfaceHeight = 720;
|
||||||
|
|
||||||
private readonly VulkanRenderer _gd;
|
private readonly VulkanRenderer _gd;
|
||||||
private readonly SurfaceKHR _surface;
|
private readonly SurfaceKHR _surface;
|
||||||
|
@ -295,15 +295,15 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Extent2D ChooseSwapExtent(SurfaceCapabilitiesKHR capabilities)
|
public Extent2D ChooseSwapExtent(SurfaceCapabilitiesKHR capabilities)
|
||||||
{
|
{
|
||||||
if (capabilities.CurrentExtent.Width != uint.MaxValue)
|
if (capabilities.CurrentExtent.Width != uint.MaxValue)
|
||||||
{
|
{
|
||||||
return capabilities.CurrentExtent;
|
return capabilities.CurrentExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint width = Math.Max(capabilities.MinImageExtent.Width, Math.Min(capabilities.MaxImageExtent.Width, SurfaceWidth));
|
uint width = Math.Max(capabilities.MinImageExtent.Width, Math.Min(capabilities.MaxImageExtent.Width, _surfaceWidth));
|
||||||
uint height = Math.Max(capabilities.MinImageExtent.Height, Math.Min(capabilities.MaxImageExtent.Height, SurfaceHeight));
|
uint height = Math.Max(capabilities.MinImageExtent.Height, Math.Min(capabilities.MaxImageExtent.Height, _surfaceHeight));
|
||||||
|
|
||||||
return new Extent2D(width, height);
|
return new Extent2D(width, height);
|
||||||
}
|
}
|
||||||
|
@ -630,9 +630,14 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
public override void SetSize(int width, int height)
|
public override void SetSize(int width, int height)
|
||||||
{
|
{
|
||||||
// We don't need to use width and height as we can get the size from the surface.
|
if (width > 0 && height > 0)
|
||||||
|
{
|
||||||
|
_surfaceWidth = (uint)width;
|
||||||
|
_surfaceHeight = (uint)height;
|
||||||
|
|
||||||
_swapchainIsDirty = true;
|
_swapchainIsDirty = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void ChangeVSyncMode(bool vsyncEnabled)
|
public override void ChangeVSyncMode(bool vsyncEnabled)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,18 +29,32 @@ namespace Ryujinx.Headless.SDL2.Vulkan
|
||||||
|
|
||||||
protected override void InitializeRenderer()
|
protected override void InitializeRenderer()
|
||||||
{
|
{
|
||||||
|
int width = DefaultWidth;
|
||||||
|
int height = DefaultHeight;
|
||||||
|
|
||||||
if (IsExclusiveFullscreen)
|
if (IsExclusiveFullscreen)
|
||||||
{
|
{
|
||||||
Renderer?.Window.SetSize(ExclusiveFullscreenWidth, ExclusiveFullscreenHeight);
|
width = ExclusiveFullscreenWidth;
|
||||||
MouseDriver.SetClientSize(ExclusiveFullscreenWidth, ExclusiveFullscreenHeight);
|
height = ExclusiveFullscreenHeight;
|
||||||
|
}
|
||||||
|
else if (IsFullscreen)
|
||||||
|
{
|
||||||
|
// NOTE: grabbing the main display's dimensions directly as OpenGL doesn't scale along like the VulkanWindow.
|
||||||
|
if (SDL_GetDisplayBounds(DisplayId, out SDL_Rect displayBounds) < 0)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"Could not retrieve display bounds: {SDL_GetError()}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Renderer?.Window.SetSize(DefaultWidth, DefaultHeight);
|
width = displayBounds.w;
|
||||||
MouseDriver.SetClientSize(DefaultWidth, DefaultHeight);
|
height = displayBounds.h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Renderer?.Window.SetSize(width, height);
|
||||||
|
MouseDriver.SetClientSize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
private static void BasicInvoke(Action action)
|
private static void BasicInvoke(Action action)
|
||||||
{
|
{
|
||||||
action();
|
action();
|
||||||
|
|
Loading…
Reference in a new issue