aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.ShaderTools/Program.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-05-05 22:02:28 -0300
committerGitHub <noreply@github.com>2020-05-06 11:02:28 +1000
commitb8eb6abeccbd4a468214a4d2ad3a9b6e5e06973c (patch)
treecd3d71ebde0f4f32eb674778adae89c0efcb75df /Ryujinx.ShaderTools/Program.cs
parent7f500e7cae940958289abe1a3461e52684742053 (diff)
Refactor shader GPU state and memory access (#1203)
* Refactor shader GPU state and memory access * Fix NVDEC project build * Address PR feedback and add missing XML comments
Diffstat (limited to 'Ryujinx.ShaderTools/Program.cs')
-rw-r--r--Ryujinx.ShaderTools/Program.cs18
1 files changed, 17 insertions, 1 deletions
diff --git a/Ryujinx.ShaderTools/Program.cs b/Ryujinx.ShaderTools/Program.cs
index 25ac8d2a..567083e4 100644
--- a/Ryujinx.ShaderTools/Program.cs
+++ b/Ryujinx.ShaderTools/Program.cs
@@ -2,11 +2,27 @@
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)
@@ -20,7 +36,7 @@ namespace Ryujinx.ShaderTools
byte[] data = File.ReadAllBytes(args[^1]);
- string code = Translator.Translate(data, new TranslatorCallbacks(null, null), flags).Code;
+ string code = Translator.Translate(0, new GpuAccessor(data), flags).Code;
Console.WriteLine(code);
}