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 _buffer; public BufferState(Auto 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).Value; gd.TransformFeedbackApi.CmdBindTransformFeedbackBuffers(cbs.CommandBuffer, binding, 1, buffer, (ulong)_offset, (ulong)_size); } } public void Swap(Auto from, Auto to) { if (_buffer == from) { _buffer.DecrementReferenceCount(); to.IncrementReferenceCount(); _buffer = to; } } public readonly void Dispose() { _buffer?.DecrementReferenceCount(); } } }