mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-21 16:43:35 +00:00
Copy query results after RP ends, rather than ending to copy
We need to end the render pass to get the data (submit command buffer) anyways... Reduces render passes created in games that use queries.
This commit is contained in:
parent
af4aae7951
commit
eda65c8dd3
2 changed files with 34 additions and 13 deletions
|
@ -1148,10 +1148,15 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
PauseTransformFeedbackInternal();
|
||||
// System.Console.WriteLine("render pass ended " + caller);
|
||||
Gd.Api.CmdEndRenderPass(CommandBuffer);
|
||||
SignalRenderPassEnd();
|
||||
_renderPassActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void SignalRenderPassEnd()
|
||||
{
|
||||
}
|
||||
|
||||
private void PauseTransformFeedbackInternal()
|
||||
{
|
||||
if (_tfEnabled && _tfActive)
|
||||
|
|
|
@ -13,13 +13,36 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
private readonly List<QueryPool> _activeQueries;
|
||||
private CounterQueueEvent _activeConditionalRender;
|
||||
|
||||
private readonly List<(QueryPool Pool, BufferHolder Holder)> _pendingQueryCopies;
|
||||
|
||||
public PipelineFull(VulkanGraphicsDevice gd, Device device) : base(gd, device)
|
||||
{
|
||||
_activeQueries = new List<QueryPool>();
|
||||
_pendingQueryCopies = new();
|
||||
|
||||
CommandBuffer = (Cbs = gd.CommandBufferPool.Rent()).CommandBuffer;
|
||||
}
|
||||
|
||||
private void CopyPendingQuery()
|
||||
{
|
||||
foreach (var item in _pendingQueryCopies)
|
||||
{
|
||||
var buffer = item.Holder.GetBuffer(CommandBuffer, true).Get(Cbs, 0, sizeof(long)).Value;
|
||||
|
||||
Gd.Api.CmdCopyQueryPoolResults(
|
||||
CommandBuffer,
|
||||
item.Pool,
|
||||
0,
|
||||
1,
|
||||
buffer,
|
||||
0,
|
||||
sizeof(long),
|
||||
QueryResultFlags.QueryResult64Bit | QueryResultFlags.QueryResultWaitBit);
|
||||
}
|
||||
|
||||
_pendingQueryCopies.Clear();
|
||||
}
|
||||
|
||||
protected override unsafe DescriptorSetLayout[] CreateDescriptorSetLayouts(VulkanGraphicsDevice gd, Device device, out PipelineLayout layout)
|
||||
{
|
||||
DescriptorSetLayoutBinding* uLayoutBindings = stackalloc DescriptorSetLayoutBinding[Constants.MaxUniformBufferBindings];
|
||||
|
@ -298,19 +321,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
public void CopyQueryResults(QueryPool pool, BufferHolder holder)
|
||||
{
|
||||
EndRenderPass();
|
||||
|
||||
var buffer = holder.GetBuffer(CommandBuffer, true).Get(Cbs, 0, sizeof(long)).Value;
|
||||
|
||||
Gd.Api.CmdCopyQueryPoolResults(
|
||||
CommandBuffer,
|
||||
pool,
|
||||
0,
|
||||
1,
|
||||
buffer,
|
||||
0,
|
||||
sizeof(long),
|
||||
QueryResultFlags.QueryResult64Bit | QueryResultFlags.QueryResultWaitBit);
|
||||
_pendingQueryCopies.Add((pool, holder));
|
||||
|
||||
_hasPendingQuery = true;
|
||||
}
|
||||
|
@ -319,5 +330,10 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
{
|
||||
FlushPendingQuery();
|
||||
}
|
||||
|
||||
protected override void SignalRenderPassEnd()
|
||||
{
|
||||
CopyPendingQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue