Check vertex array is enabled before reading constant attribute to avoid out of bounds exception

This commit is contained in:
Andy Adshead 2019-01-05 17:19:28 +00:00
parent b4d91402c6
commit 8c667fce46

View file

@ -748,11 +748,18 @@ namespace Ryujinx.Graphics.Graphics3d
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];