Use aspects flags in more places

This commit is contained in:
riperiperi 2024-09-01 19:20:50 +01:00
parent bd0737ba51
commit 24a49ea574
4 changed files with 28 additions and 33 deletions

View file

@ -0,0 +1,12 @@
using System;
namespace Ryujinx.Graphics.Vulkan
{
[Flags]
internal enum FeedbackLoopAspects
{
None = 0,
Color = 1 << 0,
Depth = 1 << 1,
}
}

View file

@ -87,13 +87,6 @@ namespace Ryujinx.Graphics.Vulkan
private bool _tfEnabled;
private bool _tfActive;
[Flags]
private enum FeedbackLoopAspects
{
Color = 1 << 0,
Depth = 1 << 1,
};
private FeedbackLoopAspects _feedbackLoop;
private bool _passWritesDepthStencil;
@ -1453,8 +1446,7 @@ namespace Ryujinx.Graphics.Vulkan
{
FramebufferParams.AddBindings();
_newState.FeedbackLoopColor = false;
_newState.FeedbackLoopDepth = false;
_newState.FeedbackLoopAspects = FeedbackLoopAspects.None;
_bindingBarriersDirty = true;
}
@ -1537,14 +1529,11 @@ namespace Ryujinx.Graphics.Vulkan
{
if (Gd.Capabilities.SupportsDynamicAttachmentFeedbackLoop)
{
DynamicState.SetFeedbackLoop(
(aspects & FeedbackLoopAspects.Color) != 0,
(aspects & FeedbackLoopAspects.Depth) != 0);
DynamicState.SetFeedbackLoop(aspects);
}
else
{
_newState.FeedbackLoopColor = (aspects & FeedbackLoopAspects.Color) != 0;
_newState.FeedbackLoopDepth = (aspects & FeedbackLoopAspects.Depth) != 0;
_newState.FeedbackLoopAspects = aspects;
}
_feedbackLoop = aspects;
@ -1588,7 +1577,7 @@ namespace Ryujinx.Graphics.Vulkan
}
else if (_feedbackLoop != 0)
{
return ChangeFeedbackLoop(0);
return ChangeFeedbackLoop(FeedbackLoopAspects.None);
}
return false;

View file

@ -22,8 +22,7 @@ namespace Ryujinx.Graphics.Vulkan
private Array4<float> _blendConstants;
private bool _feedbackLoopColor;
private bool _feedbackLoopDepth;
private FeedbackLoopAspects _feedbackLoopAspects;
public uint ViewportsCount;
public Array16<Viewport> Viewports;
@ -104,10 +103,9 @@ namespace Ryujinx.Graphics.Vulkan
}
}
public void SetFeedbackLoop(bool color, bool depth)
public void SetFeedbackLoop(FeedbackLoopAspects aspects)
{
_feedbackLoopColor = color;
_feedbackLoopDepth = depth;
_feedbackLoopAspects = aspects;
_dirty |= DirtyFlags.FeedbackLoop;
}
@ -192,9 +190,9 @@ namespace Ryujinx.Graphics.Vulkan
private readonly void RecordFeedbackLoop(ExtAttachmentFeedbackLoopDynamicState api, CommandBuffer commandBuffer)
{
ImageAspectFlags aspects = _feedbackLoopColor ? ImageAspectFlags.ColorBit : 0;
ImageAspectFlags aspects = (_feedbackLoopAspects & FeedbackLoopAspects.Color) != 0 ? ImageAspectFlags.ColorBit : 0;
if (_feedbackLoopDepth)
if ((_feedbackLoopAspects & FeedbackLoopAspects.Depth) != 0)
{
aspects |= ImageAspectFlags.DepthBit | ImageAspectFlags.StencilBit;
}

View file

@ -300,16 +300,10 @@ namespace Ryujinx.Graphics.Vulkan
set => Internal.Id8 = (Internal.Id8 & 0xFFFFFFFFFFFFFFBF) | ((value ? 1UL : 0UL) << 6);
}
public bool FeedbackLoopColor
public FeedbackLoopAspects FeedbackLoopAspects
{
readonly get => ((Internal.Id8 >> 7) & 0x1) != 0UL;
set => Internal.Id8 = (Internal.Id8 & 0xFFFFFFFFFFFFFF7F) | ((value ? 1UL : 0UL) << 7);
}
public bool FeedbackLoopDepth
{
readonly get => ((Internal.Id8 >> 8) & 0x1) != 0UL;
set => Internal.Id8 = (Internal.Id8 & 0xFFFFFFFFFFFFFEFF) | ((value ? 1UL : 0UL) << 8);
readonly get => (FeedbackLoopAspects)((Internal.Id8 >> 7) & 0x3);
set => Internal.Id8 = (Internal.Id8 & 0xFFFFFFFFFFFFFE7F) | (((ulong)value) << 7);
}
public bool HasTessellationControlShader;
@ -612,12 +606,14 @@ namespace Ryujinx.Graphics.Vulkan
if (gd.Capabilities.SupportsAttachmentFeedbackLoop)
{
if (FeedbackLoopColor)
FeedbackLoopAspects aspects = FeedbackLoopAspects;
if ((aspects & FeedbackLoopAspects.Color) != 0)
{
flags |= PipelineCreateFlags.CreateColorAttachmentFeedbackLoopBitExt;
}
if (FeedbackLoopDepth)
if ((aspects & FeedbackLoopAspects.Depth) != 0)
{
flags |= PipelineCreateFlags.CreateDepthStencilAttachmentFeedbackLoopBitExt;
}