aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Ui/Backend/Vulkan/VulkanSemaphorePair.cs
blob: 3b5fd9cc6b8c4667570c0e92c530e5d4de3602ec (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
using System;
using Silk.NET.Vulkan;

namespace Ryujinx.Ava.Ui.Vulkan
{
    internal class VulkanSemaphorePair : IDisposable
    {
        private readonly VulkanDevice _device;

        public unsafe VulkanSemaphorePair(VulkanDevice device)
        {
            _device = device;

            var semaphoreCreateInfo = new SemaphoreCreateInfo { SType = StructureType.SemaphoreCreateInfo };

            _device.Api.CreateSemaphore(_device.InternalHandle, semaphoreCreateInfo, null, out var semaphore).ThrowOnError();
            ImageAvailableSemaphore = semaphore;

            _device.Api.CreateSemaphore(_device.InternalHandle, semaphoreCreateInfo, null, out semaphore).ThrowOnError();
            RenderFinishedSemaphore = semaphore;
        }

        internal Semaphore ImageAvailableSemaphore { get; }
        internal Semaphore RenderFinishedSemaphore { get; }

        public unsafe void Dispose()
        {
            _device.Api.DestroySemaphore(_device.InternalHandle, ImageAvailableSemaphore, null);
            _device.Api.DestroySemaphore(_device.InternalHandle, RenderFinishedSemaphore, null);
        }
    }
}