aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Graphics.Vulkan/BufferHolder.cs')
-rw-r--r--src/Ryujinx.Graphics.Vulkan/BufferHolder.cs30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs b/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs
index 21b81bdd..a1ea6836 100644
--- a/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs
+++ b/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs
@@ -33,6 +33,7 @@ namespace Ryujinx.Graphics.Vulkan
private MemoryAllocation _allocation;
private Auto<DisposableBuffer> _buffer;
private Auto<MemoryAllocation> _allocationAuto;
+ private bool _allocationImported;
private ulong _bufferHandle;
private CacheByRange<BufferHolder> _cachedConvertedBuffers;
@@ -81,6 +82,26 @@ namespace Ryujinx.Graphics.Vulkan
_flushLock = new ReaderWriterLock();
}
+ public BufferHolder(VulkanRenderer gd, Device device, VkBuffer buffer, Auto<MemoryAllocation> allocation, int size, BufferAllocationType type, BufferAllocationType currentType, int offset)
+ {
+ _gd = gd;
+ _device = device;
+ _allocation = allocation.GetUnsafe();
+ _allocationAuto = allocation;
+ _allocationImported = true;
+ _waitable = new MultiFenceHolder(size);
+ _buffer = new Auto<DisposableBuffer>(new DisposableBuffer(gd.Api, device, buffer), _waitable, _allocationAuto);
+ _bufferHandle = buffer.Handle;
+ Size = size;
+ _map = _allocation.HostPointer + offset;
+
+ _baseType = type;
+ _currentType = currentType;
+ DesiredType = currentType;
+
+ _flushLock = new ReaderWriterLock();
+ }
+
public bool TryBackingSwap(ref CommandBufferScoped? cbs)
{
if (_swapQueued && DesiredType != _currentType)
@@ -775,8 +796,15 @@ namespace Ryujinx.Graphics.Vulkan
_gd.PipelineInternal?.FlushCommandsIfWeightExceeding(_buffer, (ulong)Size);
_buffer.Dispose();
- _allocationAuto.Dispose();
_cachedConvertedBuffers.Dispose();
+ if (_allocationImported)
+ {
+ _allocationAuto.DecrementReferenceCount();
+ }
+ else
+ {
+ _allocationAuto.Dispose();
+ }
_flushLock.AcquireWriterLock(Timeout.Infinite);