1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-18 12:16:39 +00:00

Clean up for some clarity and attempt to resolve some validation errors.

This commit is contained in:
sunshineinabox 2024-06-02 21:00:18 -07:00
parent 966c5d463c
commit 266649929f
2 changed files with 28 additions and 30 deletions

View file

@ -697,7 +697,7 @@ namespace Ryujinx.Graphics.Vulkan
var oldStencilTestEnable = _supportExtDynamic ? DynamicState.StencilTestEnable : _newState.StencilTestEnable; var oldStencilTestEnable = _supportExtDynamic ? DynamicState.StencilTestEnable : _newState.StencilTestEnable;
var oldDepthTestEnable = _supportExtDynamic ? DynamicState.DepthTestEnable : _newState.DepthTestEnable; var oldDepthTestEnable = _supportExtDynamic ? DynamicState.DepthTestEnable : _newState.DepthTestEnable;
var oldDepthWriteEnable = _supportExtDynamic ? DynamicState.DepthWriteEnable : _newState.DepthWriteEnable; var oldDepthWriteEnable = _supportExtDynamic ? DynamicState.DepthWriteEnable : _newState.DepthWriteEnable;
var oldTopology = _supportExtDynamic ? DynamicState.Topology : _newState.Topology; var oldTopology = _newState.Topology;
var oldViewports = DynamicState.Viewports; var oldViewports = DynamicState.Viewports;
var oldViewportsCount = _supportExtDynamic ? DynamicState.ViewportsCount : _newState.ViewportsCount; var oldViewportsCount = _supportExtDynamic ? DynamicState.ViewportsCount : _newState.ViewportsCount;
@ -728,14 +728,13 @@ namespace Ryujinx.Graphics.Vulkan
if (_supportExtDynamic) if (_supportExtDynamic)
{ {
var oldTopologyClass = GetTopologyClass(oldTopology); var oldTopologyClass = GetTopologyClass(oldTopology);
var newTopologyClass = GetTopologyClass(DynamicState.Topology);
DynamicState.SetCullMode(oldCullMode); DynamicState.SetCullMode(oldCullMode);
DynamicState.SetStencilTest(oldStencilTestEnable); DynamicState.SetStencilTest(oldStencilTestEnable);
DynamicState.SetDepthTestBool(oldDepthTestEnable, oldDepthWriteEnable); DynamicState.SetDepthTestBool(oldDepthTestEnable, oldDepthWriteEnable);
DynamicState.SetPrimitiveTopology(oldTopology); DynamicState.SetPrimitiveTopology(oldTopology);
if (oldTopologyClass != newTopologyClass) if (oldTopologyClass != TopologyClass.Triangle)
{ {
_newState.TopologyClass = oldTopology; _newState.TopologyClass = oldTopology;
} }
@ -1296,7 +1295,7 @@ namespace Ryujinx.Graphics.Vulkan
{ {
if (_supportExtDynamic) if (_supportExtDynamic)
{ {
DynamicState.SetStencilOp( DynamicState.SetStencilTestandOp(
stencilTest.BackSFail.Convert(), stencilTest.BackSFail.Convert(),
stencilTest.BackDpPass.Convert(), stencilTest.BackDpPass.Convert(),
stencilTest.BackDpFail.Convert(), stencilTest.BackDpFail.Convert(),
@ -1304,9 +1303,8 @@ namespace Ryujinx.Graphics.Vulkan
stencilTest.FrontSFail.Convert(), stencilTest.FrontSFail.Convert(),
stencilTest.FrontDpPass.Convert(), stencilTest.FrontDpPass.Convert(),
stencilTest.FrontDpFail.Convert(), stencilTest.FrontDpFail.Convert(),
stencilTest.FrontFunc.Convert()); stencilTest.FrontFunc.Convert(),
stencilTest.TestEnable);
DynamicState.SetStencilTest(stencilTest.TestEnable);
} }
else else
{ {

View file

@ -22,7 +22,6 @@ namespace Ryujinx.Graphics.Vulkan
private uint _frontWriteMask; private uint _frontWriteMask;
private uint _frontReference; private uint _frontReference;
private bool _opToo;
private StencilOp _backFailOp; private StencilOp _backFailOp;
private StencilOp _backPassOp; private StencilOp _backPassOp;
private StencilOp _backDepthFailOp; private StencilOp _backDepthFailOp;
@ -71,7 +70,7 @@ namespace Ryujinx.Graphics.Vulkan
FrontFace = 1 << 6, FrontFace = 1 << 6,
DepthTestBool = 1 << 7, DepthTestBool = 1 << 7,
DepthTestCompareOp = 1 << 8, DepthTestCompareOp = 1 << 8,
StencilTestEnable = 1 << 9, StencilTestEnableandStencilOp = 1 << 9,
LineWidth = 1 << 10, LineWidth = 1 << 10,
RasterDiscard = 1 << 11, RasterDiscard = 1 << 11,
LogicOp = 1 << 12, LogicOp = 1 << 12,
@ -79,7 +78,7 @@ namespace Ryujinx.Graphics.Vulkan
PrimitiveRestart = 1 << 14, PrimitiveRestart = 1 << 14,
PrimitiveTopology = 1 << 15, PrimitiveTopology = 1 << 15,
Standard = Blend | DepthBias | Scissor | Stencil | Viewport | LineWidth, Standard = Blend | DepthBias | Scissor | Stencil | Viewport | LineWidth,
Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnable | PrimitiveTopology, Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnableandStencilOp | PrimitiveTopology,
Extended2 = RasterDiscard | LogicOp | PatchControlPoints | PrimitiveRestart, Extended2 = RasterDiscard | LogicOp | PatchControlPoints | PrimitiveRestart,
} }
@ -123,9 +122,9 @@ namespace Ryujinx.Graphics.Vulkan
_dirty |= DirtyFlags.DepthTestCompareOp; _dirty |= DirtyFlags.DepthTestCompareOp;
} }
public void SetStencilOp(StencilOp backFailOp, StencilOp backPassOp, StencilOp backDepthFailOp, public void SetStencilTestandOp(StencilOp backFailOp, StencilOp backPassOp, StencilOp backDepthFailOp,
CompareOp backCompareOp, StencilOp frontFailOp, StencilOp frontPassOp, StencilOp frontDepthFailOp, CompareOp backCompareOp, StencilOp frontFailOp, StencilOp frontPassOp, StencilOp frontDepthFailOp,
CompareOp frontCompareOp) CompareOp frontCompareOp, bool stencilTestEnable)
{ {
_backFailOp = backFailOp; _backFailOp = backFailOp;
_backPassOp = backPassOp; _backPassOp = backPassOp;
@ -135,7 +134,17 @@ namespace Ryujinx.Graphics.Vulkan
_frontPassOp = frontPassOp; _frontPassOp = frontPassOp;
_frontDepthFailOp = frontDepthFailOp; _frontDepthFailOp = frontDepthFailOp;
_frontCompareOp = frontCompareOp; _frontCompareOp = frontCompareOp;
_opToo = true;
StencilTestEnable = stencilTestEnable;
_dirty |= DirtyFlags.StencilTestEnableandStencilOp;
}
public void SetStencilTest(bool stencilTestEnable)
{
StencilTestEnable = stencilTestEnable;
_dirty |= DirtyFlags.StencilTestEnableandStencilOp;
} }
public void SetStencilMask(uint backCompareMask, uint backWriteMask, uint backReference, public void SetStencilMask(uint backCompareMask, uint backWriteMask, uint backReference,
@ -150,12 +159,6 @@ namespace Ryujinx.Graphics.Vulkan
_dirty |= DirtyFlags.Stencil; _dirty |= DirtyFlags.Stencil;
} }
public void SetStencilTest(bool stencilTestEnable)
{
StencilTestEnable = stencilTestEnable;
_dirty |= DirtyFlags.StencilTestEnable;
}
public void SetViewport(int index, Viewport viewport) public void SetViewport(int index, Viewport viewport)
{ {
Viewports[index] = viewport; Viewports[index] = viewport;
@ -301,9 +304,9 @@ namespace Ryujinx.Graphics.Vulkan
RecordDepthTestCompareOp(gd.ExtendedDynamicStateApi, commandBuffer); RecordDepthTestCompareOp(gd.ExtendedDynamicStateApi, commandBuffer);
} }
if (_dirty.HasFlag(DirtyFlags.StencilTestEnable)) if (_dirty.HasFlag(DirtyFlags.StencilTestEnableandStencilOp))
{ {
RecordStencilTestEnable(gd.ExtendedDynamicStateApi, commandBuffer); RecordStencilTestandOp(gd.ExtendedDynamicStateApi, commandBuffer);
} }
if (_dirty.HasFlag(DirtyFlags.LineWidth)) if (_dirty.HasFlag(DirtyFlags.LineWidth))
@ -379,14 +382,6 @@ namespace Ryujinx.Graphics.Vulkan
private readonly void RecordStencil(VulkanRenderer gd, CommandBuffer commandBuffer) private readonly void RecordStencil(VulkanRenderer gd, CommandBuffer commandBuffer)
{ {
if (_opToo)
{
gd.ExtendedDynamicStateApi.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceBackBit, _backFailOp, _backPassOp,
_backDepthFailOp, _backCompareOp);
gd.ExtendedDynamicStateApi.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontFailOp, _frontPassOp,
_frontDepthFailOp, _frontCompareOp);
}
gd.Api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backCompareMask); gd.Api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backCompareMask);
gd.Api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backWriteMask); gd.Api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backWriteMask);
gd.Api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceBackBit, _backReference); gd.Api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceBackBit, _backReference);
@ -395,9 +390,14 @@ namespace Ryujinx.Graphics.Vulkan
gd.Api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontReference); gd.Api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontReference);
} }
private readonly void RecordStencilTestEnable(ExtExtendedDynamicState api, CommandBuffer commandBuffer) private readonly void RecordStencilTestandOp(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
{ {
api.CmdSetStencilTestEnable(commandBuffer, StencilTestEnable); api.CmdSetStencilTestEnable(commandBuffer, StencilTestEnable);
api.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceBackBit, _backFailOp, _backPassOp,
_backDepthFailOp, _backCompareOp);
api.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontFailOp, _frontPassOp,
_frontDepthFailOp, _frontCompareOp);
} }
private void RecordViewport(VulkanRenderer gd, CommandBuffer commandBuffer) private void RecordViewport(VulkanRenderer gd, CommandBuffer commandBuffer)