aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/OpenGL
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-10-17 18:02:23 -0300
committerGitHub <noreply@github.com>2018-10-17 18:02:23 -0300
commit0e1e094b7a8f0134831fc4cebdb0841b9c10fe6a (patch)
tree81ba6446851a033f27adeafbfb94751032108047 /Ryujinx.Graphics/Gal/OpenGL
parent02a8e7fc9369d7882db08a69d108beefb0f98677 (diff)
Improve texture tables (#457)
* Improve texture tables * More renaming and other tweaks * Minor tweaks
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL')
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs121
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs38
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs26
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs13
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs21
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs75
6 files changed, 140 insertions, 154 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
index 9a3a1a98..6b3d4fd6 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
@@ -127,55 +127,54 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
switch (Format)
{
- case GalImageFormat.R32G32B32A32 | GalImageFormat.Sfloat: return (PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float);
- case GalImageFormat.R32G32B32A32 | GalImageFormat.Sint: return (PixelInternalFormat.Rgba32i, PixelFormat.RgbaInteger, PixelType.Int);
- case GalImageFormat.R32G32B32A32 | GalImageFormat.Uint: return (PixelInternalFormat.Rgba32ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt);
- case GalImageFormat.R16G16B16A16 | GalImageFormat.Sfloat: return (PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.HalfFloat);
- case GalImageFormat.R16G16B16A16 | GalImageFormat.Sint: return (PixelInternalFormat.Rgba16i, PixelFormat.RgbaInteger, PixelType.Short);
- case GalImageFormat.R16G16B16A16 | GalImageFormat.Uint: return (PixelInternalFormat.Rgba16ui, PixelFormat.RgbaInteger, PixelType.UnsignedShort);
- case GalImageFormat.R32G32 | GalImageFormat.Sfloat: return (PixelInternalFormat.Rg32f, PixelFormat.Rg, PixelType.Float);
- case GalImageFormat.R32G32 | GalImageFormat.Sint: return (PixelInternalFormat.Rg32i, PixelFormat.RgInteger, PixelType.Int);
- case GalImageFormat.R32G32 | GalImageFormat.Uint: return (PixelInternalFormat.Rg32ui, PixelFormat.RgInteger, PixelType.UnsignedInt);
- case GalImageFormat.A8B8G8R8 | GalImageFormat.Snorm: return (PixelInternalFormat.Rgba8Snorm, PixelFormat.Rgba, PixelType.Byte);
- case GalImageFormat.A8B8G8R8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba8, PixelFormat.Rgba, PixelType.UnsignedByte);
- case GalImageFormat.A8B8G8R8 | GalImageFormat.Sint: return (PixelInternalFormat.Rgba8i, PixelFormat.RgbaInteger, PixelType.Byte);
- case GalImageFormat.A8B8G8R8 | GalImageFormat.Uint: return (PixelInternalFormat.Rgba8ui, PixelFormat.RgbaInteger, PixelType.UnsignedByte);
- case GalImageFormat.A8B8G8R8_SRGB: return (PixelInternalFormat.Srgb8Alpha8, PixelFormat.Rgba, PixelType.UnsignedByte);
- case GalImageFormat.B8G8R8A8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba8, PixelFormat.Bgra, PixelType.UnsignedByte);
- case GalImageFormat.A4B4G4R4 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba4, PixelFormat.Rgba, PixelType.UnsignedShort4444Reversed);
- case GalImageFormat.A2B10G10R10 | GalImageFormat.Uint: return (PixelInternalFormat.Rgb10A2ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt2101010Reversed);
- case GalImageFormat.A2B10G10R10 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgb10A2, PixelFormat.Rgba, PixelType.UnsignedInt2101010Reversed);
- case GalImageFormat.R32 | GalImageFormat.Sfloat: return (PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float);
- case GalImageFormat.R32 | GalImageFormat.Sint: return (PixelInternalFormat.R32i, PixelFormat.Red, PixelType.Int);
- case GalImageFormat.R32 | GalImageFormat.Uint: return (PixelInternalFormat.R32ui, PixelFormat.Red, PixelType.UnsignedInt);
- case GalImageFormat.A1R5G5B5 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgb5A1, PixelFormat.Rgba, PixelType.UnsignedShort1555Reversed);
- case GalImageFormat.B5G6R5 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba, PixelFormat.Rgb, PixelType.UnsignedShort565Reversed);
- case GalImageFormat.R16G16 | GalImageFormat.Sfloat: return (PixelInternalFormat.Rg16f, PixelFormat.Rg, PixelType.HalfFloat);
- case GalImageFormat.R16G16 | GalImageFormat.Sint: return (PixelInternalFormat.Rg16i, PixelFormat.RgInteger, PixelType.Short);
- case GalImageFormat.R16G16 | GalImageFormat.Snorm: return (PixelInternalFormat.Rg16Snorm, PixelFormat.Rg, PixelType.Byte);
- case GalImageFormat.R16G16 | GalImageFormat.Unorm: return (PixelInternalFormat.Rg16, PixelFormat.Rg, PixelType.UnsignedShort);
- case GalImageFormat.R8G8 | GalImageFormat.Sint: return (PixelInternalFormat.Rg8i, PixelFormat.RgInteger, PixelType.Byte);
- case GalImageFormat.R8G8 | GalImageFormat.Snorm: return (PixelInternalFormat.Rg8Snorm, PixelFormat.Rg, PixelType.Byte);
- case GalImageFormat.R8G8 | GalImageFormat.Uint: return (PixelInternalFormat.Rg8ui, PixelFormat.RgInteger, PixelType.UnsignedByte);
- case GalImageFormat.R8G8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rg8, PixelFormat.Rg, PixelType.UnsignedByte);
- case GalImageFormat.G8R8 | GalImageFormat.Snorm: return (PixelInternalFormat.Rg8Snorm, PixelFormat.Rg, PixelType.Byte);
- case GalImageFormat.G8R8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rg8, PixelFormat.Rg, PixelType.UnsignedByte);
- case GalImageFormat.R16 | GalImageFormat.Sfloat: return (PixelInternalFormat.R16f, PixelFormat.Red, PixelType.HalfFloat);
- case GalImageFormat.R16 | GalImageFormat.Sint: return (PixelInternalFormat.R16i, PixelFormat.RedInteger, PixelType.Short);
- case GalImageFormat.R16 | GalImageFormat.Snorm: return (PixelInternalFormat.R16Snorm, PixelFormat.Red, PixelType.Byte);
- case GalImageFormat.R16 | GalImageFormat.Uint: return (PixelInternalFormat.R16ui, PixelFormat.RedInteger, PixelType.UnsignedShort);
- case GalImageFormat.R16 | GalImageFormat.Unorm: return (PixelInternalFormat.R16, PixelFormat.Red, PixelType.UnsignedShort);
- case GalImageFormat.R8 | GalImageFormat.Sint: return (PixelInternalFormat.R8i, PixelFormat.RedInteger, PixelType.Byte);
- case GalImageFormat.R8 | GalImageFormat.Snorm: return (PixelInternalFormat.R8Snorm, PixelFormat.Red, PixelType.Byte);
- case GalImageFormat.R8 | GalImageFormat.Uint: return (PixelInternalFormat.R8ui, PixelFormat.RedInteger, PixelType.UnsignedByte);
- case GalImageFormat.R8 | GalImageFormat.Unorm: return (PixelInternalFormat.R8, PixelFormat.Red, PixelType.UnsignedByte);
- case GalImageFormat.B10G11R11 | GalImageFormat.Sfloat: return (PixelInternalFormat.R11fG11fB10f, PixelFormat.Rgb, PixelType.UnsignedInt10F11F11FRev);
-
- case GalImageFormat.D24_S8 | GalImageFormat.Uint: return (PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248);
- case GalImageFormat.D24_S8 | GalImageFormat.Unorm: return (PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248);
- case GalImageFormat.D32 | GalImageFormat.Sfloat: return (PixelInternalFormat.DepthComponent32f, PixelFormat.DepthComponent, PixelType.Float);
- case GalImageFormat.D16 | GalImageFormat.Unorm: return (PixelInternalFormat.DepthComponent16, PixelFormat.DepthComponent, PixelType.UnsignedShort);
- case GalImageFormat.D32_S8 | GalImageFormat.Sfloat: return (PixelInternalFormat.Depth32fStencil8, PixelFormat.DepthStencil, PixelType.Float32UnsignedInt248Rev);
+ case GalImageFormat.RGBA32 | GalImageFormat.Float: return (PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float);
+ case GalImageFormat.RGBA32 | GalImageFormat.Sint: return (PixelInternalFormat.Rgba32i, PixelFormat.RgbaInteger, PixelType.Int);
+ case GalImageFormat.RGBA32 | GalImageFormat.Uint: return (PixelInternalFormat.Rgba32ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt);
+ case GalImageFormat.RGBA16 | GalImageFormat.Float: return (PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.HalfFloat);
+ case GalImageFormat.RGBA16 | GalImageFormat.Sint: return (PixelInternalFormat.Rgba16i, PixelFormat.RgbaInteger, PixelType.Short);
+ case GalImageFormat.RGBA16 | GalImageFormat.Uint: return (PixelInternalFormat.Rgba16ui, PixelFormat.RgbaInteger, PixelType.UnsignedShort);
+ case GalImageFormat.RG32 | GalImageFormat.Float: return (PixelInternalFormat.Rg32f, PixelFormat.Rg, PixelType.Float);
+ case GalImageFormat.RG32 | GalImageFormat.Sint: return (PixelInternalFormat.Rg32i, PixelFormat.RgInteger, PixelType.Int);
+ case GalImageFormat.RG32 | GalImageFormat.Uint: return (PixelInternalFormat.Rg32ui, PixelFormat.RgInteger, PixelType.UnsignedInt);
+ case GalImageFormat.RGBA8 | GalImageFormat.Snorm: return (PixelInternalFormat.Rgba8Snorm, PixelFormat.Rgba, PixelType.Byte);
+ case GalImageFormat.RGBA8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba8, PixelFormat.Rgba, PixelType.UnsignedByte);
+ case GalImageFormat.RGBA8 | GalImageFormat.Sint: return (PixelInternalFormat.Rgba8i, PixelFormat.RgbaInteger, PixelType.Byte);
+ case GalImageFormat.RGBA8 | GalImageFormat.Uint: return (PixelInternalFormat.Rgba8ui, PixelFormat.RgbaInteger, PixelType.UnsignedByte);
+ case GalImageFormat.RGBA8 | GalImageFormat.Srgb: return (PixelInternalFormat.Srgb8Alpha8, PixelFormat.Rgba, PixelType.UnsignedByte);
+ case GalImageFormat.BGRA8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba8, PixelFormat.Bgra, PixelType.UnsignedByte);
+ case GalImageFormat.RGBA4 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba4, PixelFormat.Rgba, PixelType.UnsignedShort4444Reversed);
+ case GalImageFormat.RGB10A2 | GalImageFormat.Uint: return (PixelInternalFormat.Rgb10A2ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt2101010Reversed);
+ case GalImageFormat.RGB10A2 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgb10A2, PixelFormat.Rgba, PixelType.UnsignedInt2101010Reversed);
+ case GalImageFormat.R32 | GalImageFormat.Float: return (PixelInternalFormat.R32f, PixelFormat.Red, PixelType.Float);
+ case GalImageFormat.R32 | GalImageFormat.Sint: return (PixelInternalFormat.R32i, PixelFormat.Red, PixelType.Int);
+ case GalImageFormat.R32 | GalImageFormat.Uint: return (PixelInternalFormat.R32ui, PixelFormat.Red, PixelType.UnsignedInt);
+ case GalImageFormat.RGB5A1 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgb5A1, PixelFormat.Rgba, PixelType.UnsignedShort1555Reversed);
+ case GalImageFormat.RGB565 | GalImageFormat.Unorm: return (PixelInternalFormat.Rgba, PixelFormat.Rgb, PixelType.UnsignedShort565Reversed);
+ case GalImageFormat.RG16 | GalImageFormat.Float: return (PixelInternalFormat.Rg16f, PixelFormat.Rg, PixelType.HalfFloat);
+ case GalImageFormat.RG16 | GalImageFormat.Sint: return (PixelInternalFormat.Rg16i, PixelFormat.RgInteger, PixelType.Short);
+ case GalImageFormat.RG16 | GalImageFormat.Snorm: return (PixelInternalFormat.Rg16Snorm, PixelFormat.Rg, PixelType.Short);
+ case GalImageFormat.RG16 | GalImageFormat.Uint: return (PixelInternalFormat.Rg16ui, PixelFormat.RgInteger, PixelType.UnsignedShort);
+ case GalImageFormat.RG16 | GalImageFormat.Unorm: return (PixelInternalFormat.Rg16, PixelFormat.Rg, PixelType.UnsignedShort);
+ case GalImageFormat.RG8 | GalImageFormat.Sint: return (PixelInternalFormat.Rg8i, PixelFormat.RgInteger, PixelType.Byte);
+ case GalImageFormat.RG8 | GalImageFormat.Snorm: return (PixelInternalFormat.Rg8Snorm, PixelFormat.Rg, PixelType.Byte);
+ case GalImageFormat.RG8 | GalImageFormat.Uint: return (PixelInternalFormat.Rg8ui, PixelFormat.RgInteger, PixelType.UnsignedByte);
+ case GalImageFormat.RG8 | GalImageFormat.Unorm: return (PixelInternalFormat.Rg8, PixelFormat.Rg, PixelType.UnsignedByte);
+ case GalImageFormat.R16 | GalImageFormat.Float: return (PixelInternalFormat.R16f, PixelFormat.Red, PixelType.HalfFloat);
+ case GalImageFormat.R16 | GalImageFormat.Sint: return (PixelInternalFormat.R16i, PixelFormat.RedInteger, PixelType.Short);
+ case GalImageFormat.R16 | GalImageFormat.Snorm: return (PixelInternalFormat.R16Snorm, PixelFormat.Red, PixelType.Short);
+ case GalImageFormat.R16 | GalImageFormat.Uint: return (PixelInternalFormat.R16ui, PixelFormat.RedInteger, PixelType.UnsignedShort);
+ case GalImageFormat.R16 | GalImageFormat.Unorm: return (PixelInternalFormat.R16, PixelFormat.Red, PixelType.UnsignedShort);
+ case GalImageFormat.R8 | GalImageFormat.Sint: return (PixelInternalFormat.R8i, PixelFormat.RedInteger, PixelType.Byte);
+ case GalImageFormat.R8 | GalImageFormat.Snorm: return (PixelInternalFormat.R8Snorm, PixelFormat.Red, PixelType.Byte);
+ case GalImageFormat.R8 | GalImageFormat.Uint: return (PixelInternalFormat.R8ui, PixelFormat.RedInteger, PixelType.UnsignedByte);
+ case GalImageFormat.R8 | GalImageFormat.Unorm: return (PixelInternalFormat.R8, PixelFormat.Red, PixelType.UnsignedByte);
+ case GalImageFormat.R11G11B10 | GalImageFormat.Float: return (PixelInternalFormat.R11fG11fB10f, PixelFormat.Rgb, PixelType.UnsignedInt10F11F11FRev);
+
+ case GalImageFormat.D24S8 | GalImageFormat.Uint: return (PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248);
+ case GalImageFormat.D24S8 | GalImageFormat.Unorm: return (PixelInternalFormat.Depth24Stencil8, PixelFormat.DepthStencil, PixelType.UnsignedInt248);
+ case GalImageFormat.D32 | GalImageFormat.Float: return (PixelInternalFormat.DepthComponent32f, PixelFormat.DepthComponent, PixelType.Float);
+ case GalImageFormat.D16 | GalImageFormat.Unorm: return (PixelInternalFormat.DepthComponent16, PixelFormat.DepthComponent, PixelType.UnsignedShort);
+ case GalImageFormat.D32S8 | GalImageFormat.Float: return (PixelInternalFormat.Depth32fStencil8, PixelFormat.DepthStencil, PixelType.Float32UnsignedInt248Rev);
}
throw new NotImplementedException($"{Format & GalImageFormat.FormatMask} {Format & GalImageFormat.TypeMask}");
@@ -185,16 +184,20 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
switch (Format)
{
- case GalImageFormat.BC6H_UF16 | GalImageFormat.Sfloat: return InternalFormat.CompressedRgbBptcUnsignedFloat;
- case GalImageFormat.BC6H_SF16 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbBptcSignedFloat;
- case GalImageFormat.BC7 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaBptcUnorm;
- case GalImageFormat.BC1_RGBA | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt1Ext;
- case GalImageFormat.BC2 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt3Ext;
- case GalImageFormat.BC3 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt5Ext;
- case GalImageFormat.BC4 | GalImageFormat.Snorm: return InternalFormat.CompressedSignedRedRgtc1;
- case GalImageFormat.BC4 | GalImageFormat.Unorm: return InternalFormat.CompressedRedRgtc1;
- case GalImageFormat.BC5 | GalImageFormat.Snorm: return InternalFormat.CompressedSignedRgRgtc2;
- case GalImageFormat.BC5 | GalImageFormat.Unorm: return InternalFormat.CompressedRgRgtc2;
+ case GalImageFormat.BptcSfloat | GalImageFormat.Float: return InternalFormat.CompressedRgbBptcSignedFloat;
+ case GalImageFormat.BptcUfloat | GalImageFormat.Float: return InternalFormat.CompressedRgbBptcUnsignedFloat;
+ case GalImageFormat.BptcUnorm | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaBptcUnorm;
+ case GalImageFormat.BptcUnorm | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaBptcUnorm;
+ case GalImageFormat.BC1 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt1Ext;
+ case GalImageFormat.BC1 | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaS3tcDxt1Ext;
+ case GalImageFormat.BC2 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt3Ext;
+ case GalImageFormat.BC2 | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaS3tcDxt3Ext;
+ case GalImageFormat.BC3 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt5Ext;
+ case GalImageFormat.BC3 | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaS3tcDxt5Ext;
+ case GalImageFormat.BC4 | GalImageFormat.Snorm: return InternalFormat.CompressedSignedRedRgtc1;
+ case GalImageFormat.BC4 | GalImageFormat.Unorm: return InternalFormat.CompressedRedRgtc1;
+ case GalImageFormat.BC5 | GalImageFormat.Snorm: return InternalFormat.CompressedSignedRgRgtc2;
+ case GalImageFormat.BC5 | GalImageFormat.Unorm: return InternalFormat.CompressedRgRgtc2;
}
throw new NotImplementedException($"{Format & GalImageFormat.FormatMask} {Format & GalImageFormat.TypeMask}");
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs
index b7825996..00699641 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs
@@ -129,9 +129,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL
BlendFuncSrcAlpha = GalBlendFactor.One,
BlendFuncDstAlpha = GalBlendFactor.Zero,
+ ColorMask = ColorMaskRgba.Default,
+
PrimitiveRestartEnabled = false,
PrimitiveRestartIndex = 0
};
+
+ for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++)
+ {
+ Old.ColorMasks[Index] = ColorMaskRgba.Default;
+ }
}
public void Bind(GalPipelineState New)
@@ -177,8 +184,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
if (New.DepthWriteEnabled != Old.DepthWriteEnabled)
{
- Rasterizer.DepthWriteEnabled = New.DepthWriteEnabled;
-
GL.DepthMask(New.DepthWriteEnabled);
}
@@ -303,16 +308,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL
}
}
- if (New.ColorMaskR != Old.ColorMaskR ||
- New.ColorMaskG != Old.ColorMaskG ||
- New.ColorMaskB != Old.ColorMaskB ||
- New.ColorMaskA != Old.ColorMaskA)
+ for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++)
{
- GL.ColorMask(
- New.ColorMaskR,
- New.ColorMaskG,
- New.ColorMaskB,
- New.ColorMaskA);
+ 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);
+ }
}
if (New.PrimitiveRestartEnabled != Old.PrimitiveRestartEnabled)
@@ -613,5 +619,15 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GL.Disable(Cap);
}
}
+
+ public void ResetDepthMask()
+ {
+ Old.DepthWriteEnabled = true;
+ }
+
+ public void ResetColorMask(int Index)
+ {
+ Old.ColorMasks[Index] = ColorMaskRgba.Default;
+ }
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs
index 7b435c45..cefbb2d2 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs
@@ -5,8 +5,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
class OGLRasterizer : IGalRasterizer
{
- public bool DepthWriteEnabled { set; private get; }
-
private int[] VertexBuffers;
private OGLCachedResource<int> VboCache;
@@ -30,8 +28,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
IboCache = new OGLCachedResource<int>(GL.DeleteBuffer);
IndexBuffer = new IbInfo();
-
- DepthWriteEnabled = true;
}
public void LockCaches()
@@ -49,17 +45,15 @@ namespace Ryujinx.Graphics.Gal.OpenGL
public void ClearBuffers(
GalClearBufferFlags Flags,
int Attachment,
- float Red, float Green, float Blue, float Alpha,
+ float Red,
+ float Green,
+ float Blue,
+ float Alpha,
float Depth,
int Stencil)
{
- //OpenGL needs glDepthMask to be enabled to clear it
- if (!DepthWriteEnabled)
- {
- GL.DepthMask(true);
- }
-
GL.ColorMask(
+ Attachment,
Flags.HasFlag(GalClearBufferFlags.ColorRed),
Flags.HasFlag(GalClearBufferFlags.ColorGreen),
Flags.HasFlag(GalClearBufferFlags.ColorBlue),
@@ -67,6 +61,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GL.ClearBuffer(ClearBuffer.Color, Attachment, new float[] { Red, Green, Blue, Alpha });
+ GL.ColorMask(Attachment, true, true, true, true);
+ GL.DepthMask(true);
+
if (Flags.HasFlag(GalClearBufferFlags.Depth))
{
GL.ClearBuffer(ClearBuffer.Depth, 0, ref Depth);
@@ -76,13 +73,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
GL.ClearBuffer(ClearBuffer.Stencil, 0, ref Stencil);
}
-
- GL.ColorMask(true, true, true, true);
-
- if (!DepthWriteEnabled)
- {
- GL.DepthMask(false);
- }
}
public bool IsVboCached(long Key, long DataSize)
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs
index 0de070b5..e0c4854e 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs
@@ -59,9 +59,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
private const int NativeWidth = 1280;
private const int NativeHeight = 720;
- private const int RenderTargetsCount = 8;
-
- private const GalImageFormat RawFormat = GalImageFormat.A8B8G8R8 | GalImageFormat.Unorm;
+ private const int RenderTargetsCount = GalPipelineState.RenderTargetsCount;
private OGLTexture Texture;
@@ -115,15 +113,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL
for (int Attachment = 0; Attachment < RenderTargetsCount; Attachment++)
{
- if (Attachments.Colors[Attachment] == OldAttachments.Colors[Attachment])
+ long Key = Attachments.Colors[Attachment];
+
+ if (Key == OldAttachments.Colors[Attachment])
{
continue;
}
int Handle = 0;
- if (Attachments.Colors[Attachment] != 0 &&
- Texture.TryGetImageHandler(Attachments.Colors[Attachment], out CachedImage))
+ if (Key != 0 && Texture.TryGetImageHandler(Key, out CachedImage))
{
Handle = CachedImage.Handle;
}
@@ -178,7 +177,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
if (OGLExtension.ViewportArray)
{
- GL.ViewportArray(0, 8, Viewports);
+ GL.ViewportArray(0, RenderTargetsCount, Viewports);
}
else
{
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs
index efcb7e34..b45a3a3a 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs
@@ -55,16 +55,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GlslDecompiler Decompiler = new GlslDecompiler();
+ int ShaderDumpIndex = ShaderDumper.DumpIndex;
+
if (IsDualVp)
{
ShaderDumper.Dump(Memory, Position, Type, "a");
ShaderDumper.Dump(Memory, PositionB, Type, "b");
- Program = Decompiler.Decompile(
- Memory,
- Position,
- PositionB,
- Type);
+ Program = Decompiler.Decompile(Memory, Position, PositionB, Type);
}
else
{
@@ -73,11 +71,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Program = Decompiler.Decompile(Memory, Position, Type);
}
- return new OGLShaderStage(
- Type,
- Program.Code,
- Program.Uniforms,
- Program.Textures);
+ string Code = Program.Code;
+
+ if (ShaderDumper.IsDumpEnabled())
+ {
+ Code = "//Shader " + ShaderDumpIndex + Environment.NewLine + Code;
+ }
+
+ return new OGLShaderStage(Type, Code, Program.Uniforms, Program.Textures);
}
public IEnumerable<ShaderDeclInfo> GetConstBufferUsage(long Key)
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
index 3347afbd..6c608528 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
@@ -39,41 +39,25 @@ namespace Ryujinx.Graphics.Gal.OpenGL
TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Size);
- GalImageFormat TypeLess = Image.Format & GalImageFormat.FormatMask;
-
- bool IsASTC = TypeLess >= GalImageFormat.ASTC_BEGIN && TypeLess <= GalImageFormat.ASTC_END;
-
- if (ImageUtils.IsCompressed(Image.Format) && !IsASTC)
+ if (ImageUtils.IsCompressed(Image.Format))
{
- InternalFormat InternalFmt = OGLEnumConverter.GetCompressedImageFormat(Image.Format);
-
- GL.CompressedTexImage2D(
- TextureTarget.Texture2D,
- Level,
- InternalFmt,
- Image.Width,
- Image.Height,
- Border,
- Size,
- IntPtr.Zero);
+ throw new InvalidOperationException("Surfaces with compressed formats are not supported!");
}
- else
- {
- (PixelInternalFormat InternalFmt,
- PixelFormat Format,
- PixelType Type) = OGLEnumConverter.GetImageFormat(Image.Format);
- GL.TexImage2D(
- TextureTarget.Texture2D,
- Level,
- InternalFmt,
- Image.Width,
- Image.Height,
- Border,
- Format,
- Type,
- IntPtr.Zero);
- }
+ (PixelInternalFormat InternalFmt,
+ PixelFormat Format,
+ PixelType Type) = OGLEnumConverter.GetImageFormat(Image.Format);
+
+ GL.TexImage2D(
+ TextureTarget.Texture2D,
+ Level,
+ InternalFmt,
+ Image.Width,
+ Image.Height,
+ Border,
+ Format,
+ Type,
+ IntPtr.Zero);
}
public void Create(long Key, byte[] Data, GalImage Image)
@@ -87,11 +71,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Data.Length);
- GalImageFormat TypeLess = Image.Format & GalImageFormat.FormatMask;
-
- bool IsASTC = TypeLess >= GalImageFormat.ASTC_BEGIN && TypeLess <= GalImageFormat.ASTC_END;
-
- if (ImageUtils.IsCompressed(Image.Format) && !IsASTC)
+ if (ImageUtils.IsCompressed(Image.Format) && !IsAstc(Image.Format))
{
InternalFormat InternalFmt = OGLEnumConverter.GetCompressedImageFormat(Image.Format);
@@ -108,7 +88,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
else
{
//TODO: Use KHR_texture_compression_astc_hdr when available
- if (IsASTC)
+ if (IsAstc(Image.Format))
{
int TextureBlockWidth = ImageUtils.GetBlockWidth(Image.Format);
int TextureBlockHeight = ImageUtils.GetBlockHeight(Image.Format);
@@ -120,17 +100,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Image.Width,
Image.Height, 1);
- Image.Format = GalImageFormat.A8B8G8R8 | GalImageFormat.Unorm;
- }
- else if (TypeLess == GalImageFormat.G8R8)
- {
- Data = ImageConverter.G8R8ToR8G8(
- Data,
- Image.Width,
- Image.Height,
- 1);
-
- Image.Format = GalImageFormat.R8G8 | (Image.Format & GalImageFormat.TypeMask);
+ Image.Format = GalImageFormat.RGBA8 | GalImageFormat.Unorm;
}
(PixelInternalFormat InternalFmt,
@@ -150,6 +120,13 @@ namespace Ryujinx.Graphics.Gal.OpenGL
}
}
+ private static bool IsAstc(GalImageFormat Format)
+ {
+ Format &= GalImageFormat.FormatMask;
+
+ return Format > GalImageFormat.Astc2DStart && Format < GalImageFormat.Astc2DEnd;
+ }
+
public bool TryGetImage(long Key, out GalImage Image)
{
if (TextureCache.TryGetValue(Key, out ImageHandler CachedImage))