More renaming and other tweaks

This commit is contained in:
gdkchan 2018-10-15 15:38:28 -03:00
commit d545a123e3
8 changed files with 64 additions and 56 deletions

View file

@ -47,9 +47,9 @@ namespace Ryujinx.Graphics.Gal
BC3, BC3,
BC4, BC4,
BC5, BC5,
BC6H_SF16, BptcSfloat,
BC6H_UF16, BptcUfloat,
BC7, BptcUnorm,
Snorm = 1 << 26, Snorm = 1 << 26,
Unorm = 1 << 27, Unorm = 1 << 27,

View file

@ -9,12 +9,12 @@ namespace Ryujinx.Graphics.Gal
RGB10A2 = 0x9, RGB10A2 = 0x9,
RG16 = 0xc, RG16 = 0xc,
R32 = 0xf, R32 = 0xf,
BC6H_SF16 = 0x10, BptcSfloat = 0x10,
BC6H_UF16 = 0x11, BptcUfloat = 0x11,
RGBA4 = 0x12, RGBA4 = 0x12,
RGB5A1 = 0x14, RGB5A1 = 0x14,
RGB565 = 0x15, RGB565 = 0x15,
BC7U = 0x17, BptcUnorm = 0x17,
RG8 = 0x18, RG8 = 0x18,
R16 = 0x1b, R16 = 0x1b,
R8 = 0x1d, R8 = 0x1d,

View file

@ -184,9 +184,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{ {
switch (Format) switch (Format)
{ {
case GalImageFormat.BC6H_SF16 | GalImageFormat.Float: return InternalFormat.CompressedRgbBptcSignedFloat; case GalImageFormat.BptcSfloat | GalImageFormat.Float: return InternalFormat.CompressedRgbBptcSignedFloat;
case GalImageFormat.BC6H_UF16 | GalImageFormat.Float: return InternalFormat.CompressedRgbBptcUnsignedFloat; case GalImageFormat.BptcUfloat | GalImageFormat.Float: return InternalFormat.CompressedRgbBptcUnsignedFloat;
case GalImageFormat.BC7 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaBptcUnorm; 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.Unorm: return InternalFormat.CompressedRgbaS3tcDxt1Ext;
case GalImageFormat.BC1 | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaS3tcDxt1Ext; case GalImageFormat.BC1 | GalImageFormat.Srgb: return InternalFormat.CompressedSrgbAlphaS3tcDxt1Ext;
case GalImageFormat.BC2 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt3Ext; case GalImageFormat.BC2 | GalImageFormat.Unorm: return InternalFormat.CompressedRgbaS3tcDxt3Ext;

View file

@ -55,16 +55,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GlslDecompiler Decompiler = new GlslDecompiler(); GlslDecompiler Decompiler = new GlslDecompiler();
int ShaderDumpIndex = ShaderDumper.DumpIndex;
if (IsDualVp) if (IsDualVp)
{ {
ShaderDumper.Dump(Memory, Position, Type, "a"); ShaderDumper.Dump(Memory, Position, Type, "a");
ShaderDumper.Dump(Memory, PositionB, Type, "b"); ShaderDumper.Dump(Memory, PositionB, Type, "b");
Program = Decompiler.Decompile( Program = Decompiler.Decompile(Memory, Position, PositionB, Type);
Memory,
Position,
PositionB,
Type);
} }
else else
{ {
@ -73,11 +71,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Program = Decompiler.Decompile(Memory, Position, Type); Program = Decompiler.Decompile(Memory, Position, Type);
} }
return new OGLShaderStage( string Code = Program.Code;
Type,
Program.Code, if (ShaderDumper.IsDumpEnabled())
Program.Uniforms, {
Program.Textures); Code = "//Shader " + ShaderDumpIndex + Environment.NewLine + Code;
}
return new OGLShaderStage(Type, Code, Program.Uniforms, Program.Textures);
} }
public IEnumerable<ShaderDeclInfo> GetConstBufferUsage(long Key) public IEnumerable<ShaderDeclInfo> GetConstBufferUsage(long Key)

View file

@ -100,7 +100,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Image.Width, Image.Width,
Image.Height, 1); Image.Height, 1);
Image.Format = GalImageFormat.RGBA8 | (Image.Format & GalImageFormat.TypeMask); Image.Format = GalImageFormat.RGBA8 | GalImageFormat.Unorm;
} }
(PixelInternalFormat InternalFmt, (PixelInternalFormat InternalFmt,

View file

@ -165,7 +165,7 @@ namespace Ryujinx.Graphics.Gal.Shader
DbgOpCode += (Decode?.Method.Name ?? "???"); DbgOpCode += (Decode?.Method.Name ?? "???");
if (Decode == ShaderDecode.Bra) if (Decode == ShaderDecode.Bra || Decode == ShaderDecode.Ssy)
{ {
int Offset = ((int)(OpCode >> 20) << 8) >> 8; int Offset = ((int)(OpCode >> 20) << 8) >> 8;

View file

@ -7,11 +7,11 @@ namespace Ryujinx.Graphics.Gal
{ {
private static string RuntimeDir; private static string RuntimeDir;
private static int DumpIndex = 1; public static int DumpIndex { get; private set; } = 1;
public static void Dump(IGalMemory Memory, long Position, GalShaderType Type, string ExtSuffix = "") public static void Dump(IGalMemory Memory, long Position, GalShaderType Type, string ExtSuffix = "")
{ {
if (string.IsNullOrWhiteSpace(GraphicsConfig.ShadersDumpPath)) if (!IsDumpEnabled())
{ {
return; return;
} }
@ -25,9 +25,10 @@ namespace Ryujinx.Graphics.Gal
using (FileStream FullFile = File.Create(FullPath)) using (FileStream FullFile = File.Create(FullPath))
using (FileStream CodeFile = File.Create(CodePath)) using (FileStream CodeFile = File.Create(CodePath))
using (BinaryWriter FullWriter = new BinaryWriter(FullFile))
using (BinaryWriter CodeWriter = new BinaryWriter(CodeFile))
{ {
BinaryWriter FullWriter = new BinaryWriter(FullFile);
BinaryWriter CodeWriter = new BinaryWriter(CodeFile);
for (long i = 0; i < 0x50; i += 4) for (long i = 0; i < 0x50; i += 4)
{ {
FullWriter.Write(Memory.ReadInt32(Position + i)); FullWriter.Write(Memory.ReadInt32(Position + i));
@ -69,6 +70,11 @@ namespace Ryujinx.Graphics.Gal
} }
} }
public static bool IsDumpEnabled()
{
return !string.IsNullOrWhiteSpace(GraphicsConfig.ShadersDumpPath);
}
private static string FullDir() private static string FullDir()
{ {
return CreateAndReturn(Path.Combine(DumpDir(), "Full")); return CreateAndReturn(Path.Combine(DumpDir(), "Full"));

View file

@ -65,9 +65,9 @@ namespace Ryujinx.Graphics.Texture
{ GalTextureFormat.D16, GalImageFormat.D16 | Unorm }, { GalTextureFormat.D16, GalImageFormat.D16 | Unorm },
//Compressed formats //Compressed formats
{ GalTextureFormat.BC6H_SF16, GalImageFormat.BC6H_SF16 | Unorm }, { GalTextureFormat.BptcSfloat, GalImageFormat.BptcSfloat | Float },
{ GalTextureFormat.BC6H_UF16, GalImageFormat.BC6H_UF16 | Float }, { GalTextureFormat.BptcUfloat, GalImageFormat.BptcUfloat | Float },
{ GalTextureFormat.BC7U, GalImageFormat.BC7 | Unorm }, { GalTextureFormat.BptcUnorm, GalImageFormat.BptcUnorm | Unorm | Srgb },
{ GalTextureFormat.BC1, GalImageFormat.BC1 | Unorm | Srgb }, { GalTextureFormat.BC1, GalImageFormat.BC1 | Unorm | Srgb },
{ GalTextureFormat.BC2, GalImageFormat.BC2 | Unorm | Srgb }, { GalTextureFormat.BC2, GalImageFormat.BC2 | Unorm | Srgb },
{ GalTextureFormat.BC3, GalImageFormat.BC3 | Unorm | Srgb }, { GalTextureFormat.BC3, GalImageFormat.BC3 | Unorm | Srgb },
@ -100,11 +100,11 @@ namespace Ryujinx.Graphics.Texture
{ GalImageFormat.RGB10A2, new ImageDescriptor(4, 1, 1, TargetBuffer.Color) }, { GalImageFormat.RGB10A2, new ImageDescriptor(4, 1, 1, TargetBuffer.Color) },
{ GalImageFormat.R32, new ImageDescriptor(4, 1, 1, TargetBuffer.Color) }, { GalImageFormat.R32, new ImageDescriptor(4, 1, 1, TargetBuffer.Color) },
{ GalImageFormat.RGBA4, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) }, { GalImageFormat.RGBA4, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) },
{ GalImageFormat.BC6H_SF16, new ImageDescriptor(16, 4, 4, TargetBuffer.Color) }, { GalImageFormat.BptcSfloat, new ImageDescriptor(16, 4, 4, TargetBuffer.Color) },
{ GalImageFormat.BC6H_UF16, new ImageDescriptor(16, 4, 4, TargetBuffer.Color) }, { GalImageFormat.BptcUfloat, new ImageDescriptor(16, 4, 4, TargetBuffer.Color) },
{ GalImageFormat.RGB5A1, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) }, { GalImageFormat.RGB5A1, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) },
{ GalImageFormat.RGB565, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) }, { GalImageFormat.RGB565, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) },
{ GalImageFormat.BC7, new ImageDescriptor(16, 4, 4, TargetBuffer.Color) }, { GalImageFormat.BptcUnorm, new ImageDescriptor(16, 4, 4, TargetBuffer.Color) },
{ GalImageFormat.RG16, new ImageDescriptor(4, 1, 1, TargetBuffer.Color) }, { GalImageFormat.RG16, new ImageDescriptor(4, 1, 1, TargetBuffer.Color) },
{ GalImageFormat.RG8, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) }, { GalImageFormat.RG8, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) },
{ GalImageFormat.R16, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) }, { GalImageFormat.R16, new ImageDescriptor(2, 1, 1, TargetBuffer.Color) },
@ -151,7 +151,7 @@ namespace Ryujinx.Graphics.Texture
if (!s_TextureTable.TryGetValue(Format, out GalImageFormat ImageFormat)) if (!s_TextureTable.TryGetValue(Format, out GalImageFormat ImageFormat))
{ {
throw new NotImplementedException("Format " + ((int)Format).ToString("x2") + " not implemented!"); throw new NotImplementedException($"Format 0x{((int)Format):x} not implemented!");
} }
GalImageFormat FormatType = ConvSrgb ? Srgb : GetFormatType(RType); GalImageFormat FormatType = ConvSrgb ? Srgb : GetFormatType(RType);
@ -160,7 +160,7 @@ namespace Ryujinx.Graphics.Texture
if (!ImageFormat.HasFlag(FormatType)) if (!ImageFormat.HasFlag(FormatType))
{ {
throw new NotImplementedException("Format " + CombinedFormat + " not implemented!"); throw new NotImplementedException($"Format \"{CombinedFormat}\" not implemented!");
} }
return CombinedFormat; return CombinedFormat;
@ -380,7 +380,7 @@ namespace Ryujinx.Graphics.Texture
return Descriptor; return Descriptor;
} }
throw new NotImplementedException("Image with format " + PixelFormat.ToString() + " not implemented"); throw new NotImplementedException($"Format \"{PixelFormat}\" not implemented!");
} }
private static GalImageFormat GetFormatType(GalTextureType Type) private static GalImageFormat GetFormatType(GalTextureType Type)