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

Reduce unneeded state changes

This commit is contained in:
sunshineinabox 2024-05-29 09:45:56 -07:00
parent 5c65880ec0
commit e6492f8e78
3 changed files with 40 additions and 17 deletions

View file

@ -880,12 +880,10 @@ namespace Ryujinx.Graphics.Vulkan
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
{
DynamicState.SetDepthBias(factor, units, clamp, (enables != 0));
bool enable = enables != 0;
DynamicState.SetDepthBias(factor, units, clamp, enable);
if (!_supportExtDynamic2)
{
_newState.DepthBiasEnable = enables != 0;
}
_newState.DepthBiasEnable = enable;
SignalStateChange();
}
@ -919,11 +917,12 @@ namespace Ryujinx.Graphics.Vulkan
}
else
{
_newState.DepthTestEnable = depthTest.TestEnable;
_newState.DepthWriteEnable = depthTest.WriteEnable;
_newState.DepthCompareOp = depthTest.Func.Convert();
}
_newState.DepthTestEnable = depthTest.TestEnable;
SignalStateChange();
}

View file

@ -434,8 +434,11 @@ namespace Ryujinx.Graphics.Vulkan
{
api.CmdSetDepthTestEnable(commandBuffer, DepthTestEnable);
if (DepthTestEnable)
{
api.CmdSetDepthWriteEnable(commandBuffer, DepthWriteEnable);
}
}
private readonly void RecordDepthTestCompareOp(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
{

View file

@ -526,7 +526,10 @@ namespace Ryujinx.Graphics.Vulkan
depthStencilState.Back = stencilBack;
depthStencilState.StencilTestEnable = StencilTestEnable;
depthStencilState.DepthTestEnable = DepthTestEnable;
if (DepthTestEnable)
{
depthStencilState.DepthWriteEnable = DepthWriteEnable;
}
depthStencilState.DepthCompareOp = DepthCompareOp;
}
@ -579,7 +582,7 @@ namespace Ryujinx.Graphics.Vulkan
colorBlendState.PNext = &colorBlendAdvancedState;
}
int baseDynamicStatesCount = 7;
int baseDynamicStatesCount = 6;
int additionalDynamicStatesCount = 0;
if (!isMoltenVk)
@ -587,9 +590,19 @@ namespace Ryujinx.Graphics.Vulkan
baseDynamicStatesCount++;
}
if (DepthBiasEnable)
{
baseDynamicStatesCount++;
}
if (supportsExtDynamicState)
{
additionalDynamicStatesCount += isMoltenVk ? 8 : 9;
additionalDynamicStatesCount += isMoltenVk ? 7 : 8;
if (DepthTestEnable)
{
additionalDynamicStatesCount++;
}
}
if (supportsExtDynamicState2)
@ -610,13 +623,16 @@ namespace Ryujinx.Graphics.Vulkan
dynamicStates[0] = DynamicState.Viewport;
dynamicStates[1] = DynamicState.Scissor;
dynamicStates[2] = DynamicState.DepthBias;
dynamicStates[3] = DynamicState.StencilCompareMask;
dynamicStates[4] = DynamicState.StencilWriteMask;
dynamicStates[5] = DynamicState.StencilReference;
dynamicStates[6] = DynamicState.BlendConstants;
dynamicStates[2] = DynamicState.StencilCompareMask;
dynamicStates[3] = DynamicState.StencilWriteMask;
dynamicStates[4] = DynamicState.StencilReference;
dynamicStates[5] = DynamicState.BlendConstants;
int currentIndex = 7;
if (DepthBiasEnable)
{
dynamicStates[6] = DynamicState.DepthBias;
}
int currentIndex = DepthBiasEnable ? 7 : 6;
if (!isMoltenVk)
{
@ -636,7 +652,12 @@ namespace Ryujinx.Graphics.Vulkan
dynamicStates[currentIndex++] = DynamicState.CullModeExt;
dynamicStates[currentIndex++] = DynamicState.FrontFaceExt;
dynamicStates[currentIndex++] = DynamicState.DepthTestEnableExt;
if (DepthTestEnable)
{
dynamicStates[currentIndex++] = DynamicState.DepthWriteEnableExt;
}
dynamicStates[currentIndex++] = DynamicState.DepthCompareOpExt;
dynamicStates[currentIndex++] = DynamicState.StencilTestEnableExt;
dynamicStates[currentIndex++] = DynamicState.StencilOpExt;