2022-11-26 03:06:53 -08:00
|
|
|
using Avalonia.Platform;
|
2022-09-19 11:05:26 -07:00
|
|
|
using Silk.NET.Vulkan;
|
|
|
|
using SPB.Graphics.Vulkan;
|
2022-11-26 03:06:53 -08:00
|
|
|
using SPB.Platform.GLX;
|
2022-12-06 14:00:25 -08:00
|
|
|
using SPB.Platform.Metal;
|
2022-09-19 11:05:26 -07:00
|
|
|
using SPB.Platform.Win32;
|
|
|
|
using SPB.Platform.X11;
|
|
|
|
using SPB.Windowing;
|
|
|
|
using System;
|
2022-11-26 03:06:53 -08:00
|
|
|
using System.Runtime.Versioning;
|
2022-09-19 11:05:26 -07:00
|
|
|
|
2022-12-29 06:24:05 -08:00
|
|
|
namespace Ryujinx.Ava.UI.Helpers
|
2022-09-19 11:05:26 -07:00
|
|
|
{
|
|
|
|
public class VulkanEmbeddedWindow : EmbeddedWindow
|
|
|
|
{
|
|
|
|
private NativeWindowBase _window;
|
|
|
|
|
2022-11-26 03:06:53 -08:00
|
|
|
[SupportedOSPlatform("linux")]
|
|
|
|
protected override IPlatformHandle CreateLinux(IPlatformHandle parent)
|
|
|
|
{
|
|
|
|
X11Window = new GLXWindow(new NativeHandle(X11.DefaultDisplay), new NativeHandle(parent.Handle));
|
|
|
|
WindowHandle = X11Window.WindowHandle.RawHandle;
|
|
|
|
X11Display = X11Window.DisplayHandle.RawHandle;
|
|
|
|
|
|
|
|
X11Window.Hide();
|
|
|
|
|
|
|
|
return new PlatformHandle(WindowHandle, "X11");
|
|
|
|
}
|
|
|
|
|
2022-09-19 11:05:26 -07:00
|
|
|
public SurfaceKHR CreateSurface(Instance instance)
|
|
|
|
{
|
|
|
|
if (OperatingSystem.IsWindows())
|
|
|
|
{
|
|
|
|
_window = new SimpleWin32Window(new NativeHandle(WindowHandle));
|
|
|
|
}
|
|
|
|
else if (OperatingSystem.IsLinux())
|
|
|
|
{
|
2022-11-25 09:40:44 -08:00
|
|
|
_window = new SimpleX11Window(new NativeHandle(X11Display), new NativeHandle(WindowHandle));
|
2022-09-19 11:05:26 -07:00
|
|
|
}
|
2022-12-06 14:00:25 -08:00
|
|
|
else if (OperatingSystem.IsMacOS())
|
|
|
|
{
|
|
|
|
_window = new SimpleMetalWindow(new NativeHandle(NsView), new NativeHandle(MetalLayer));
|
|
|
|
}
|
2022-09-19 11:05:26 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new PlatformNotSupportedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
return new SurfaceKHR((ulong?)VulkanHelper.CreateWindowSurface(instance.Handle, _window));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|