forked from Mirror/Ryujinx
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
This commit is contained in:
parent
2fd23577ce
commit
f0a49a1c94
4 changed files with 59 additions and 46 deletions
|
@ -37,11 +37,11 @@
|
||||||
|
|
||||||
public GalFrontFace FrontFace;
|
public GalFrontFace FrontFace;
|
||||||
|
|
||||||
public bool CullFaceEnabled;
|
public bool CullFaceEnabled;
|
||||||
public GalCullFace CullFace;
|
public GalCullFace CullFace;
|
||||||
|
|
||||||
public bool DepthTestEnabled;
|
public bool DepthTestEnabled;
|
||||||
public bool DepthWriteEnabled;
|
public bool DepthWriteEnabled;
|
||||||
public GalComparisonOp DepthFunc;
|
public GalComparisonOp DepthFunc;
|
||||||
public float DepthRangeNear;
|
public float DepthRangeNear;
|
||||||
public float DepthRangeFar;
|
public float DepthRangeFar;
|
||||||
|
@ -50,31 +50,31 @@
|
||||||
public bool StencilTwoSideEnabled;
|
public bool StencilTwoSideEnabled;
|
||||||
|
|
||||||
public GalComparisonOp StencilBackFuncFunc;
|
public GalComparisonOp StencilBackFuncFunc;
|
||||||
public int StencilBackFuncRef;
|
public int StencilBackFuncRef;
|
||||||
public uint StencilBackFuncMask;
|
public uint StencilBackFuncMask;
|
||||||
public GalStencilOp StencilBackOpFail;
|
public GalStencilOp StencilBackOpFail;
|
||||||
public GalStencilOp StencilBackOpZFail;
|
public GalStencilOp StencilBackOpZFail;
|
||||||
public GalStencilOp StencilBackOpZPass;
|
public GalStencilOp StencilBackOpZPass;
|
||||||
public uint StencilBackMask;
|
public uint StencilBackMask;
|
||||||
|
|
||||||
public GalComparisonOp StencilFrontFuncFunc;
|
public GalComparisonOp StencilFrontFuncFunc;
|
||||||
public int StencilFrontFuncRef;
|
public int StencilFrontFuncRef;
|
||||||
public uint StencilFrontFuncMask;
|
public uint StencilFrontFuncMask;
|
||||||
public GalStencilOp StencilFrontOpFail;
|
public GalStencilOp StencilFrontOpFail;
|
||||||
public GalStencilOp StencilFrontOpZFail;
|
public GalStencilOp StencilFrontOpZFail;
|
||||||
public GalStencilOp StencilFrontOpZPass;
|
public GalStencilOp StencilFrontOpZPass;
|
||||||
public uint StencilFrontMask;
|
public uint StencilFrontMask;
|
||||||
|
|
||||||
public bool BlendEnabled;
|
public bool BlendEnabled;
|
||||||
public bool BlendSeparateAlpha;
|
public bool BlendSeparateAlpha;
|
||||||
public GalBlendEquation BlendEquationRgb;
|
public GalBlendEquation BlendEquationRgb;
|
||||||
public GalBlendFactor BlendFuncSrcRgb;
|
public GalBlendFactor BlendFuncSrcRgb;
|
||||||
public GalBlendFactor BlendFuncDstRgb;
|
public GalBlendFactor BlendFuncDstRgb;
|
||||||
public GalBlendEquation BlendEquationAlpha;
|
public GalBlendEquation BlendEquationAlpha;
|
||||||
public GalBlendFactor BlendFuncSrcAlpha;
|
public GalBlendFactor BlendFuncSrcAlpha;
|
||||||
public GalBlendFactor BlendFuncDstAlpha;
|
public GalBlendFactor BlendFuncDstAlpha;
|
||||||
|
|
||||||
public ColorMaskRgba ColorMask;
|
public bool ColorMaskCommon;
|
||||||
public ColorMaskRgba[] ColorMasks;
|
public ColorMaskRgba[] ColorMasks;
|
||||||
|
|
||||||
public bool PrimitiveRestartEnabled;
|
public bool PrimitiveRestartEnabled;
|
||||||
|
|
|
@ -131,8 +131,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
BlendFuncSrcAlpha = GalBlendFactor.One,
|
BlendFuncSrcAlpha = GalBlendFactor.One,
|
||||||
BlendFuncDstAlpha = GalBlendFactor.Zero,
|
BlendFuncDstAlpha = GalBlendFactor.Zero,
|
||||||
|
|
||||||
ColorMask = ColorMaskRgba.Default,
|
|
||||||
|
|
||||||
PrimitiveRestartEnabled = false,
|
PrimitiveRestartEnabled = false,
|
||||||
PrimitiveRestartIndex = 0
|
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(
|
GL.ColorMask(
|
||||||
Index,
|
New.ColorMasks[0].Red,
|
||||||
New.ColorMasks[Index].Red,
|
New.ColorMasks[0].Green,
|
||||||
New.ColorMasks[Index].Green,
|
New.ColorMasks[0].Blue,
|
||||||
New.ColorMasks[Index].Blue,
|
New.ColorMasks[0].Alpha);
|
||||||
New.ColorMasks[Index].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))
|
if (!Dict.TryGetValue(Attrib.Size, out VertexAttribPointerType Type))
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("Unsupported size \"" + Attrib.Size + "\" on type \"" + Attrib.Type + "\"!");
|
ThrowUnsupportedAttrib(Attrib);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Type;
|
return Type;
|
||||||
|
@ -485,15 +497,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
private unsafe static void SetConstAttrib(GalVertexAttrib Attrib)
|
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 ||
|
if (Attrib.Size == GalVertexAttribSize._10_10_10_2 ||
|
||||||
Attrib.Size == GalVertexAttribSize._11_11_10)
|
Attrib.Size == GalVertexAttribSize._11_11_10)
|
||||||
{
|
{
|
||||||
Unsupported();
|
ThrowUnsupportedAttrib(Attrib);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Attrib.Type == GalVertexAttribType.Unorm)
|
if (Attrib.Type == GalVertexAttribType.Unorm)
|
||||||
|
@ -611,11 +618,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
GL.VertexAttrib4(Attrib.Index, (float*)Attrib.Pointer);
|
GL.VertexAttrib4(Attrib.Index, (float*)Attrib.Pointer);
|
||||||
break;
|
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)
|
private void Enable(EnableCap Cap, bool Enabled)
|
||||||
{
|
{
|
||||||
if (Enabled)
|
if (Enabled)
|
||||||
|
|
|
@ -64,6 +64,10 @@ namespace Ryujinx.Graphics
|
||||||
{
|
{
|
||||||
UploadedKeys[i] = new List<long>();
|
UploadedKeys[i] = new List<long>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Ensure that all components are enabled by default.
|
||||||
|
//FIXME: Is this correct?
|
||||||
|
WriteRegister(NvGpuEngine3dReg.ColorMaskN, 0x1111);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CallMethod(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
|
public void CallMethod(NvGpuVmm Vmm, NvGpuPBEntry PBEntry)
|
||||||
|
@ -420,16 +424,13 @@ namespace Ryujinx.Graphics
|
||||||
|
|
||||||
private void SetColorMask(GalPipelineState State)
|
private void SetColorMask(GalPipelineState State)
|
||||||
{
|
{
|
||||||
int ColorMask = ReadRegister(NvGpuEngine3dReg.ColorMask);
|
bool ColorMaskCommon = ReadRegisterBool(NvGpuEngine3dReg.ColorMaskCommon);
|
||||||
|
|
||||||
State.ColorMask.Red = ((ColorMask >> 0) & 0xf) != 0;
|
State.ColorMaskCommon = ColorMaskCommon;
|
||||||
State.ColorMask.Green = ((ColorMask >> 4) & 0xf) != 0;
|
|
||||||
State.ColorMask.Blue = ((ColorMask >> 8) & 0xf) != 0;
|
|
||||||
State.ColorMask.Alpha = ((ColorMask >> 12) & 0xf) != 0;
|
|
||||||
|
|
||||||
for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++)
|
for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++)
|
||||||
{
|
{
|
||||||
ColorMask = ReadRegister(NvGpuEngine3dReg.ColorMaskN + Index);
|
int ColorMask = ReadRegister(NvGpuEngine3dReg.ColorMaskN + (ColorMaskCommon ? 0 : Index));
|
||||||
|
|
||||||
State.ColorMasks[Index].Red = ((ColorMask >> 0) & 0xf) != 0;
|
State.ColorMasks[Index].Red = ((ColorMask >> 0) & 0xf) != 0;
|
||||||
State.ColorMasks[Index].Green = ((ColorMask >> 4) & 0xf) != 0;
|
State.ColorMasks[Index].Green = ((ColorMask >> 4) & 0xf) != 0;
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Ryujinx.Graphics
|
||||||
StencilBackFuncRef = 0x3d5,
|
StencilBackFuncRef = 0x3d5,
|
||||||
StencilBackMask = 0x3d6,
|
StencilBackMask = 0x3d6,
|
||||||
StencilBackFuncMask = 0x3d7,
|
StencilBackFuncMask = 0x3d7,
|
||||||
ColorMask = 0x3e4,
|
ColorMaskCommon = 0x3e4,
|
||||||
RTSeparateFragData = 0x3eb,
|
RTSeparateFragData = 0x3eb,
|
||||||
ZetaAddress = 0x3f8,
|
ZetaAddress = 0x3f8,
|
||||||
ZetaFormat = 0x3fa,
|
ZetaFormat = 0x3fa,
|
||||||
|
|
Loading…
Reference in a new issue