Avoid setting DepthBias when not needed.
This commit is contained in:
parent
1a919e99b2
commit
7404d782ce
10 changed files with 90 additions and 34 deletions
|
@ -47,7 +47,8 @@ namespace Ryujinx.Graphics.GAL
|
||||||
void SetBlendState(AdvancedBlendDescriptor blend);
|
void SetBlendState(AdvancedBlendDescriptor blend);
|
||||||
void SetBlendState(int index, BlendDescriptor blend);
|
void SetBlendState(int index, BlendDescriptor blend);
|
||||||
|
|
||||||
void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
|
void SetDepthBias(float factor, float units, float clamp);
|
||||||
|
void SetDepthBiasEnable(PolygonModeMask enables);
|
||||||
void SetDepthClamp(bool clamp);
|
void SetDepthClamp(bool clamp);
|
||||||
void SetDepthMode(DepthMode mode);
|
void SetDepthMode(DepthMode mode);
|
||||||
void SetDepthTest(DepthTestDescriptor depthTest);
|
void SetDepthTest(DepthTestDescriptor depthTest);
|
||||||
|
|
|
@ -116,6 +116,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
Register<SetBlendStateAdvancedCommand>(CommandType.SetBlendStateAdvanced);
|
Register<SetBlendStateAdvancedCommand>(CommandType.SetBlendStateAdvanced);
|
||||||
Register<SetBlendStateCommand>(CommandType.SetBlendState);
|
Register<SetBlendStateCommand>(CommandType.SetBlendState);
|
||||||
Register<SetDepthBiasCommand>(CommandType.SetDepthBias);
|
Register<SetDepthBiasCommand>(CommandType.SetDepthBias);
|
||||||
|
Register<SetDepthBiasEnableCommand>(CommandType.SetDepthBiasEnable);
|
||||||
Register<SetDepthClampCommand>(CommandType.SetDepthClamp);
|
Register<SetDepthClampCommand>(CommandType.SetDepthClamp);
|
||||||
Register<SetDepthModeCommand>(CommandType.SetDepthMode);
|
Register<SetDepthModeCommand>(CommandType.SetDepthMode);
|
||||||
Register<SetDepthTestCommand>(CommandType.SetDepthTest);
|
Register<SetDepthTestCommand>(CommandType.SetDepthTest);
|
||||||
|
|
|
@ -76,6 +76,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
SetBlendStateAdvanced,
|
SetBlendStateAdvanced,
|
||||||
SetBlendState,
|
SetBlendState,
|
||||||
SetDepthBias,
|
SetDepthBias,
|
||||||
|
SetDepthBiasEnable,
|
||||||
SetDepthClamp,
|
SetDepthClamp,
|
||||||
SetDepthMode,
|
SetDepthMode,
|
||||||
SetDepthTest,
|
SetDepthTest,
|
||||||
|
|
|
@ -3,14 +3,12 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||||
struct SetDepthBiasCommand : IGALCommand, IGALCommand<SetDepthBiasCommand>
|
struct SetDepthBiasCommand : IGALCommand, IGALCommand<SetDepthBiasCommand>
|
||||||
{
|
{
|
||||||
public readonly CommandType CommandType => CommandType.SetDepthBias;
|
public readonly CommandType CommandType => CommandType.SetDepthBias;
|
||||||
private PolygonModeMask _enables;
|
|
||||||
private float _factor;
|
private float _factor;
|
||||||
private float _units;
|
private float _units;
|
||||||
private float _clamp;
|
private float _clamp;
|
||||||
|
|
||||||
public void Set(PolygonModeMask enables, float factor, float units, float clamp)
|
public void Set(float factor, float units, float clamp)
|
||||||
{
|
{
|
||||||
_enables = enables;
|
|
||||||
_factor = factor;
|
_factor = factor;
|
||||||
_units = units;
|
_units = units;
|
||||||
_clamp = clamp;
|
_clamp = clamp;
|
||||||
|
@ -18,7 +16,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||||
|
|
||||||
public static void Run(ref SetDepthBiasCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
public static void Run(ref SetDepthBiasCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||||
{
|
{
|
||||||
renderer.Pipeline.SetDepthBias(command._enables, command._factor, command._units, command._clamp);
|
renderer.Pipeline.SetDepthBias(command._factor, command._units, command._clamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||||
|
{
|
||||||
|
struct SetDepthBiasEnableCommand : IGALCommand, IGALCommand<SetDepthBiasEnableCommand>
|
||||||
|
{
|
||||||
|
public readonly CommandType CommandType => CommandType.SetDepthBias;
|
||||||
|
private PolygonModeMask _enables;
|
||||||
|
|
||||||
|
|
||||||
|
public void Set(PolygonModeMask enables)
|
||||||
|
{
|
||||||
|
_enables = enables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Run(ref SetDepthBiasEnableCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||||
|
{
|
||||||
|
renderer.Pipeline.SetDepthBiasEnable(command._enables);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -141,9 +141,15 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
public void SetDepthBias(float factor, float units, float clamp)
|
||||||
{
|
{
|
||||||
_renderer.New<SetDepthBiasCommand>().Set(enables, factor, units, clamp);
|
_renderer.New<SetDepthBiasCommand>().Set(factor, units, clamp);
|
||||||
|
_renderer.QueueCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDepthBiasEnable(PolygonModeMask enables)
|
||||||
|
{
|
||||||
|
_renderer.New<SetDepthBiasEnableCommand>().Set(enables);
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -849,12 +849,25 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||||
|
|
||||||
PolygonModeMask enables;
|
PolygonModeMask enables;
|
||||||
|
|
||||||
enables = (depthBias.PointEnable ? PolygonModeMask.Point : 0);
|
if (factor == 0 && units == 0)
|
||||||
enables |= (depthBias.LineEnable ? PolygonModeMask.Line : 0);
|
{
|
||||||
enables |= (depthBias.FillEnable ? PolygonModeMask.Fill : 0);
|
enables = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
enables = (depthBias.PointEnable ? PolygonModeMask.Point : 0);
|
||||||
|
enables |= (depthBias.LineEnable ? PolygonModeMask.Line : 0);
|
||||||
|
enables |= (depthBias.FillEnable ? PolygonModeMask.Fill : 0);
|
||||||
|
}
|
||||||
|
|
||||||
_pipeline.BiasEnable = enables;
|
_pipeline.BiasEnable = enables;
|
||||||
_context.Renderer.Pipeline.SetDepthBias(enables, factor, units / 2f, clamp);
|
|
||||||
|
_context.Renderer.Pipeline.SetDepthBiasEnable(enables);
|
||||||
|
|
||||||
|
if (enables != 0)
|
||||||
|
{
|
||||||
|
_context.Renderer.Pipeline.SetDepthBias(factor, units / 2f, clamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -831,8 +831,25 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
GL.Enable(IndexedEnableCap.Blend, index);
|
GL.Enable(IndexedEnableCap.Blend, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
public void SetDepthBias(float factor, float units, float clamp)
|
||||||
{
|
{
|
||||||
|
if (HwCapabilities.SupportsPolygonOffsetClamp)
|
||||||
|
{
|
||||||
|
GL.PolygonOffsetClamp(factor, units, clamp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL.PolygonOffset(factor, units);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDepthBiasEnable(PolygonModeMask enables)
|
||||||
|
{
|
||||||
|
if (enables == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((enables & PolygonModeMask.Point) != 0)
|
if ((enables & PolygonModeMask.Point) != 0)
|
||||||
{
|
{
|
||||||
GL.Enable(EnableCap.PolygonOffsetPoint);
|
GL.Enable(EnableCap.PolygonOffsetPoint);
|
||||||
|
@ -859,20 +876,6 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
GL.Disable(EnableCap.PolygonOffsetFill);
|
GL.Disable(EnableCap.PolygonOffsetFill);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enables == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HwCapabilities.SupportsPolygonOffsetClamp)
|
|
||||||
{
|
|
||||||
GL.PolygonOffsetClamp(factor, units, clamp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GL.PolygonOffset(factor, units);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthClamp(bool clamp)
|
public void SetDepthClamp(bool clamp)
|
||||||
|
|
|
@ -785,11 +785,17 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
|
public void SetDepthBias(float factor, float units, float clamp)
|
||||||
{
|
{
|
||||||
DynamicState.SetDepthBias(factor, units, clamp);
|
DynamicState.SetDepthBias(factor, units, clamp);
|
||||||
|
|
||||||
|
SignalStateChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDepthBiasEnable(PolygonModeMask enables)
|
||||||
|
{
|
||||||
_newState.DepthBiasEnable = enables != 0;
|
_newState.DepthBiasEnable = enables != 0;
|
||||||
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -564,21 +564,29 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
|
|
||||||
bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState;
|
bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState;
|
||||||
int dynamicStatesCount = supportsExtDynamicState ? 8 : 7;
|
int dynamicStatesCount = supportsExtDynamicState ? 7 : 6;
|
||||||
|
if (DepthBiasEnable)
|
||||||
|
{
|
||||||
|
dynamicStatesCount++;
|
||||||
|
}
|
||||||
|
|
||||||
DynamicState* dynamicStates = stackalloc DynamicState[dynamicStatesCount];
|
DynamicState* dynamicStates = stackalloc DynamicState[dynamicStatesCount];
|
||||||
|
|
||||||
dynamicStates[0] = DynamicState.Viewport;
|
dynamicStates[0] = DynamicState.Viewport;
|
||||||
dynamicStates[1] = DynamicState.Scissor;
|
dynamicStates[1] = DynamicState.Scissor;
|
||||||
dynamicStates[2] = DynamicState.DepthBias;
|
dynamicStates[2] = DynamicState.StencilCompareMask;
|
||||||
dynamicStates[3] = DynamicState.StencilCompareMask;
|
dynamicStates[3] = DynamicState.StencilWriteMask;
|
||||||
dynamicStates[4] = DynamicState.StencilWriteMask;
|
dynamicStates[4] = DynamicState.StencilReference;
|
||||||
dynamicStates[5] = DynamicState.StencilReference;
|
dynamicStates[5] = DynamicState.BlendConstants;
|
||||||
dynamicStates[6] = DynamicState.BlendConstants;
|
|
||||||
|
if (DepthBiasEnable)
|
||||||
|
{
|
||||||
|
dynamicStates[6] = DynamicState.DepthBias;
|
||||||
|
}
|
||||||
|
|
||||||
if (supportsExtDynamicState)
|
if (supportsExtDynamicState)
|
||||||
{
|
{
|
||||||
dynamicStates[7] = DynamicState.VertexInputBindingStrideExt;
|
dynamicStates[dynamicStatesCount - 1] = DynamicState.VertexInputBindingStrideExt;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pipelineDynamicStateCreateInfo = new PipelineDynamicStateCreateInfo
|
var pipelineDynamicStateCreateInfo = new PipelineDynamicStateCreateInfo
|
||||||
|
|
Loading…
Reference in a new issue