mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-23 03:45:46 +00:00
GPU: Don't sync/bind index buffer when it's not in use (#5526)
* GPU: Don't sync/bind index buffer when it's not in use Sometimes draws don't use an index buffer. It's not necessary to check or upload data for the current index buffer binding as it won't be used. This fixes Pokemon: Legends Arceus updating a stale index buffer for every draw during its TFB pass, which was all non-indexed draws. This probably didn't cost much on normal PCs, but it had a large impact on MacOS, which the macos1 release build avoided by mirroring index buffers (the PR currently does not). Needs buffer mirrors still for the rest of the performance. There are additional cases where index buffers are bound or checked with non-indexed draws on the backend, but this one was straightforward to fix and has the largest impact. Testing is welcome to ensure nothing weird broke. * Fix case with _rebind
This commit is contained in:
parent
5a0aa074b6
commit
6e784e0aca
2 changed files with 18 additions and 10 deletions
|
@ -331,7 +331,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
UpdateShaderState();
|
||||
}
|
||||
|
||||
_channel.BufferManager.CommitGraphicsBindings();
|
||||
_channel.BufferManager.CommitGraphicsBindings(_drawState.DrawIndexed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -515,10 +515,13 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
/// Ensures that the graphics engine bindings are visible to the host GPU.
|
||||
/// Note: this actually performs the binding using the host graphics API.
|
||||
/// </summary>
|
||||
public void CommitGraphicsBindings()
|
||||
/// <param name="indexed">True if the index buffer is in use</param>
|
||||
public void CommitGraphicsBindings(bool indexed)
|
||||
{
|
||||
var bufferCache = _channel.MemoryManager.Physical.BufferCache;
|
||||
|
||||
if (indexed)
|
||||
{
|
||||
if (_indexBufferDirty || _rebind)
|
||||
{
|
||||
_indexBufferDirty = false;
|
||||
|
@ -534,6 +537,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
{
|
||||
bufferCache.SynchronizeBufferRange(_indexBuffer.Address, _indexBuffer.Size);
|
||||
}
|
||||
}
|
||||
else if (_rebind)
|
||||
{
|
||||
_indexBufferDirty = true;
|
||||
}
|
||||
|
||||
uint vbEnableMask = _vertexBuffersEnableMask;
|
||||
|
||||
|
|
Loading…
Reference in a new issue