mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 02:53:04 +00:00
Avoid unncessary DepthBias state updates
This commit is contained in:
parent
7404d782ce
commit
10506afc23
3 changed files with 47 additions and 9 deletions
|
@ -841,19 +841,29 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
/// </summary>
|
||||
private void UpdateDepthBiasState()
|
||||
{
|
||||
if (_pipeline.BiasEnable == 0 && (_state.State.DepthBiasFactor == 0 && _state.State.DepthBiasUnits == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (_pipeline.BiasEnable != 0 &&
|
||||
(_state.State.DepthBiasFactor == 0 && _state.State.DepthBiasUnits == 0))
|
||||
{
|
||||
_pipeline.BiasEnable = 0;
|
||||
|
||||
_context.Renderer.Pipeline.SetDepthBiasEnable(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var depthBias = _state.State.DepthBiasState;
|
||||
|
||||
float factor = _state.State.DepthBiasFactor;
|
||||
float units = _state.State.DepthBiasUnits;
|
||||
float clamp = _state.State.DepthBiasClamp;
|
||||
|
||||
PolygonModeMask enables;
|
||||
PolygonModeMask enables = 0;
|
||||
|
||||
if (factor == 0 && units == 0)
|
||||
{
|
||||
enables = 0;
|
||||
}
|
||||
else
|
||||
if (factor != 0 && units != 0)
|
||||
{
|
||||
enables = (depthBias.PointEnable ? PolygonModeMask.Point : 0);
|
||||
enables |= (depthBias.LineEnable ? PolygonModeMask.Line : 0);
|
||||
|
@ -864,7 +874,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
|
||||
_context.Renderer.Pipeline.SetDepthBiasEnable(enables);
|
||||
|
||||
if (enables != 0)
|
||||
if (enables > 0)
|
||||
{
|
||||
_context.Renderer.Pipeline.SetDepthBias(factor, units / 2f, clamp);
|
||||
}
|
||||
|
|
|
@ -833,6 +833,15 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
public void SetDepthBias(float factor, float units, float clamp)
|
||||
{
|
||||
if (factor == 0 && units == 0)
|
||||
{
|
||||
GL.Disable(EnableCap.PolygonOffsetPoint);
|
||||
GL.Disable(EnableCap.PolygonOffsetLine);
|
||||
GL.Disable(EnableCap.PolygonOffsetFill);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (HwCapabilities.SupportsPolygonOffsetClamp)
|
||||
{
|
||||
GL.PolygonOffsetClamp(factor, units, clamp);
|
||||
|
|
|
@ -787,6 +787,19 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
public void SetDepthBias(float factor, float units, float clamp)
|
||||
{
|
||||
if (factor == 0 && units == 0 && _newState.DepthBiasEnable)
|
||||
{
|
||||
_newState.DepthBiasEnable = false;
|
||||
|
||||
SignalStateChange();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (factor == 0 && units == 0 && !_newState.DepthBiasEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DynamicState.SetDepthBias(factor, units, clamp);
|
||||
|
||||
SignalStateChange();
|
||||
|
@ -794,11 +807,17 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
public void SetDepthBiasEnable(PolygonModeMask enables)
|
||||
{
|
||||
_newState.DepthBiasEnable = enables != 0;
|
||||
bool depthBiasEnable = enables != 0;
|
||||
|
||||
if (_newState.DepthBiasEnable != depthBiasEnable)
|
||||
{
|
||||
_newState.DepthBiasEnable = depthBiasEnable;
|
||||
|
||||
SignalStateChange();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetDepthClamp(bool clamp)
|
||||
{
|
||||
_newState.DepthClampEnable = clamp;
|
||||
|
|
Loading…
Reference in a new issue