aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx/UI/Renderer/EmbeddedWindowVulkan.cs
blob: fafbec20745c16cf34c130ab462d9a7964a8b89b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Silk.NET.Vulkan;
using SPB.Graphics.Vulkan;
using SPB.Platform.Metal;
using SPB.Platform.Win32;
using SPB.Platform.X11;
using SPB.Windowing;
using System;

namespace Ryujinx.Ava.UI.Renderer
{
    public class EmbeddedWindowVulkan : EmbeddedWindow
    {
        public SurfaceKHR CreateSurface(Instance instance)
        {
            NativeWindowBase nativeWindowBase;

            if (OperatingSystem.IsWindows())
            {
                nativeWindowBase = new SimpleWin32Window(new NativeHandle(WindowHandle));
            }
            else if (OperatingSystem.IsLinux())
            {
                nativeWindowBase = new SimpleX11Window(new NativeHandle(X11Display), new NativeHandle(WindowHandle));
            }
            else if (OperatingSystem.IsMacOS())
            {
                nativeWindowBase = new SimpleMetalWindow(new NativeHandle(NsView), new NativeHandle(MetalLayer));
            }
            else
            {
                throw new PlatformNotSupportedException();
            }

            return new SurfaceKHR((ulong?)VulkanHelper.CreateWindowSurface(instance.Handle, nativeWindowBase));
        }

        public SurfaceKHR CreateSurface(Instance instance, Vk _)
        {
            return CreateSurface(instance);
        }
    }
}