aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaronKiko <BaronKiko@users.noreply.github.com>2019-01-18 18:31:25 +0000
committergdkchan <gab.dark.100@gmail.com>2019-01-18 16:31:25 -0200
commit3731d0ce8412c3c48286c242842bcb4940b4ca6d (patch)
tree5299f15d0018ee3e2033feec0b4564bd5eca9c81
parent0cd5ba03fe4cccd232cdb6aa7e8648b4a08a0ab1 (diff)
SNK 40th Anniversary Out of Bounds Fix (#557)
* Check vertex array is enabled before reading constant attribute to avoid out of bounds exception * Removed new line
-rw-r--r--Ryujinx.Graphics/Graphics3d/NvGpuEngine3d.cs10
1 files changed, 8 insertions, 2 deletions
diff --git a/Ryujinx.Graphics/Graphics3d/NvGpuEngine3d.cs b/Ryujinx.Graphics/Graphics3d/NvGpuEngine3d.cs
index 9a22c85f..7de76cce 100644
--- a/Ryujinx.Graphics/Graphics3d/NvGpuEngine3d.cs
+++ b/Ryujinx.Graphics/Graphics3d/NvGpuEngine3d.cs
@@ -783,12 +783,18 @@ namespace Ryujinx.Graphics.Graphics3d
GalVertexAttribType Type = (GalVertexAttribType)((Packed >> 27) & 0x7);
bool IsRgba = ((Packed >> 31) & 1) != 0;
+
+ // Check vertex array is enabled to avoid out of bounds exception when reading bytes
+ bool Enable = (ReadRegister(NvGpuEngine3dReg.VertexArrayNControl + ArrayIndex * 4) & 0x1000) != 0;
//Note: 16 is the maximum size of an attribute,
//having a component size of 32-bits with 4 elements (a vec4).
- byte[] Data = Vmm.ReadBytes(VbPosition + Offset, 16);
+ if (Enable)
+ {
+ byte[] Data = Vmm.ReadBytes(VbPosition + Offset, 16);
- Attribs[ArrayIndex].Add(new GalVertexAttrib(Attr, IsConst, Offset, Data, Size, Type, IsRgba));
+ Attribs[ArrayIndex].Add(new GalVertexAttrib(Attr, IsConst, Offset, Data, Size, Type, IsRgba));
+ }
}
State.VertexBindings = new GalVertexBinding[32];