1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-18 15:22:00 +00:00

Clamp vertex buffer size to mapped size if too high (#6272)

* Clamp vertex buffer size to mapped size if too high

* Update comment
This commit is contained in:
gdkchan 2024-02-08 14:27:12 -03:00 committed by GitHub
parent 628d092fc6
commit 8bb7a3fc97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,6 +26,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public const int PrimitiveRestartStateIndex = 12; public const int PrimitiveRestartStateIndex = 12;
public const int RenderTargetStateIndex = 27; public const int RenderTargetStateIndex = 27;
// Vertex buffers larger than this size will be clamped to the mapped size.
private const ulong VertexBufferSizeToMappedSizeThreshold = 256 * 1024 * 1024; // 256 MB
private readonly GpuContext _context; private readonly GpuContext _context;
private readonly GpuChannel _channel; private readonly GpuChannel _channel;
private readonly DeviceStateWithShadow<ThreedClassState> _state; private readonly DeviceStateWithShadow<ThreedClassState> _state;
@ -1144,6 +1147,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
size = Math.Min(size, maxVertexBufferSize); size = Math.Min(size, maxVertexBufferSize);
} }
else if (size > VertexBufferSizeToMappedSizeThreshold)
{
// Make sure we have a sane vertex buffer size, since in some cases applications
// might set the "end address" of the vertex buffer to the end of the GPU address space,
// which would result in a several GBs large buffer.
size = _channel.MemoryManager.GetMappedSize(address, size);
}
} }
else else
{ {