Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Flush queries on attachment change rather than program change
Browse files Browse the repository at this point in the history
Occlusion queries are usually used in a depth only pass so the attachments changing is a better indication of the query block ending.

Write mask changes are also considered since some games do depth only pass by setting 0 write mask on all the colour targets.
  • Loading branch information
riperiperi authored and gdkchan committed Jul 10, 2022
1 parent c3257bd commit 3e5b1c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions Ryujinx.Graphics.Vulkan/PipelineBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class PipelineBase : IDisposable
protected FramebufferParams FramebufferParams;
private Auto<DisposableFramebuffer> _framebuffer;
private Auto<DisposableRenderPass> _renderPass;
private int _writtenAttachmentCount;
private bool _renderPassActive;

private readonly DescriptorSetUpdater _descriptorSetUpdater;
Expand Down Expand Up @@ -605,10 +606,9 @@ public void SetProgram(IProgram program)
stages.CopyTo(_newState.Stages.ToSpan().Slice(0, stages.Length));

SignalStateChange();
SignalProgramChange();
}

protected virtual void SignalProgramChange()
protected virtual void SignalAttachmentChange()
{
}

Expand All @@ -621,15 +621,27 @@ public void SetRasterizerDiscard(bool discard)
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask)
{
int count = Math.Min(Constants.MaxRenderTargets, componentMask.Length);
int writtenAttachments = 0;

for (int i = 0; i < count; i++)
{
ref var vkBlend = ref _newState.Internal.ColorBlendAttachmentState[i];

vkBlend.ColorWriteMask = (ColorComponentFlags)componentMask[i];

if (componentMask[i] != 0)
{
writtenAttachments++;
}
}

SignalStateChange();

if (writtenAttachments != _writtenAttachmentCount)
{
SignalAttachmentChange();
_writtenAttachmentCount = writtenAttachments;
}
}

public void SetRenderTargets(ITexture[] colors, ITexture depthStencil)
Expand All @@ -638,6 +650,7 @@ public void SetRenderTargets(ITexture[] colors, ITexture depthStencil)
CreateFramebuffer(colors, depthStencil);
CreateRenderPass();
SignalStateChange();
SignalAttachmentChange();
}

public void SetRenderTargetScale(float scale)
Expand Down
2 changes: 1 addition & 1 deletion Ryujinx.Graphics.Vulkan/PipelineFull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public void CopyQueryResults(BufferedQuery query)
_hasPendingQuery = true;
}

protected override void SignalProgramChange()
protected override void SignalAttachmentChange()
{
FlushPendingQuery();
}
Expand Down

0 comments on commit 3e5b1c4

Please sign in to comment.