Implement DepthWriteMask and add R16G16 (#425)

This commit is contained in:
ReinUsesLisp 2018-09-19 22:02:11 -03:00 committed by gdkchan
parent bed13f2022
commit 47a62e826f
6 changed files with 46 additions and 14 deletions

View file

@ -85,6 +85,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
CullFace = GalCullFace.Back,
DepthTestEnabled = false,
DepthWriteEnabled = true,
DepthFunc = GalComparisonOp.Less,
StencilTestEnabled = false,
@ -138,19 +139,19 @@ namespace Ryujinx.Graphics.Gal.OpenGL
//Note: Uncomment SetFrontFace and SetCullFace when flipping issues are solved
//if (New.FrontFace != O.FrontFace)
//if (New.FrontFace != Old.FrontFace)
//{
// GL.FrontFace(OGLEnumConverter.GetFrontFace(New.FrontFace));
//}
//if (New.CullFaceEnabled != O.CullFaceEnabled)
//if (New.CullFaceEnabled != Old.CullFaceEnabled)
//{
// Enable(EnableCap.CullFace, New.CullFaceEnabled);
//}
//if (New.CullFaceEnabled)
//{
// if (New.CullFace != O.CullFace)
// if (New.CullFace != Old.CullFace)
// {
// GL.CullFace(OGLEnumConverter.GetCullFace(New.CullFace));
// }
@ -161,6 +162,13 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Enable(EnableCap.DepthTest, New.DepthTestEnabled);
}
if (New.DepthWriteEnabled != Old.DepthWriteEnabled)
{
Rasterizer.DepthWriteEnabled = New.DepthWriteEnabled;
GL.DepthMask(New.DepthWriteEnabled);
}
if (New.DepthTestEnabled)
{
if (New.DepthFunc != Old.DepthFunc)

View file

@ -5,6 +5,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
class OGLRasterizer : IGalRasterizer
{
public bool DepthWriteEnabled { set; private get; }
private int[] VertexBuffers;
private OGLCachedResource<int> VboCache;
@ -28,6 +30,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
IboCache = new OGLCachedResource<int>(GL.DeleteBuffer);
IndexBuffer = new IbInfo();
DepthWriteEnabled = true;
}
public void LockCaches()
@ -49,6 +53,12 @@ namespace Ryujinx.Graphics.Gal.OpenGL
float Depth,
int Stencil)
{
//OpenGL needs glDepthMask to be enabled to clear it
if (!DepthWriteEnabled)
{
GL.DepthMask(true);
}
GL.ColorMask(
Flags.HasFlag(GalClearBufferFlags.ColorRed),
Flags.HasFlag(GalClearBufferFlags.ColorGreen),
@ -68,6 +78,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
}
GL.ColorMask(true, true, true, true);
if (!DepthWriteEnabled)
{
GL.DepthMask(false);
}
}
public bool IsVboCached(long Key, long DataSize)