2022-11-26 12:06:53 +01:00
|
|
|
using Avalonia.Platform;
|
2022-09-19 20:05:26 +02:00
|
|
|
using Silk.NET.Vulkan;
|
|
|
|
using SPB.Graphics.Vulkan;
|
2022-11-26 12:06:53 +01:00
|
|
|
using SPB.Platform.GLX;
|
2022-12-06 23:00:25 +01:00
|
|
|
using SPB.Platform.Metal;
|
2022-09-19 20:05:26 +02:00
|
|
|
using SPB.Platform.Win32;
|
|
|
|
using SPB.Platform.X11;
|
|
|
|
using SPB.Windowing;
|
|
|
|
using System;
|
2022-11-26 12:06:53 +01:00
|
|
|
using System.Runtime.Versioning;
|
2022-09-19 20:05:26 +02:00
|
|
|
|
2022-12-29 15:24:05 +01:00
|
|
|
namespace Ryujinx.Ava.UI.Helpers
|
2022-09-19 20:05:26 +02:00
|
|
|
{
|
|
|
|
public class VulkanEmbeddedWindow : EmbeddedWindow
|
|
|
|
{
|
|
|
|
private NativeWindowBase _window;
|
|
|
|
|
2022-11-26 12:06:53 +01: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 20:05:26 +02:00
|
|
|
public SurfaceKHR CreateSurface(Instance instance)
|
|
|
|
{
|
|
|
|
if (OperatingSystem.IsWindows())
|
|
|
|
{
|
|
|
|
_window = new SimpleWin32Window(new NativeHandle(WindowHandle));
|
|
|
|
}
|
|
|
|
else if (OperatingSystem.IsLinux())
|
|
|
|
{
|
2022-11-25 18:40:44 +01:00
|
|
|
_window = new SimpleX11Window(new NativeHandle(X11Display), new NativeHandle(WindowHandle));
|
2022-09-19 20:05:26 +02:00
|
|
|
}
|
2022-12-06 23:00:25 +01:00
|
|
|
else if (OperatingSystem.IsMacOS())
|
|
|
|
{
|
|
|
|
_window = new SimpleMetalWindow(new NativeHandle(NsView), new NativeHandle(MetalLayer));
|
|
|
|
}
|
2022-09-19 20:05:26 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new PlatformNotSupportedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
return new SurfaceKHR((ulong?)VulkanHelper.CreateWindowSurface(instance.Handle, _window));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|