diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs index 6bfb22cf70..475d1ee4e5 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs @@ -5,6 +5,7 @@ using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Engine.GPFifo; using Ryujinx.Graphics.Gpu.Engine.Threed; using Ryujinx.Graphics.Gpu.Engine.Types; +using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Memory.Range; using System; using System.Collections.Generic; @@ -495,8 +496,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME ulong indirectBufferSize = (ulong)maxDrawCount * (ulong)stride; - MultiRange indirectBufferRange = bufferCache.TranslateAndCreateMultiBuffers(_processor.MemoryManager, indirectBufferGpuVa, indirectBufferSize, Memory.BufferStage.Indirect); - MultiRange parameterBufferRange = bufferCache.TranslateAndCreateMultiBuffers(_processor.MemoryManager, parameterBufferGpuVa, 4, Memory.BufferStage.Indirect); + MultiRange indirectBufferRange = bufferCache.TranslateAndCreateMultiBuffers(_processor.MemoryManager, indirectBufferGpuVa, indirectBufferSize, BufferStage.Indirect); + MultiRange parameterBufferRange = bufferCache.TranslateAndCreateMultiBuffers(_processor.MemoryManager, parameterBufferGpuVa, 4, BufferStage.Indirect); _processor.ThreedClass.DrawIndirect( topology, diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs index 25f20e28a8..73682866ba 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs @@ -415,7 +415,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw ulong misalign = address & ((ulong)_context.Capabilities.TextureBufferOffsetAlignment - 1); BufferRange range = memoryManager.Physical.BufferCache.GetBufferRange( memoryManager.GetPhysicalRegions(address + indexOffset - misalign, size + misalign), - Gpu.Memory.BufferStage.IndexBuffer); + BufferStage.IndexBuffer); misalignedOffset = (int)misalign >> shift; SetIndexBufferTexture(reservations, range, format); diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs index aaeaa472a1..e850f3bca1 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs @@ -670,7 +670,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Gets an action that disposes the backing buffer using its current handle. /// Useful for deleting an old copy of the buffer after the handle changes. /// - /// An action that flushes data from the specified range, using the buffer handle at the time this the method is generated + /// An action that flushes data from the specified range, using the buffer handle at the time the method is generated public Action GetSnapshotDisposeAction() { BufferHandle handle = Handle; @@ -687,7 +687,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Gets an action that flushes a range of the buffer using its current handle. /// Useful for flushing data from old copies of the buffer after the handle changes. /// - /// An action that flushes data from the specified range, using the buffer handle at the time this the method is generated + /// An action that flushes data from the specified range, using the buffer handle at the time the method is generated public BufferFlushAction GetSnapshotFlushAction() { BufferHandle handle = Handle; diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferBackingState.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferBackingState.cs index 27d1c19e8f..3f65131e6b 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferBackingState.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferBackingState.cs @@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// /// Initialize the buffer backing state for a given parent buffer. /// - /// Gpu context + /// GPU context /// Parent buffer /// Initial buffer stage /// Buffers to inherit state from diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferStage.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferStage.cs index 4a37da62ee..d56abda284 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferStage.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferStage.cs @@ -81,13 +81,13 @@ namespace Ryujinx.Graphics.Gpu.Memory [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BufferStage TextureBuffer(ShaderStage shaderStage, TextureUsageFlags flags) { - return (BufferStage)shaderStage | FromUsage(flags); + return FromShaderStage(shaderStage) | FromUsage(flags); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static BufferStage GraphicsStorage(int stageIndex, BufferUsageFlags flags) { - return (BufferStage)(stageIndex + 1) | FromUsage(flags); + return FromShaderStage(stageIndex) | FromUsage(flags); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs b/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs index 01fc8a481c..3dcbc3130b 100644 --- a/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs +++ b/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs @@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Vulkan private bool _lastAccessIsWrite; - private BufferAllocationType _baseType; + private readonly BufferAllocationType _baseType; private readonly BufferAllocationType _activeType; private readonly ReaderWriterLockSlim _flushLock; @@ -111,14 +111,6 @@ namespace Ryujinx.Graphics.Vulkan _flushLock = new ReaderWriterLockSlim(); } - public void Pin() - { - if (_baseType == BufferAllocationType.Auto) - { - _baseType = _activeType; - } - } - public unsafe Auto CreateView(VkFormat format, int offset, int size, Action invalidateView) { var bufferViewCreateInfo = new BufferViewCreateInfo diff --git a/src/Ryujinx.Graphics.Vulkan/BufferManager.cs b/src/Ryujinx.Graphics.Vulkan/BufferManager.cs index 4e8ae2a0bd..e73cde83c8 100644 --- a/src/Ryujinx.Graphics.Vulkan/BufferManager.cs +++ b/src/Ryujinx.Graphics.Vulkan/BufferManager.cs @@ -165,10 +165,6 @@ namespace Ryujinx.Graphics.Vulkan if (TryGetBuffer(range.Handle, out var existingHolder)) { - // Since this buffer now also owns the memory from the referenced buffer, - // we pin it to ensure the memory location will not change. - existingHolder.Pin(); - (var memory, var offset) = existingHolder.GetDeviceMemoryAndOffset(); memoryBinds[index] = new SparseMemoryBind()