Code review suggestions

This commit is contained in:
sunshineinabox 2024-07-21 12:58:40 -07:00
parent a7a49cc8fe
commit 20101e2ea3
5 changed files with 18 additions and 15 deletions

View file

@ -5,6 +5,7 @@ namespace Ryujinx.Graphics.GAL
[Flags]
public enum PolygonModeMask
{
None = 0,
Point = 1 << 0,
Line = 1 << 1,
Fill = 1 << 2,

View file

@ -841,16 +841,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
private void UpdateDepthBiasState()
{
if (_pipeline.BiasEnable == 0 && (_state.State.DepthBiasFactor == 0 && _state.State.DepthBiasUnits == 0))
if (_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;
if (_pipeline.BiasEnable != PolygonModeMask.None)
{
_pipeline.BiasEnable = PolygonModeMask.None;
_context.Renderer.Pipeline.SetDepthBias(0, 0, 0, 0);
_context.Renderer.Pipeline.SetDepthBias(PolygonModeMask.None, 0, 0, 0);
}
return;
}
@ -861,7 +859,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
float units = _state.State.DepthBiasUnits;
float clamp = _state.State.DepthBiasClamp;
PolygonModeMask enables = 0;
PolygonModeMask enables = PolygonModeMask.None;
if (factor != 0 && units != 0)
{

View file

@ -833,7 +833,7 @@ namespace Ryujinx.Graphics.OpenGL
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
{
if (enables == 0 || (factor == 0 && units == 0))
if (enables == PolygonModeMask.None || (factor == 0 && units == 0))
{
GL.Disable(EnableCap.PolygonOffsetPoint);
GL.Disable(EnableCap.PolygonOffsetLine);

View file

@ -787,14 +787,14 @@ namespace Ryujinx.Graphics.Vulkan
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
{
bool depthBiasEnable = (enables != 0) && (factor != 0 && units != 0);
bool changed = false;
if (factor == 0 && units == 0 && !_newState.DepthBiasEnable)
{
return;
}
bool depthBiasEnable = (enables != PolygonModeMask.None) && (factor != 0 && units != 0);
bool changed = false;
if (_newState.DepthBiasEnable != depthBiasEnable)
{
_newState.DepthBiasEnable = depthBiasEnable;

View file

@ -564,7 +564,9 @@ namespace Ryujinx.Graphics.Vulkan
}
bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState;
int dynamicStatesCount = supportsExtDynamicState ? 7 : 6;
if (DepthBiasEnable)
{
dynamicStatesCount++;
@ -579,14 +581,16 @@ namespace Ryujinx.Graphics.Vulkan
dynamicStates[4] = DynamicState.StencilReference;
dynamicStates[5] = DynamicState.BlendConstants;
dynamicStatesCount = 6;
if (DepthBiasEnable)
{
dynamicStates[6] = DynamicState.DepthBias;
dynamicStates[dynamicStatesCount++] = DynamicState.DepthBias;
}
if (supportsExtDynamicState)
{
dynamicStates[dynamicStatesCount - 1] = DynamicState.VertexInputBindingStrideExt;
dynamicStates[dynamicStatesCount++] = DynamicState.VertexInputBindingStrideExt;
}
var pipelineDynamicStateCreateInfo = new PipelineDynamicStateCreateInfo