blob: b03fd72040bedfc5baa011bbcbb8e482e6ccf822 (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
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 = 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;
}
}
|