Address Feedback
This commit is contained in:
parent
d7089682ae
commit
f085b47b30
2 changed files with 65 additions and 103 deletions
|
@ -2,6 +2,7 @@ using Ryujinx.Common.Memory;
|
||||||
using Silk.NET.Vulkan;
|
using Silk.NET.Vulkan;
|
||||||
using Silk.NET.Vulkan.Extensions.EXT;
|
using Silk.NET.Vulkan.Extensions.EXT;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Vulkan
|
namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
|
@ -81,7 +82,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
PrimitiveRestart = 1 << 15,
|
PrimitiveRestart = 1 << 15,
|
||||||
PrimitiveTopology = 1 << 16,
|
PrimitiveTopology = 1 << 16,
|
||||||
DepthBiasEnable = 1 << 17,
|
DepthBiasEnable = 1 << 17,
|
||||||
Standard = Blend | DepthBias | Scissor | Stencil | Viewport | FeedbackLoop,
|
Standard = Blend | DepthBias | Scissor | Stencil | Viewport,
|
||||||
Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnableAndStencilOp | PrimitiveTopology,
|
Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnableAndStencilOp | PrimitiveTopology,
|
||||||
Extended2 = RasterDiscard | PrimitiveRestart | DepthBiasEnable,
|
Extended2 = RasterDiscard | PrimitiveRestart | DepthBiasEnable,
|
||||||
}
|
}
|
||||||
|
@ -265,12 +266,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
if (gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2)
|
if (gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2)
|
||||||
{
|
{
|
||||||
_dirty |= DirtyFlags.Extended2;
|
_dirty |= DirtyFlags.Extended2;
|
||||||
}
|
|
||||||
|
|
||||||
if (!gd.IsMoltenVk)
|
|
||||||
{
|
|
||||||
_dirty |= DirtyFlags.LineWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp)
|
if (gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp)
|
||||||
{
|
{
|
||||||
|
@ -283,96 +278,63 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!gd.IsMoltenVk)
|
||||||
|
{
|
||||||
|
_dirty |= DirtyFlags.LineWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gd.Capabilities.SupportsDynamicAttachmentFeedbackLoop)
|
||||||
|
{
|
||||||
|
_dirty |= DirtyFlags.FeedbackLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ReplayIfDirty(VulkanRenderer gd, CommandBuffer commandBuffer)
|
public void ReplayIfDirty(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
if (_dirty.HasFlag(DirtyFlags.Blend))
|
if (_dirty == DirtyFlags.None)
|
||||||
{
|
{
|
||||||
RecordBlend(gd.Api, commandBuffer);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.DepthBias))
|
var api = gd.Api;
|
||||||
{
|
var extendedStateApi = gd.ExtendedDynamicStateApi;
|
||||||
RecordDepthBias(gd, commandBuffer);
|
var extendedState2Api = gd.ExtendedDynamicState2Api;
|
||||||
}
|
var dynamicFeedbackLoopApi = gd.DynamicFeedbackLoopApi;
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.Scissor))
|
PipelineDynamicState state = this;
|
||||||
{
|
|
||||||
RecordScissor(gd, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.Stencil))
|
Action[] actions = new Action[]
|
||||||
{
|
{
|
||||||
RecordStencil(gd, commandBuffer);
|
() => state.RecordBlend(api, commandBuffer),
|
||||||
}
|
() => state.RecordDepthBias(api, commandBuffer),
|
||||||
|
() => state.RecordScissor(gd, commandBuffer),
|
||||||
|
() => state.RecordStencil(api, commandBuffer),
|
||||||
|
() => state.RecordViewport(gd, commandBuffer),
|
||||||
|
() => state.RecordFeedbackLoop(dynamicFeedbackLoopApi, commandBuffer),
|
||||||
|
() => state.RecordCullMode(extendedStateApi, commandBuffer),
|
||||||
|
() => state.RecordFrontFace(extendedStateApi, commandBuffer),
|
||||||
|
() => state.RecordDepthTestBool(extendedStateApi, commandBuffer),
|
||||||
|
() => state.RecordDepthTestCompareOp(extendedStateApi, commandBuffer),
|
||||||
|
() => state.RecordStencilTestAndOp(extendedStateApi, commandBuffer),
|
||||||
|
() => state.RecordLineWidth(api, commandBuffer),
|
||||||
|
() => state.RecordRasterizationDiscard(extendedState2Api, commandBuffer),
|
||||||
|
() => state.RecordLogicOp(extendedState2Api, commandBuffer),
|
||||||
|
() => state.RecordPatchControlPoints(extendedState2Api, commandBuffer),
|
||||||
|
() => state.RecordPrimitiveRestartEnable(gd, commandBuffer),
|
||||||
|
() => state.RecordPrimitiveTopology(extendedStateApi, commandBuffer),
|
||||||
|
() => state.RecordDepthBiasEnable(extendedState2Api, commandBuffer),
|
||||||
|
};
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.Viewport))
|
DirtyFlags dirtyFlags = _dirty;
|
||||||
{
|
|
||||||
RecordViewport(gd, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.CullMode))
|
while (dirtyFlags != DirtyFlags.None)
|
||||||
{
|
{
|
||||||
RecordCullMode(gd.ExtendedDynamicStateApi, commandBuffer);
|
int bitIndex = BitOperations.TrailingZeroCount((uint)dirtyFlags);
|
||||||
}
|
DirtyFlags currentFlag = (DirtyFlags)(1 << bitIndex);
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.FrontFace))
|
actions[bitIndex]();
|
||||||
{
|
|
||||||
RecordFrontFace(gd.ExtendedDynamicStateApi, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.DepthTestBool))
|
dirtyFlags &= ~currentFlag;
|
||||||
{
|
|
||||||
RecordDepthTestBool(gd.ExtendedDynamicStateApi, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.DepthBiasEnable))
|
|
||||||
{
|
|
||||||
RecordDepthBiasEnable(gd.ExtendedDynamicState2Api, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.DepthTestCompareOp))
|
|
||||||
{
|
|
||||||
RecordDepthTestCompareOp(gd.ExtendedDynamicStateApi, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.StencilTestEnableAndStencilOp))
|
|
||||||
{
|
|
||||||
RecordStencilTestAndOp(gd.ExtendedDynamicStateApi, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.LineWidth))
|
|
||||||
{
|
|
||||||
RecordLineWidth(gd.Api, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.RasterDiscard))
|
|
||||||
{
|
|
||||||
RecordRasterizationDiscard(gd, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.PrimitiveRestart))
|
|
||||||
{
|
|
||||||
RecordPrimitiveRestartEnable(gd, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.PrimitiveTopology))
|
|
||||||
{
|
|
||||||
RecordPrimitiveTopology(gd, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.LogicOp))
|
|
||||||
{
|
|
||||||
RecordLogicOp(gd, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.PatchControlPoints))
|
|
||||||
{
|
|
||||||
RecordPatchControlPoints(gd, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.FeedbackLoop) && gd.Capabilities.SupportsDynamicAttachmentFeedbackLoop)
|
|
||||||
{
|
|
||||||
RecordFeedbackLoop(gd.DynamicFeedbackLoopApi, commandBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_dirty = DirtyFlags.None;
|
_dirty = DirtyFlags.None;
|
||||||
|
@ -383,9 +345,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
api.CmdSetBlendConstants(commandBuffer, _blendConstants.AsSpan());
|
api.CmdSetBlendConstants(commandBuffer, _blendConstants.AsSpan());
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordDepthBias(VulkanRenderer gd, CommandBuffer commandBuffer)
|
private readonly void RecordDepthBias(Vk api, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
gd.Api.CmdSetDepthBias(commandBuffer, _depthBiasConstantFactor, _depthBiasClamp, _depthBiasSlopeFactor);
|
api.CmdSetDepthBias(commandBuffer, _depthBiasConstantFactor, _depthBiasClamp, _depthBiasSlopeFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordDepthBiasEnable(ExtExtendedDynamicState2 gd, CommandBuffer commandBuffer)
|
private readonly void RecordDepthBiasEnable(ExtExtendedDynamicState2 gd, CommandBuffer commandBuffer)
|
||||||
|
@ -411,14 +373,14 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordStencil(VulkanRenderer gd, CommandBuffer commandBuffer)
|
private readonly void RecordStencil(Vk api, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
gd.Api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backCompareMask);
|
api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backCompareMask);
|
||||||
gd.Api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backWriteMask);
|
api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backWriteMask);
|
||||||
gd.Api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceBackBit, _backReference);
|
api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceBackBit, _backReference);
|
||||||
gd.Api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontCompareMask);
|
api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontCompareMask);
|
||||||
gd.Api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontWriteMask);
|
api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontWriteMask);
|
||||||
gd.Api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontReference);
|
api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordStencilTestAndOp(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
|
private readonly void RecordStencilTestAndOp(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
|
||||||
|
@ -472,9 +434,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
api.CmdSetDepthCompareOp(commandBuffer, _depthCompareOp);
|
api.CmdSetDepthCompareOp(commandBuffer, _depthCompareOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordRasterizationDiscard(VulkanRenderer gd, CommandBuffer commandBuffer)
|
private readonly void RecordRasterizationDiscard(ExtExtendedDynamicState2 extendedDynamicState2Api, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
gd.ExtendedDynamicState2Api.CmdSetRasterizerDiscardEnable(commandBuffer, _discard);
|
extendedDynamicState2Api.CmdSetRasterizerDiscardEnable(commandBuffer, _discard);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordPrimitiveRestartEnable(VulkanRenderer gd, CommandBuffer commandBuffer)
|
private readonly void RecordPrimitiveRestartEnable(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||||
|
@ -508,19 +470,19 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
gd.ExtendedDynamicState2Api.CmdSetPrimitiveRestartEnable(commandBuffer, primitiveRestartEnable);
|
gd.ExtendedDynamicState2Api.CmdSetPrimitiveRestartEnable(commandBuffer, primitiveRestartEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordPrimitiveTopology(VulkanRenderer gd, CommandBuffer commandBuffer)
|
private readonly void RecordPrimitiveTopology(ExtExtendedDynamicState extendedDynamicStateApi, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
gd.ExtendedDynamicStateApi.CmdSetPrimitiveTopology(commandBuffer, Topology);
|
extendedDynamicStateApi.CmdSetPrimitiveTopology(commandBuffer, Topology);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordLogicOp(VulkanRenderer gd, CommandBuffer commandBuffer)
|
private readonly void RecordLogicOp(ExtExtendedDynamicState2 extendedDynamicState2Api, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
gd.ExtendedDynamicState2Api.CmdSetLogicOp(commandBuffer, _logicOp);
|
extendedDynamicState2Api.CmdSetLogicOp(commandBuffer, _logicOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordPatchControlPoints(VulkanRenderer gd, CommandBuffer commandBuffer)
|
private readonly void RecordPatchControlPoints(ExtExtendedDynamicState2 extendedDynamicState2Api, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
gd.ExtendedDynamicState2Api.CmdSetPatchControlPoints(commandBuffer, _patchControlPoints);
|
extendedDynamicState2Api.CmdSetPatchControlPoints(commandBuffer, _patchControlPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordLineWidth(Vk api, CommandBuffer commandBuffer)
|
private readonly void RecordLineWidth(Vk api, CommandBuffer commandBuffer)
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
public bool Equals(ref PipelineUid other)
|
public bool Equals(ref PipelineUid other)
|
||||||
{
|
{
|
||||||
if (!Unsafe.As<ulong, Vector128<byte>>(ref Id2).Equals(Unsafe.As<ulong, Vector128<byte>>(ref other.Id2)))
|
if (!Unsafe.As<ulong, Vector256<byte>>(ref Id0).Equals(Unsafe.As<ulong, Vector256<byte>>(ref other.Id0)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue