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