aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Memory
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory')
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/Buffer.cs4
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/BufferCache.cs2
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs37
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs13
4 files changed, 45 insertions, 11 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
index a624386e..3778cd82 100644
--- a/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
@@ -105,13 +105,13 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (_useGranular)
{
- _memoryTrackingGranular = physicalMemory.BeginGranularTracking(address, size, baseHandles);
+ _memoryTrackingGranular = physicalMemory.BeginGranularTracking(address, size, ResourceKind.Buffer, baseHandles);
_memoryTrackingGranular.RegisterPreciseAction(address, size, PreciseAction);
}
else
{
- _memoryTracking = physicalMemory.BeginTracking(address, size);
+ _memoryTracking = physicalMemory.BeginTracking(address, size, ResourceKind.Buffer);
if (baseHandles != null)
{
diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs b/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
index 00f59083..a5a9b75e 100644
--- a/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
@@ -368,7 +368,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
_context.Renderer.Pipeline.ClearBuffer(buffer.Handle, offset, (int)size, value);
- buffer.SignalModified(address, size);
+ memoryManager.Physical.FillTrackedResource(address, size, value, ResourceKind.Buffer);
}
/// <summary>
diff --git a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
index c1fc0c5c..bd33383e 100644
--- a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
@@ -7,6 +7,7 @@ using Ryujinx.Memory.Range;
using Ryujinx.Memory.Tracking;
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading;
namespace Ryujinx.Graphics.Gpu.Memory
@@ -296,22 +297,40 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
/// <summary>
+ /// Fills the specified memory region with a 32-bit integer value.
+ /// </summary>
+ /// <param name="address">CPU virtual address of the region</param>
+ /// <param name="size">Size of the region</param>
+ /// <param name="value">Value to fill the region with</param>
+ /// <param name="kind">Kind of the resource being filled, which will not be signalled as CPU modified</param>
+ public void FillTrackedResource(ulong address, ulong size, uint value, ResourceKind kind)
+ {
+ _cpuMemory.SignalMemoryTracking(address, size, write: true, precise: true, (int)kind);
+
+ using WritableRegion region = _cpuMemory.GetWritableRegion(address, (int)size);
+
+ MemoryMarshal.Cast<byte, uint>(region.Memory.Span).Fill(value);
+ }
+
+ /// <summary>
/// Obtains a memory tracking handle for the given virtual region. This should be disposed when finished with.
/// </summary>
/// <param name="address">CPU virtual address of the region</param>
/// <param name="size">Size of the region</param>
+ /// <param name="kind">Kind of the resource being tracked</param>
/// <returns>The memory tracking handle</returns>
- public CpuRegionHandle BeginTracking(ulong address, ulong size)
+ public CpuRegionHandle BeginTracking(ulong address, ulong size, ResourceKind kind)
{
- return _cpuMemory.BeginTracking(address, size);
+ return _cpuMemory.BeginTracking(address, size, (int)kind);
}
/// <summary>
/// Obtains a memory tracking handle for the given virtual region. This should be disposed when finished with.
/// </summary>
/// <param name="range">Ranges of physical memory where the data is located</param>
+ /// <param name="kind">Kind of the resource being tracked</param>
/// <returns>The memory tracking handle</returns>
- public GpuRegionHandle BeginTracking(MultiRange range)
+ public GpuRegionHandle BeginTracking(MultiRange range, ResourceKind kind)
{
var cpuRegionHandles = new CpuRegionHandle[range.Count];
int count = 0;
@@ -321,7 +340,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
var currentRange = range.GetSubRange(i);
if (currentRange.Address != MemoryManager.PteUnmapped)
{
- cpuRegionHandles[count++] = _cpuMemory.BeginTracking(currentRange.Address, currentRange.Size);
+ cpuRegionHandles[count++] = _cpuMemory.BeginTracking(currentRange.Address, currentRange.Size, (int)kind);
}
}
@@ -338,12 +357,13 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
/// <param name="address">CPU virtual address of the region</param>
/// <param name="size">Size of the region</param>
+ /// <param name="kind">Kind of the resource being tracked</param>
/// <param name="handles">Handles to inherit state from or reuse</param>
/// <param name="granularity">Desired granularity of write tracking</param>
/// <returns>The memory tracking handle</returns>
- public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles = null, ulong granularity = 4096)
+ public CpuMultiRegionHandle BeginGranularTracking(ulong address, ulong size, ResourceKind kind, IEnumerable<IRegionHandle> handles = null, ulong granularity = 4096)
{
- return _cpuMemory.BeginGranularTracking(address, size, handles, granularity);
+ return _cpuMemory.BeginGranularTracking(address, size, handles, granularity, (int)kind);
}
/// <summary>
@@ -351,11 +371,12 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
/// <param name="address">CPU virtual address of the region</param>
/// <param name="size">Size of the region</param>
+ /// <param name="kind">Kind of the resource being tracked</param>
/// <param name="granularity">Desired granularity of write tracking</param>
/// <returns>The memory tracking handle</returns>
- public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity = 4096)
+ public CpuSmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ResourceKind kind, ulong granularity = 4096)
{
- return _cpuMemory.BeginSmartGranularTracking(address, size, granularity);
+ return _cpuMemory.BeginSmartGranularTracking(address, size, granularity, (int)kind);
}
/// <summary>
diff --git a/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs b/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs
new file mode 100644
index 00000000..55d697b8
--- /dev/null
+++ b/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs
@@ -0,0 +1,13 @@
+namespace Ryujinx.Graphics.Gpu.Memory
+{
+ /// <summary>
+ /// Kind of a GPU resource.
+ /// </summary>
+ enum ResourceKind
+ {
+ None,
+ Buffer,
+ Texture,
+ Pool
+ }
+}