mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-22 17:10:19 +00:00
This path is only taken if the much faster check of "is the buffer rented at all" is triggered, so it doesn't actually end up costing too much, and the time saved by not ending render passes (and on gpu for not waiting on barriers) is probably helpful. Avoids ending render passes to update buffer data (not all the time) - 140-180 to 35-45 in SMO metro kingdom (these updates are in the UI) - Very variable 60-150(!) to 16-25 in mario kart 8 (these updates are in the UI) As well as allowing more data to be preloaded persistently, this will also allow more data to be loaded in the preload buffer, which should be faster as it doesn't need to insert barriers between draws. (and on tbdr, does not need to flush and reload tile memory) Improves performance in GPU limited scenarios. Should notably improve performance on TBDR gpus. Still a lot more to do here.
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
namespace Ryujinx.Graphics.Vulkan
|
|
{
|
|
internal class BufferUsageBitmap
|
|
{
|
|
private BitMap _bitmap;
|
|
private int _size;
|
|
private int _granularity;
|
|
private int _bits;
|
|
|
|
private int _intsPerCb;
|
|
private int _bitsPerCb;
|
|
|
|
public BufferUsageBitmap(int size, int granularity)
|
|
{
|
|
_size = size;
|
|
_granularity = granularity;
|
|
_bits = (size + (granularity - 1)) / granularity;
|
|
|
|
_intsPerCb = (_bits + (BitMap.IntSize - 1)) / BitMap.IntSize;
|
|
_bitsPerCb = _intsPerCb * BitMap.IntSize;
|
|
|
|
_bitmap = new BitMap(_bitsPerCb * CommandBufferPool.MaxCommandBuffers);
|
|
}
|
|
|
|
public void Add(int cbIndex, int offset, int size)
|
|
{
|
|
int cbBase = cbIndex * _bitsPerCb;
|
|
int start = cbBase + offset / _granularity;
|
|
int end = cbBase + (offset + size - 1) / _granularity;
|
|
|
|
_bitmap.SetRange(start, end);
|
|
}
|
|
|
|
public bool OverlapsWith(int cbIndex, int offset, int size)
|
|
{
|
|
int cbBase = cbIndex * _bitsPerCb;
|
|
int start = cbBase + offset / _granularity;
|
|
int end = cbBase + (offset + size - 1) / _granularity;
|
|
|
|
return _bitmap.IsSet(start, end);
|
|
}
|
|
|
|
public bool OverlapsWith(int offset, int size)
|
|
{
|
|
for (int i = 0; i < CommandBufferPool.MaxCommandBuffers; i++)
|
|
{
|
|
if (OverlapsWith(i, offset, size))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public void Clear(int cbIndex)
|
|
{
|
|
_bitmap.ClearInt(cbIndex * _intsPerCb, (cbIndex + 1) * _intsPerCb - 1);
|
|
}
|
|
}
|
|
}
|