mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-21 16:43:35 +00:00
Add single queue support
Multiqueue seems to be a bit more responsive on NVIDIA. Should fix texture flush on intel. AMD has been forced to single queue for an experiment.
This commit is contained in:
parent
dc0d0f49b1
commit
4d94b03622
7 changed files with 31 additions and 43 deletions
|
@ -23,7 +23,14 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
{
|
||||
if (_pool == null)
|
||||
{
|
||||
_pool = new CommandBufferPool(_gd.Api, _device, _gd.BackgroundQueue, _gd.QueueFamilyIndex, isLight: true);
|
||||
bool useBackground = _gd.BackgroundQueue.Handle != 0 && _gd.Vendor != Vendor.Amd;
|
||||
Queue queue = useBackground ? _gd.BackgroundQueue : _gd.Queue;
|
||||
object queueLock = useBackground ? _gd.BackgroundQueueLock : _gd.QueueLock;
|
||||
|
||||
lock (queueLock)
|
||||
{
|
||||
_pool = new CommandBufferPool(_gd.Api, _device, queue, queueLock, _gd.QueueFamilyIndex, isLight: true);
|
||||
}
|
||||
}
|
||||
|
||||
return _pool;
|
||||
|
|
|
@ -143,16 +143,9 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
return resource.GetFlushBuffer().GetBufferData(_gd.CommandBufferPool, this, offset, size);
|
||||
}
|
||||
else if (_gd.BackgroundQueue.Handle != 0)
|
||||
{
|
||||
lock (_gd.BackgroundQueueLock)
|
||||
{
|
||||
return resource.GetFlushBuffer().GetBufferData(resource.GetPool(), this, offset, size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new byte[size];
|
||||
return resource.GetFlushBuffer().GetBufferData(resource.GetPool(), this, offset, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
private readonly Vk _api;
|
||||
private readonly Device _device;
|
||||
private readonly Queue _queue;
|
||||
private readonly object _queueLock;
|
||||
private readonly CommandPool _pool;
|
||||
private readonly Thread _owner;
|
||||
|
||||
|
@ -58,11 +59,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
private int _cursor;
|
||||
|
||||
public unsafe CommandBufferPool(Vk api, Device device, Queue queue, uint queueFamilyIndex, bool isLight = false)
|
||||
public unsafe CommandBufferPool(Vk api, Device device, Queue queue, object queueLock, uint queueFamilyIndex, bool isLight = false)
|
||||
{
|
||||
_api = api;
|
||||
_device = device;
|
||||
_queue = queue;
|
||||
_queueLock = queueLock;
|
||||
_owner = Thread.CurrentThread;
|
||||
|
||||
var commandPoolCreateInfo = new CommandPoolCreateInfo()
|
||||
|
@ -272,9 +274,12 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
PSignalSemaphores = pSignalSemaphores
|
||||
};
|
||||
|
||||
lock (_queueLock)
|
||||
{
|
||||
_api.QueueSubmit(_queue, 1, sInfo, entry.Fence.GetUnsafe());
|
||||
}
|
||||
}
|
||||
}
|
||||
// _api.QueueWaitIdle(_queue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,9 +233,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
CopyToImpl(cbs, dst, srcRegion, dstRegion, linearFilter);
|
||||
}
|
||||
else if (_gd.BackgroundQueue.Handle != 0)
|
||||
{
|
||||
lock (_gd.BackgroundQueueLock)
|
||||
else
|
||||
{
|
||||
var cbp = _gd.BackgroundResources.Get().GetPool();
|
||||
|
||||
|
@ -244,11 +242,6 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
CopyToImpl(cbs, dst, srcRegion, dstRegion, linearFilter);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO...
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyToImpl(CommandBufferScoped cbs, TextureView dst, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter)
|
||||
{
|
||||
|
@ -678,24 +671,9 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
return GetData(_gd.CommandBufferPool, resources.GetFlushBuffer());
|
||||
}
|
||||
else if (_gd.BackgroundQueue.Handle != 0)
|
||||
{
|
||||
lock (_gd.BackgroundQueueLock)
|
||||
{
|
||||
return GetData(resources.GetPool(), resources.GetFlushBuffer());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Flush when the device only supports one queue.
|
||||
int size = 0;
|
||||
|
||||
for (int level = 0; level < Info.Levels; level++)
|
||||
{
|
||||
size += Info.GetMipSize(level);
|
||||
}
|
||||
|
||||
return new byte[size];
|
||||
return GetData(resources.GetPool(), resources.GetFlushBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
internal Queue Queue { get; private set; }
|
||||
internal Queue BackgroundQueue { get; private set; }
|
||||
internal object BackgroundQueueLock { get; private set; }
|
||||
internal object QueueLock { get; private set; }
|
||||
|
||||
internal MemoryAllocator MemoryAllocator { get; private set; }
|
||||
internal CommandBufferPool CommandBufferPool { get; private set; }
|
||||
|
@ -153,6 +154,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
api.GetDeviceQueue(_device, queueFamilyIndex, 0, out var queue);
|
||||
Queue = queue;
|
||||
QueueLock = new object();
|
||||
|
||||
if (maxQueueCount >= 2)
|
||||
{
|
||||
|
@ -165,7 +167,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
MemoryAllocator = new MemoryAllocator(api, _device, properties.Limits.MaxMemoryAllocationCount);
|
||||
|
||||
CommandBufferPool = VulkanInitialization.CreateCommandBufferPool(api, _device, queue, queueFamilyIndex);
|
||||
CommandBufferPool = VulkanInitialization.CreateCommandBufferPool(api, _device, queue, QueueLock, queueFamilyIndex);
|
||||
|
||||
DescriptorSetManager = new DescriptorSetManager(_device);
|
||||
|
||||
|
|
|
@ -418,9 +418,9 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
return extensionProperties.Select(x => Marshal.PtrToStringAnsi((IntPtr)x.ExtensionName)).ToArray();
|
||||
}
|
||||
|
||||
public static CommandBufferPool CreateCommandBufferPool(Vk api, Device device, Queue queue, uint queueFamilyIndex)
|
||||
public static CommandBufferPool CreateCommandBufferPool(Vk api, Device device, Queue queue, object queueLock, uint queueFamilyIndex)
|
||||
{
|
||||
return new CommandBufferPool(api, device, queue, queueFamilyIndex);
|
||||
return new CommandBufferPool(api, device, queue, queueLock, queueFamilyIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -352,8 +352,11 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
PResults = &result
|
||||
};
|
||||
|
||||
lock (_gd.QueueLock)
|
||||
{
|
||||
_gd.SwapchainApi.QueuePresent(_gd.Queue, presentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void Transition(
|
||||
CommandBuffer commandBuffer,
|
||||
|
|
Loading…
Reference in a new issue