Address feedback

This commit is contained in:
ReinUsesLisp 2018-07-14 15:35:58 -03:00
parent 561fab56ac
commit eda3ef302a
4 changed files with 15 additions and 13 deletions

View file

@ -1,4 +0,0 @@
public static class AGraphicsConfig
{
public static string ShadersDumpPath = "";
}

View file

@ -5,22 +5,24 @@ namespace Ryujinx.Graphics.Gal
{
static class ShaderDumper
{
private static string RuntimeDir = "";
private static string RuntimeDir;
private static int DumpIndex = 1;
public static void Dump(IGalMemory Memory, long Position, GalShaderType Type, string ExtSuffix = "")
{
if (AGraphicsConfig.ShadersDumpPath == "")
if (string.IsNullOrWhiteSpace(GraphicsConfig.ShadersDumpPath))
{
return;
}
string Path = DumpDir() + "/Shader" + DumpIndex.ToString("d4") + "." + ShaderExtension(Type) + ExtSuffix + ".bin";
string FileName = "Shader" + DumpIndex.ToString("d4") + "." + ShaderExtension(Type) + ExtSuffix + ".bin";
string FilePath = Path.Combine(DumpDir(), FileName);
DumpIndex++;
using (FileStream Output = File.Create(Path))
using (FileStream Output = File.Create(FilePath))
using (BinaryWriter Writer = new BinaryWriter(Output))
{
long Offset = 0;
@ -28,12 +30,12 @@ namespace Ryujinx.Graphics.Gal
ulong Instruction = 0;
//Dump until a NOP instruction is found
while (Instruction >> 52 != 0x50b)
while ((Instruction >> 52 & 0xfff8) != 0x50b0)
{
uint Word0 = (uint)Memory.ReadInt32(Position + Offset + 0);
uint Word1 = (uint)Memory.ReadInt32(Position + Offset + 4);
Instruction = Word0 | (ulong) Word1 << 32;
Instruction = Word0 | (ulong)Word1 << 32;
//Zero instructions (other kind of NOP) stop immediatly,
//this is to avoid two rows of zeroes
@ -59,13 +61,13 @@ namespace Ryujinx.Graphics.Gal
private static string DumpDir()
{
if (RuntimeDir == "")
if (string.IsNullOrEmpty(RuntimeDir))
{
int Index = 1;
do
{
RuntimeDir = AGraphicsConfig.ShadersDumpPath + "/Dumps" + Index.ToString("d2");
RuntimeDir = Path.Combine(GraphicsConfig.ShadersDumpPath, "Dumps" + Index.ToString("d2"));
Index++;
}

View file

@ -0,0 +1,4 @@
public static class GraphicsConfig
{
public static string ShadersDumpPath;
}

View file

@ -29,7 +29,7 @@ namespace Ryujinx
AOptimizations.DisableMemoryChecks = !Convert.ToBoolean(Parser.Value("Enable_Memory_Checks"));
AGraphicsConfig.ShadersDumpPath = Parser.Value("Graphics_Shaders_Dump_Path");
GraphicsConfig.ShadersDumpPath = Parser.Value("Graphics_Shaders_Dump_Path");
Log.SetEnable(LogLevel.Debug, Convert.ToBoolean(Parser.Value("Logging_Enable_Debug")));
Log.SetEnable(LogLevel.Stub, Convert.ToBoolean(Parser.Value("Logging_Enable_Stub")));