mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-23 17:40:19 +00:00
* add avalonia support * only lock around skia flush * addressed review * cleanup * add fallback size if avalonia attempts to render but the window size is 0. read desktop scale after enabling dpi check * fix getting window handle on linux. skip render is size is 0
67 lines
1.7 KiB
C#
67 lines
1.7 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);
|
|
|
|
var vulkanQueue = new VulkanQueue(this, queue);
|
|
Queue = vulkanQueue;
|
|
|
|
PresentQueue = vulkanQueue;
|
|
|
|
CommandBufferPool = new VulkanCommandBufferPool(this, physicalDevice);
|
|
}
|
|
|
|
public IntPtr Handle => InternalHandle.Handle;
|
|
|
|
internal Device InternalHandle { get; }
|
|
public Vk Api { get; }
|
|
|
|
public VulkanQueue Queue { get; private set; }
|
|
public VulkanQueue PresentQueue { get; }
|
|
public VulkanCommandBufferPool CommandBufferPool { get; }
|
|
|
|
public void Dispose()
|
|
{
|
|
WaitIdle();
|
|
CommandBufferPool?.Dispose();
|
|
Queue = null;
|
|
}
|
|
|
|
internal void Submit(SubmitInfo submitInfo, Fence fence = new())
|
|
{
|
|
lock (_lock)
|
|
{
|
|
Api.QueueSubmit(Queue.InternalHandle, 1, submitInfo, fence);
|
|
}
|
|
}
|
|
|
|
public void WaitIdle()
|
|
{
|
|
lock (_lock)
|
|
{
|
|
Api.DeviceWaitIdle(InternalHandle);
|
|
}
|
|
}
|
|
|
|
public void QueueWaitIdle()
|
|
{
|
|
lock (_lock)
|
|
{
|
|
Api.QueueWaitIdle(Queue.InternalHandle);
|
|
}
|
|
}
|
|
|
|
public object Lock => _lock;
|
|
}
|
|
}
|