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