mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-15 17:45:26 +00:00
c8f9292bab
* drop split devices, rebase * add fallback to opengl if vulkan is not available * addressed review * ensure present image references are incremented and decremented when necessary * allow changing vsync for vulkan * fix screenshot on avalonia vulkan * save favorite when toggled * improve sync between popups * use separate devices for each new window * fix crash when closing window * addressed review * don't create the main window with immediate mode * change skia vk delegate to method * update vulkan throwonerror * addressed review
64 lines
1.5 KiB
C#
64 lines
1.5 KiB
C#
using System;
|
|
using Silk.NET.Vulkan;
|
|
|
|
namespace Ryujinx.Ava.Ui.Vulkan
|
|
{
|
|
internal class VulkanDevice : IDisposable
|
|
{
|
|
private static object _lock = new object();
|
|
|
|
public VulkanDevice(Device apiHandle, VulkanPhysicalDevice physicalDevice, Vk api)
|
|
{
|
|
InternalHandle = apiHandle;
|
|
Api = api;
|
|
|
|
api.GetDeviceQueue(apiHandle, physicalDevice.QueueFamilyIndex, 0, out var queue);
|
|
|
|
Queue = new VulkanQueue(this, queue);
|
|
|
|
PresentQueue = Queue;
|
|
}
|
|
|
|
public IntPtr Handle => InternalHandle.Handle;
|
|
|
|
internal Device InternalHandle { get; }
|
|
public Vk Api { get; }
|
|
|
|
public VulkanQueue Queue { get; private set; }
|
|
public VulkanQueue PresentQueue { get; }
|
|
|
|
public void Dispose()
|
|
{
|
|
WaitIdle();
|
|
Queue = null;
|
|
Api.DestroyDevice(InternalHandle, Span<AllocationCallbacks>.Empty);
|
|
}
|
|
|
|
internal void Submit(SubmitInfo submitInfo, Fence fence = default)
|
|
{
|
|
lock (_lock)
|
|
{
|
|
Api.QueueSubmit(Queue.InternalHandle, 1, submitInfo, fence).ThrowOnError();
|
|
}
|
|
}
|
|
|
|
public void WaitIdle()
|
|
{
|
|
lock (_lock)
|
|
{
|
|
Api.DeviceWaitIdle(InternalHandle);
|
|
}
|
|
}
|
|
|
|
public void QueueWaitIdle()
|
|
{
|
|
lock (_lock)
|
|
{
|
|
Api.QueueWaitIdle(Queue.InternalHandle);
|
|
}
|
|
}
|
|
|
|
public object Lock => _lock;
|
|
}
|
|
}
|