Skip to content

Commit

Permalink
Fix rebase 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
riperiperi committed May 12, 2023
1 parent 1cb382f commit c82b92e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
Expand Up @@ -623,7 +623,7 @@ private void BindBuffers(BufferCache bufferCache, BuffersPerStage[] bindings, bo
{
var isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write);
var range = isStorage
? bufferCache.GetBufferRangeTillEnd(bounds.Address, bounds.Size, isWrite)
? bufferCache.GetBufferRangeAligned(bounds.Address, bounds.Size, isWrite)
: bufferCache.GetBufferRange(bounds.Address, bounds.Size);

ranges[rangesCount++] = new BufferAssignment(bindingInfo.Binding, range);
Expand Down Expand Up @@ -660,7 +660,7 @@ private void BindBuffers(BufferCache bufferCache, BuffersPerStage buffers, bool
{
var isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write);
var range = isStorage
? bufferCache.GetBufferRangeTillEnd(bounds.Address, bounds.Size, isWrite)
? bufferCache.GetBufferRangeAligned(bounds.Address, bounds.Size, isWrite)
: bufferCache.GetBufferRange(bounds.Address, bounds.Size);

ranges[rangesCount++] = new BufferAssignment(bindingInfo.Binding, range);
Expand Down
11 changes: 8 additions & 3 deletions src/Ryujinx.Graphics.Vulkan/BufferHolder.cs
Expand Up @@ -94,7 +94,7 @@ public BufferHolder(VulkanRenderer gd, Device device, VkBuffer buffer, Auto<Memo
_allocationAuto = allocation;
_allocationImported = true;
_waitable = new MultiFenceHolder(size);
_buffer = new Auto<DisposableBuffer>(new DisposableBuffer(gd.Api, device, buffer), _waitable, _allocationAuto);
_buffer = new Auto<DisposableBuffer>(new DisposableBuffer(gd.Api, device, buffer), this, _waitable, _allocationAuto);
_bufferHandle = buffer.Handle;
Size = size;
_map = _allocation.HostPointer + offset;
Expand All @@ -113,7 +113,7 @@ public bool TryBackingSwap(ref CommandBufferScoped? cbs)
// Only swap if the buffer is not used in any queued command buffer.
bool isRented = _buffer.HasRentedCommandBufferDependency(_gd.CommandBufferPool);

if (!isRented && _gd.CommandBufferPool.OwnedByCurrentThread && !_flushLock.IsReaderLockHeld)
if (!isRented && _gd.CommandBufferPool.OwnedByCurrentThread && !_flushLock.IsReaderLockHeld && (_pendingData == null || cbs != null))
{
var currentAllocation = _allocationAuto;
var currentBuffer = _buffer;
Expand All @@ -123,6 +123,11 @@ public bool TryBackingSwap(ref CommandBufferScoped? cbs)

if (buffer.Handle != 0)
{
if (cbs != null)
{
ClearMirrors(cbs.Value, 0, Size);
}

_flushLock.AcquireWriterLock(Timeout.Infinite);

ClearFlushFence();
Expand All @@ -131,7 +136,7 @@ public bool TryBackingSwap(ref CommandBufferScoped? cbs)

_allocation = allocation;
_allocationAuto = new Auto<MemoryAllocation>(allocation);
_buffer = new Auto<DisposableBuffer>(new DisposableBuffer(_gd.Api, _device, buffer), _waitable, _allocationAuto);
_buffer = new Auto<DisposableBuffer>(new DisposableBuffer(_gd.Api, _device, buffer), this, _waitable, _allocationAuto);
_bufferHandle = buffer.Handle;
_map = allocation.HostPointer;

Expand Down
4 changes: 3 additions & 1 deletion src/Ryujinx.Graphics.Vulkan/PipelineBase.cs
Expand Up @@ -720,9 +720,11 @@ internal void Rebind(Auto<DisposableBuffer> buffer, int offset, int size)
{
if (_vertexBuffers[i].Overlaps(buffer, offset, size))
{
_vertexBuffers[i].BindVertexBuffer(Gd, Cbs, (uint)i, ref _newState);
_vertexBuffers[i].BindVertexBuffer(Gd, Cbs, (uint)i, ref _newState, _vertexBufferUpdater);
}
}

_vertexBufferUpdater.Commit(Cbs);
}

public void SetAlphaTest(bool enable, float reference, GAL.CompareOp op)
Expand Down
5 changes: 5 additions & 0 deletions src/Ryujinx.Graphics.Vulkan/VertexBufferState.cs
Expand Up @@ -102,6 +102,11 @@ public bool BoundEquals(Auto<DisposableBuffer> buffer)
return _buffer == buffer;
}

public bool Overlaps(Auto<DisposableBuffer> buffer, int offset, int size)
{
return buffer == _buffer && offset < _offset + _size && offset + size > _offset;
}

public bool Matches(Auto<DisposableBuffer> buffer, int descriptorIndex, int offset, int size, int stride = 0)
{
return _buffer == buffer && DescriptorIndex == descriptorIndex && _offset == offset && _size == size && _stride == stride;
Expand Down

0 comments on commit c82b92e

Please sign in to comment.