aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-10-12 17:35:31 -0300
committerGitHub <noreply@github.com>2021-10-12 22:35:31 +0200
commita7109c767bdc014327b574012794156c92174495 (patch)
treed7d7db6eaa63d4e3e0396a3182d0267b6ad31dd7 /Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs
parent0510fde25ae66ec0b55091746a52931248d75b89 (diff)
Rewrite shader decoding stage (#2698)
* Rewrite shader decoding stage * Fix P2R constant buffer encoding * Fix PSET/PSETP * PR feedback * Log unimplemented shader instructions * Implement NOP * Remove using * PR feedback
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs')
-rw-r--r--Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs21
1 files changed, 12 insertions, 9 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs b/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs
index ff5932e1..0ad172da 100644
--- a/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs
+++ b/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs
@@ -1,5 +1,6 @@
using Ryujinx.Graphics.Shader.Decoders;
using System;
+using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Shader.Translation
{
@@ -113,11 +114,13 @@ namespace Ryujinx.Graphics.Shader.Translation
public ShaderHeader(IGpuAccessor gpuAccessor, ulong address)
{
- int commonWord0 = gpuAccessor.MemoryRead<int>(address + 0);
- int commonWord1 = gpuAccessor.MemoryRead<int>(address + 4);
- int commonWord2 = gpuAccessor.MemoryRead<int>(address + 8);
- int commonWord3 = gpuAccessor.MemoryRead<int>(address + 12);
- int commonWord4 = gpuAccessor.MemoryRead<int>(address + 16);
+ ReadOnlySpan<int> header = MemoryMarshal.Cast<ulong, int>(gpuAccessor.GetCode(address, 0x50));
+
+ int commonWord0 = header[0];
+ int commonWord1 = header[1];
+ int commonWord2 = header[2];
+ int commonWord3 = header[3];
+ int commonWord4 = header[4];
SphType = commonWord0.Extract(0, 5);
Version = commonWord0.Extract(5, 5);
@@ -164,9 +167,9 @@ namespace Ryujinx.Graphics.Shader.Translation
ImapTypes = new ImapPixelType[32];
- for (ulong i = 0; i < 32; i++)
+ for (int i = 0; i < 32; i++)
{
- byte imap = gpuAccessor.MemoryRead<byte>(address + 0x18 + i);
+ byte imap = (byte)(header[6 + (i >> 2)] >> ((i & 3) * 8));
ImapTypes[i] = new ImapPixelType(
(PixelImap)((imap >> 0) & 3),
@@ -175,8 +178,8 @@ namespace Ryujinx.Graphics.Shader.Translation
(PixelImap)((imap >> 6) & 3));
}
- int type2OmapTarget = gpuAccessor.MemoryRead<int>(address + 0x48);
- int type2Omap = gpuAccessor.MemoryRead<int>(address + 0x4c);
+ int type2OmapTarget = header[18];
+ int type2Omap = header[19];
OmapTargets = new OmapTarget[8];