Archived
1
0
Fork 0
forked from Mirror/Ryujinx

Add support for custom line widths (#2406)

This commit is contained in:
gdkchan 2021-06-25 20:11:54 -03:00 committed by GitHub
parent 493648df31
commit fefd4619a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 1 deletions

View file

@ -52,6 +52,7 @@ namespace Ryujinx.Graphics.GAL
void SetLogicOpState(bool enable, LogicalOp op); void SetLogicOpState(bool enable, LogicalOp op);
void SetLineParameters(float width, bool smooth);
void SetPointParameters(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin); void SetPointParameters(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin);
void SetPrimitiveRestart(bool enable, int index); void SetPrimitiveRestart(bool enable, int index);

View file

@ -223,12 +223,17 @@ namespace Ryujinx.Graphics.Gpu.Engine
UpdateTexturePoolState(state); UpdateTexturePoolState(state);
} }
// Input assembler state. // Rasterizer state.
if (state.QueryModified(MethodOffset.VertexAttribState)) if (state.QueryModified(MethodOffset.VertexAttribState))
{ {
UpdateVertexAttribState(state); UpdateVertexAttribState(state);
} }
if (state.QueryModified(MethodOffset.LineWidthSmooth, MethodOffset.LineSmoothEnable))
{
UpdateLineState(state);
}
if (state.QueryModified(MethodOffset.PointSize, if (state.QueryModified(MethodOffset.PointSize,
MethodOffset.VertexProgramPointSize, MethodOffset.VertexProgramPointSize,
MethodOffset.PointSpriteEnable, MethodOffset.PointSpriteEnable,
@ -716,6 +721,18 @@ namespace Ryujinx.Graphics.Gpu.Engine
_context.Renderer.Pipeline.SetVertexAttribs(vertexAttribs); _context.Renderer.Pipeline.SetVertexAttribs(vertexAttribs);
} }
/// <summary>
/// Updates host line width based on guest GPU state.
/// </summary>
/// <param name="state">Current GPU state</param>
private void UpdateLineState(GpuState state)
{
float width = state.Get<float>(MethodOffset.LineWidthSmooth);
bool smooth = state.Get<Boolean32>(MethodOffset.LineSmoothEnable);
_context.Renderer.Pipeline.SetLineParameters(width, smooth);
}
/// <summary> /// <summary>
/// Updates host point size based on guest GPU state. /// Updates host point size based on guest GPU state.
/// </summary> /// </summary>

View file

@ -67,6 +67,8 @@ namespace Ryujinx.Graphics.Gpu.State
BlendEnable = 0x4d8, BlendEnable = 0x4d8,
StencilTestState = 0x4e0, StencilTestState = 0x4e0,
YControl = 0x4eb, YControl = 0x4eb,
LineWidthSmooth = 0x4ec,
LineWidthAliased = 0x4ed,
FirstVertex = 0x50d, FirstVertex = 0x50d,
FirstInstance = 0x50e, FirstInstance = 0x50e,
ClipDistanceEnable = 0x544, ClipDistanceEnable = 0x544,
@ -77,6 +79,7 @@ namespace Ryujinx.Graphics.Gpu.State
ConditionState = 0x554, ConditionState = 0x554,
SamplerPoolState = 0x557, SamplerPoolState = 0x557,
DepthBiasFactor = 0x55b, DepthBiasFactor = 0x55b,
LineSmoothEnable = 0x55c,
TexturePoolState = 0x55d, TexturePoolState = 0x55d,
StencilBackTestState = 0x565, StencilBackTestState = 0x565,
DepthBiasUnits = 0x56f, DepthBiasUnits = 0x56f,

View file

@ -746,6 +746,20 @@ namespace Ryujinx.Graphics.OpenGL
} }
} }
public void SetLineParameters(float width, bool smooth)
{
if (smooth)
{
GL.Enable(EnableCap.LineSmooth);
}
else
{
GL.Disable(EnableCap.LineSmooth);
}
GL.LineWidth(width);
}
public void SetPointParameters(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin) public void SetPointParameters(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin)
{ {
// GL_POINT_SPRITE was deprecated in core profile 3.2+ and causes GL_INVALID_ENUM when set. // GL_POINT_SPRITE was deprecated in core profile 3.2+ and causes GL_INVALID_ENUM when set.