Refactor Cull Mode to only send face.
This commit is contained in:
parent
2fd093d4b4
commit
5a391f38fd
11 changed files with 27 additions and 18 deletions
|
@ -2,6 +2,7 @@ namespace Ryujinx.Graphics.GAL
|
|||
{
|
||||
public enum Face
|
||||
{
|
||||
None = 0,
|
||||
Front = 0x404,
|
||||
Back = 0x405,
|
||||
FrontAndBack = 0x408,
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.GAL
|
|||
void SetDepthMode(DepthMode mode);
|
||||
void SetDepthTest(DepthTestDescriptor depthTest);
|
||||
|
||||
void SetFaceCulling(bool enable, Face face);
|
||||
void SetFaceCulling(Face face);
|
||||
|
||||
void SetFrontFace(FrontFace frontFace);
|
||||
|
||||
|
|
|
@ -3,18 +3,16 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
|||
struct SetFaceCullingCommand : IGALCommand, IGALCommand<SetFaceCullingCommand>
|
||||
{
|
||||
public readonly CommandType CommandType => CommandType.SetFaceCulling;
|
||||
private bool _enable;
|
||||
private Face _face;
|
||||
|
||||
public void Set(bool enable, Face face)
|
||||
public void Set(Face face)
|
||||
{
|
||||
_enable = enable;
|
||||
_face = face;
|
||||
}
|
||||
|
||||
public static void Run(ref SetFaceCullingCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||
{
|
||||
renderer.Pipeline.SetFaceCulling(command._enable, command._face);
|
||||
renderer.Pipeline.SetFaceCulling(command._face);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,9 +165,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
|||
_renderer.QueueCommand();
|
||||
}
|
||||
|
||||
public void SetFaceCulling(bool enable, Face face)
|
||||
public void SetFaceCulling(Face face)
|
||||
{
|
||||
_renderer.New<SetFaceCullingCommand>().Set(enable, face);
|
||||
_renderer.New<SetFaceCullingCommand>().Set(face);
|
||||
_renderer.QueueCommand();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ namespace Ryujinx.Graphics.GAL
|
|||
public StencilTestDescriptor StencilTest;
|
||||
public FrontFace FrontFace;
|
||||
public Face CullMode;
|
||||
public bool CullEnable;
|
||||
|
||||
public PolygonModeMask BiasEnable;
|
||||
|
||||
|
|
|
@ -1198,9 +1198,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
var yControl = _state.State.YControl;
|
||||
var face = _state.State.FaceState;
|
||||
|
||||
_pipeline.CullEnable = face.CullEnable;
|
||||
_pipeline.CullMode = face.CullFace;
|
||||
_context.Renderer.Pipeline.SetFaceCulling(face.CullEnable, face.CullFace);
|
||||
if (face.CullEnable)
|
||||
{
|
||||
_pipeline.CullMode = face.CullFace;
|
||||
_context.Renderer.Pipeline.SetFaceCulling(face.CullFace);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pipeline.CullMode = Face.None;
|
||||
_context.Renderer.Pipeline.SetFaceCulling(Face.None);
|
||||
}
|
||||
|
||||
UpdateFrontFace(yControl, face.FrontFace);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ using OpenTK.Graphics.OpenGL;
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using GL = OpenTK.Graphics.ES11.GL;
|
||||
|
||||
namespace Ryujinx.Graphics.OpenGL
|
||||
{
|
||||
|
@ -334,6 +335,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
return CullFaceMode.Front;
|
||||
case Face.FrontAndBack:
|
||||
return CullFaceMode.FrontAndBack;
|
||||
case Face.None:
|
||||
return (CullFaceMode)All.None;
|
||||
}
|
||||
|
||||
Logger.Debug?.Print(LogClass.Gpu, $"Invalid {nameof(Face)} enum value: {face}.");
|
||||
|
|
|
@ -915,11 +915,11 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
_depthTestEnable = depthTest.TestEnable;
|
||||
}
|
||||
|
||||
public void SetFaceCulling(bool enable, Face face)
|
||||
public void SetFaceCulling(Face face)
|
||||
{
|
||||
_cullEnable = enable;
|
||||
_cullEnable = face != Face.None;
|
||||
|
||||
if (!enable)
|
||||
if (!_cullEnable)
|
||||
{
|
||||
GL.Disable(EnableCap.CullFace);
|
||||
return;
|
||||
|
|
|
@ -238,6 +238,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
Face.Back => CullModeFlags.BackBit,
|
||||
Face.Front => CullModeFlags.FrontBit,
|
||||
Face.FrontAndBack => CullModeFlags.FrontAndBack,
|
||||
Face.None => CullModeFlags.None,
|
||||
_ => LogInvalidAndReturn(face, nameof(Face), CullModeFlags.BackBit),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -908,15 +908,15 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
UpdatePassDepthStencil();
|
||||
}
|
||||
|
||||
public void SetFaceCulling(bool enable, Face face)
|
||||
public void SetFaceCulling(Face face)
|
||||
{
|
||||
if (_supportExtDynamic)
|
||||
{
|
||||
DynamicState.SetCullMode(enable ? face.Convert() : CullModeFlags.None);
|
||||
DynamicState.SetCullMode(face.Convert());
|
||||
}
|
||||
else
|
||||
{
|
||||
_newState.CullMode = enable ? face.Convert() : CullModeFlags.None;
|
||||
_newState.CullMode = face.Convert();
|
||||
|
||||
SignalStateChange();
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
if (!extendedDynamicState)
|
||||
{
|
||||
pipeline.DepthCompareOp = state.DepthTest.Func.Convert();
|
||||
pipeline.CullMode = state.CullEnable ? state.CullMode.Convert() : CullModeFlags.None;
|
||||
pipeline.CullMode = state.CullMode.Convert();
|
||||
|
||||
pipeline.DepthTestEnable = state.DepthTest.TestEnable;
|
||||
pipeline.DepthWriteEnable = state.DepthTest.WriteEnable;
|
||||
|
|
Loading…
Reference in a new issue