aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Decoders/Decoder.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-10-03 02:43:33 -0300
committerGitHub <noreply@github.com>2020-10-03 15:43:33 +1000
commit0954e76a261235107b2255c33de595d188570274 (patch)
tree719e71e2938e808ca1164aa0da69f95d23248a88 /Ryujinx.Graphics.Shader/Decoders/Decoder.cs
parent86412ed30a5e28a7c11ba30c3987bdebeeb903c1 (diff)
Improve BRX target detection heuristics (#1591)
Diffstat (limited to 'Ryujinx.Graphics.Shader/Decoders/Decoder.cs')
-rw-r--r--Ryujinx.Graphics.Shader/Decoders/Decoder.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Shader/Decoders/Decoder.cs b/Ryujinx.Graphics.Shader/Decoders/Decoder.cs
index e2c9212b..a15d7f9e 100644
--- a/Ryujinx.Graphics.Shader/Decoders/Decoder.cs
+++ b/Ryujinx.Graphics.Shader/Decoders/Decoder.cs
@@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
}
// Do we have a block after the current one?
- if (!IsExit(currBlock.GetLastOp()) && currBlock.BrIndir != null)
+ if (currBlock.BrIndir != null && HasBlockAfter(gpuAccessor, currBlock, startAddress))
{
bool targetVisited = visited.ContainsKey(currBlock.EndAddress);
@@ -154,6 +154,19 @@ namespace Ryujinx.Graphics.Shader.Decoders
return blocks.ToArray();
}
+ private static bool HasBlockAfter(IGpuAccessor gpuAccessor, Block currBlock, ulong startAdddress)
+ {
+ if (!gpuAccessor.MemoryMapped(startAdddress + currBlock.EndAddress) ||
+ !gpuAccessor.MemoryMapped(startAdddress + currBlock.EndAddress + 7))
+ {
+ return false;
+ }
+
+ ulong inst = gpuAccessor.MemoryRead<ulong>(startAdddress + currBlock.EndAddress);
+
+ return inst != 0UL;
+ }
+
private static bool BinarySearch(List<Block> blocks, ulong address, out int index)
{
index = 0;