forked from Mirror/Ryujinx
492a046335
* Initial implementation of buffer mirrors Generally slower right now, goal is to reduce render passes in games that do inline updates Fix support buffer mirrors Reintroduce vertex buffer mirror Add storage buffer support Optimisation part 1 More optimisation Avoid useless data copies. Remove unused cbIndex stuff Properly set write flag for storage buffers. Fix minor issues Not sure why this was here. Fix BufferRangeList Fix some big issues Align storage buffers rather than getting full buffer as a range Improves mirrorability of read-only storage buffers Increase staging buffer size, as it now contains mirrors Fix some issues with buffers not updating Fix buffer SetDataUnchecked offset for one of the paths when using mirrors Fix buffer mirrors interaction with buffer textures Fix mirror rebinding Move GetBuffer calls on indirect draws before BeginRenderPass to avoid draws without render pass Fix mirrors rebase Fix rebase 2023 * Fix crash when using stale vertex buffer Similar to `Get` with a size that's too large, just treat it as a clamp. * Explicitly set support buffer as mirrorable * Address feedback * Remove unused fragment of MVK workaround * Replace logging for staging buffer OOM * Address format issues * Address more format issues * Mini cleanup * Address more things * Rename BufferRangeList * Support bounding range for ClearMirrors and UploadPendingData * Add maximum size for vertex buffer mirrors * Enable index buffer mirrors Enabled on all platforms for the IbStreamer. * Feedback * Remove mystery BufferCache change Probably macos related? * Fix mirrors not creating when staging buffer is empty. * Change log level to debug
53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System;
|
|
|
|
namespace Ryujinx.Graphics.Vulkan
|
|
{
|
|
struct BufferState : IDisposable
|
|
{
|
|
public static BufferState Null => new(null, 0, 0);
|
|
|
|
private readonly int _offset;
|
|
private readonly int _size;
|
|
|
|
private Auto<DisposableBuffer> _buffer;
|
|
|
|
public BufferState(Auto<DisposableBuffer> buffer, int offset, int size)
|
|
{
|
|
_buffer = buffer;
|
|
_offset = offset;
|
|
_size = size;
|
|
buffer?.IncrementReferenceCount();
|
|
}
|
|
|
|
public readonly void BindTransformFeedbackBuffer(VulkanRenderer gd, CommandBufferScoped cbs, uint binding)
|
|
{
|
|
if (_buffer != null)
|
|
{
|
|
var buffer = _buffer.Get(cbs, _offset, _size, true).Value;
|
|
|
|
gd.TransformFeedbackApi.CmdBindTransformFeedbackBuffers(cbs.CommandBuffer, binding, 1, buffer, (ulong)_offset, (ulong)_size);
|
|
}
|
|
}
|
|
|
|
public void Swap(Auto<DisposableBuffer> from, Auto<DisposableBuffer> to)
|
|
{
|
|
if (_buffer == from)
|
|
{
|
|
_buffer.DecrementReferenceCount();
|
|
to.IncrementReferenceCount();
|
|
|
|
_buffer = to;
|
|
}
|
|
}
|
|
|
|
public readonly bool Overlaps(Auto<DisposableBuffer> buffer, int offset, int size)
|
|
{
|
|
return buffer == _buffer && offset < _offset + _size && offset + size > _offset;
|
|
}
|
|
|
|
public readonly void Dispose()
|
|
{
|
|
_buffer?.DecrementReferenceCount();
|
|
}
|
|
}
|
|
}
|