mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-12-27 14:26:44 +01:00
48f6570557
Here come Salieri, my implementation of a disk shader cache! "I'm sure you know why I named it that." "It doesn't really mean anything." This implementation collects shaders at runtime and cache them to be later compiled when starting a game.
49 lines
No EOL
1.3 KiB
C#
49 lines
No EOL
1.3 KiB
C#
using Ryujinx.Graphics.Shader;
|
|
using Ryujinx.Graphics.Shader.Translation;
|
|
using System;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Ryujinx.ShaderTools
|
|
{
|
|
class Program
|
|
{
|
|
private class GpuAccessor : IGpuAccessor
|
|
{
|
|
private readonly byte[] _data;
|
|
|
|
public GpuAccessor(byte[] data)
|
|
{
|
|
_data = data;
|
|
}
|
|
|
|
public T MemoryRead<T>(ulong address) where T : unmanaged
|
|
{
|
|
return MemoryMarshal.Cast<byte, T>(new ReadOnlySpan<byte>(_data).Slice((int)address))[0];
|
|
}
|
|
}
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
if (args.Length == 1 || args.Length == 2)
|
|
{
|
|
TranslationFlags flags = TranslationFlags.DebugMode;
|
|
|
|
if (args.Length == 2 && args[0] == "--compute")
|
|
{
|
|
flags |= TranslationFlags.Compute;
|
|
}
|
|
|
|
byte[] data = File.ReadAllBytes(args[^1]);
|
|
|
|
string code = Translator.CreateContext(0, new GpuAccessor(data), flags).Translate(out _).Code;
|
|
|
|
Console.WriteLine(code);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Usage: Ryujinx.ShaderTools [--compute] shader.bin");
|
|
}
|
|
}
|
|
}
|
|
} |