aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-10-25 18:30:09 -0300
committerGitHub <noreply@github.com>2018-10-25 18:30:09 -0300
commitf0a49a1c94c74886f4cfb35c35d7deec82f6bd8f (patch)
tree6bdd103005b7a551b99ea4bd2b7bbf75536e39ce /Ryujinx.Graphics/Gal
parent2fd23577cea09a1c270678109ec728026df1cfda (diff)
Fix Color Mask values (#473)
* Fix color mask common, set default value on first color mask register * Missing check * Better exception messages * Address PR feedback * Add fixme as per review feedback
Diffstat (limited to 'Ryujinx.Graphics/Gal')
-rw-r--r--Ryujinx.Graphics/Gal/GalPipelineState.cs46
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs46
2 files changed, 52 insertions, 40 deletions
diff --git a/Ryujinx.Graphics/Gal/GalPipelineState.cs b/Ryujinx.Graphics/Gal/GalPipelineState.cs
index 17f52dd6..f50f1032 100644
--- a/Ryujinx.Graphics/Gal/GalPipelineState.cs
+++ b/Ryujinx.Graphics/Gal/GalPipelineState.cs
@@ -37,11 +37,11 @@
public GalFrontFace FrontFace;
- public bool CullFaceEnabled;
+ public bool CullFaceEnabled;
public GalCullFace CullFace;
- public bool DepthTestEnabled;
- public bool DepthWriteEnabled;
+ public bool DepthTestEnabled;
+ public bool DepthWriteEnabled;
public GalComparisonOp DepthFunc;
public float DepthRangeNear;
public float DepthRangeFar;
@@ -50,31 +50,31 @@
public bool StencilTwoSideEnabled;
public GalComparisonOp StencilBackFuncFunc;
- public int StencilBackFuncRef;
- public uint StencilBackFuncMask;
- public GalStencilOp StencilBackOpFail;
- public GalStencilOp StencilBackOpZFail;
- public GalStencilOp StencilBackOpZPass;
- public uint StencilBackMask;
+ public int StencilBackFuncRef;
+ public uint StencilBackFuncMask;
+ public GalStencilOp StencilBackOpFail;
+ public GalStencilOp StencilBackOpZFail;
+ public GalStencilOp StencilBackOpZPass;
+ public uint StencilBackMask;
public GalComparisonOp StencilFrontFuncFunc;
- public int StencilFrontFuncRef;
- public uint StencilFrontFuncMask;
- public GalStencilOp StencilFrontOpFail;
- public GalStencilOp StencilFrontOpZFail;
- public GalStencilOp StencilFrontOpZPass;
- public uint StencilFrontMask;
-
- public bool BlendEnabled;
- public bool BlendSeparateAlpha;
+ public int StencilFrontFuncRef;
+ public uint StencilFrontFuncMask;
+ public GalStencilOp StencilFrontOpFail;
+ public GalStencilOp StencilFrontOpZFail;
+ public GalStencilOp StencilFrontOpZPass;
+ public uint StencilFrontMask;
+
+ public bool BlendEnabled;
+ public bool BlendSeparateAlpha;
public GalBlendEquation BlendEquationRgb;
- public GalBlendFactor BlendFuncSrcRgb;
- public GalBlendFactor BlendFuncDstRgb;
+ public GalBlendFactor BlendFuncSrcRgb;
+ public GalBlendFactor BlendFuncDstRgb;
public GalBlendEquation BlendEquationAlpha;
- public GalBlendFactor BlendFuncSrcAlpha;
- public GalBlendFactor BlendFuncDstAlpha;
+ public GalBlendFactor BlendFuncSrcAlpha;
+ public GalBlendFactor BlendFuncDstAlpha;
- public ColorMaskRgba ColorMask;
+ public bool ColorMaskCommon;
public ColorMaskRgba[] ColorMasks;
public bool PrimitiveRestartEnabled;
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs
index 656d8e8e..6e1cabba 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs
@@ -131,8 +131,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
BlendFuncSrcAlpha = GalBlendFactor.One,
BlendFuncDstAlpha = GalBlendFactor.Zero,
- ColorMask = ColorMaskRgba.Default,
-
PrimitiveRestartEnabled = false,
PrimitiveRestartIndex = 0
};
@@ -316,16 +314,30 @@ namespace Ryujinx.Graphics.Gal.OpenGL
}
}
- for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++)
+ if (New.ColorMaskCommon)
{
- if (!New.ColorMasks[Index].Equals(Old.ColorMasks[Index]))
+ if (New.ColorMaskCommon != Old.ColorMaskCommon || !New.ColorMasks[0].Equals(Old.ColorMasks[0]))
{
GL.ColorMask(
- Index,
- New.ColorMasks[Index].Red,
- New.ColorMasks[Index].Green,
- New.ColorMasks[Index].Blue,
- New.ColorMasks[Index].Alpha);
+ New.ColorMasks[0].Red,
+ New.ColorMasks[0].Green,
+ New.ColorMasks[0].Blue,
+ New.ColorMasks[0].Alpha);
+ }
+ }
+ else
+ {
+ for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++)
+ {
+ if (!New.ColorMasks[Index].Equals(Old.ColorMasks[Index]))
+ {
+ GL.ColorMask(
+ Index,
+ New.ColorMasks[Index].Red,
+ New.ColorMasks[Index].Green,
+ New.ColorMasks[Index].Blue,
+ New.ColorMasks[Index].Alpha);
+ }
}
}
@@ -477,7 +489,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
if (!Dict.TryGetValue(Attrib.Size, out VertexAttribPointerType Type))
{
- throw new NotImplementedException("Unsupported size \"" + Attrib.Size + "\" on type \"" + Attrib.Type + "\"!");
+ ThrowUnsupportedAttrib(Attrib);
}
return Type;
@@ -485,15 +497,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
private unsafe static void SetConstAttrib(GalVertexAttrib Attrib)
{
- void Unsupported()
- {
- throw new NotImplementedException("Constant attribute " + Attrib.Size + " not implemented!");
- }
-
if (Attrib.Size == GalVertexAttribSize._10_10_10_2 ||
Attrib.Size == GalVertexAttribSize._11_11_10)
{
- Unsupported();
+ ThrowUnsupportedAttrib(Attrib);
}
if (Attrib.Type == GalVertexAttribType.Unorm)
@@ -611,11 +618,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GL.VertexAttrib4(Attrib.Index, (float*)Attrib.Pointer);
break;
- default: Unsupported(); break;
+ default: ThrowUnsupportedAttrib(Attrib); break;
}
}
}
+ private static void ThrowUnsupportedAttrib(GalVertexAttrib Attrib)
+ {
+ throw new NotImplementedException("Unsupported size \"" + Attrib.Size + "\" on type \"" + Attrib.Type + "\"!");
+ }
+
private void Enable(EnableCap Cap, bool Enabled)
{
if (Enabled)