diff options
author | gdkchan <gab.dark.100@gmail.com> | 2024-02-08 14:27:12 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-08 18:27:12 +0100 |
commit | 8bb7a3fc977db964b33645166e733b4b29259cb9 (patch) | |
tree | cb3fd4c98667d552df689812ee4abecbedb13c31 /src | |
parent | 628d092fc64d8b89a5e9f05cc15136bac16122ab (diff) |
Clamp vertex buffer size to mapped size if too high (#6272)1.1.1165
* Clamp vertex buffer size to mapped size if too high
* Update comment
Diffstat (limited to 'src')
-rw-r--r-- | src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index 2b65b456..6b4ea89f 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -26,6 +26,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed public const int PrimitiveRestartStateIndex = 12; 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 GpuChannel _channel; private readonly DeviceStateWithShadow<ThreedClassState> _state; @@ -1144,6 +1147,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed 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 { |