aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Ui/Backend/SkiaGpuFactory.cs
blob: 335bc905f5343b5b97883ebac3b823da2804f174 (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
using Avalonia;
using Avalonia.Skia;
using Ryujinx.Ava.Ui.Vulkan;
using Ryujinx.Ava.Ui.Backend.Vulkan;

namespace Ryujinx.Ava.Ui.Backend
{
    public static class SkiaGpuFactory
    {
        public static ISkiaGpu CreateVulkanGpu()
        {
            var skiaOptions = AvaloniaLocator.Current.GetService<SkiaOptions>() ?? new SkiaOptions();
            var platformInterface = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();

            if (platformInterface == null)
            {
                VulkanPlatformInterface.TryInitialize();
            }

            var gpu = new VulkanSkiaGpu(skiaOptions.MaxGpuResourceSizeBytes);
            AvaloniaLocator.CurrentMutable.Bind<VulkanSkiaGpu>().ToConstant(gpu);

            return gpu;
        }
    }
}