See merge request ryubing/ryujinx!202
This commit is contained in:
LotP
2025-10-30 20:55:58 -05:00
parent ab7aeee67b
commit 92b61f9d73
43 changed files with 686 additions and 315 deletions

View File

@@ -1,6 +1,7 @@
using Ryujinx.Common.Memory;
using Silk.NET.Vulkan;
using System;
using System.Buffers;
namespace Ryujinx.Graphics.Vulkan
{
@@ -11,7 +12,7 @@ namespace Ryujinx.Graphics.Vulkan
{
private const int BufferUsageTrackingGranularity = 4096;
private readonly FenceHolder[] _fences;
public FenceHolder[] Fences { get; }
private readonly BufferUsageBitmap _bufferUsageBitmap;
/// <summary>
@@ -19,7 +20,7 @@ namespace Ryujinx.Graphics.Vulkan
/// </summary>
public MultiFenceHolder()
{
_fences = new FenceHolder[CommandBufferPool.MaxCommandBuffers];
Fences = ArrayPool<FenceHolder>.Shared.Rent(CommandBufferPool.MaxCommandBuffers);
}
/// <summary>
@@ -28,7 +29,7 @@ namespace Ryujinx.Graphics.Vulkan
/// <param name="size">Size of the buffer</param>
public MultiFenceHolder(int size)
{
_fences = new FenceHolder[CommandBufferPool.MaxCommandBuffers];
Fences = ArrayPool<FenceHolder>.Shared.Rent(CommandBufferPool.MaxCommandBuffers);
_bufferUsageBitmap = new BufferUsageBitmap(size, BufferUsageTrackingGranularity);
}
@@ -90,7 +91,7 @@ namespace Ryujinx.Graphics.Vulkan
/// <returns>True if the command buffer's previous fence value was null</returns>
public bool AddFence(int cbIndex, FenceHolder fence)
{
ref FenceHolder fenceRef = ref _fences[cbIndex];
ref FenceHolder fenceRef = ref Fences[cbIndex];
if (fenceRef == null)
{
@@ -107,7 +108,7 @@ namespace Ryujinx.Graphics.Vulkan
/// <param name="cbIndex">Command buffer index of the command buffer that owns the fence</param>
public void RemoveFence(int cbIndex)
{
_fences[cbIndex] = null;
Fences[cbIndex] = null;
}
/// <summary>
@@ -117,7 +118,7 @@ namespace Ryujinx.Graphics.Vulkan
/// <returns>True if referenced, false otherwise</returns>
public bool HasFence(int cbIndex)
{
return _fences[cbIndex] != null;
return Fences[cbIndex] != null;
}
/// <summary>
@@ -227,9 +228,9 @@ namespace Ryujinx.Graphics.Vulkan
{
int count = 0;
for (int i = 0; i < _fences.Length; i++)
for (int i = 0; i < Fences.Length; i++)
{
FenceHolder fence = _fences[i];
FenceHolder fence = Fences[i];
if (fence != null)
{
@@ -251,9 +252,9 @@ namespace Ryujinx.Graphics.Vulkan
{
int count = 0;
for (int i = 0; i < _fences.Length; i++)
for (int i = 0; i < Fences.Length; i++)
{
FenceHolder fence = _fences[i];
FenceHolder fence = Fences[i];
if (fence != null && _bufferUsageBitmap.OverlapsWith(i, offset, size))
{