Add a separate device memory manager (#6153)
* Add a separate device memory manager * Still need this * Device writes are always tracked * Device writes are always tracked (2) * Rename more instances of gmm to mm
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Device;
|
||||
using Ryujinx.Graphics.Video;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
@@ -27,11 +27,11 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
|
||||
private readonly CacheItem[] _pool = new CacheItem[MaxItems];
|
||||
|
||||
private readonly MemoryManager _gmm;
|
||||
private readonly DeviceMemoryManager _mm;
|
||||
|
||||
public SurfaceCache(MemoryManager gmm)
|
||||
public SurfaceCache(DeviceMemoryManager mm)
|
||||
{
|
||||
_gmm = gmm;
|
||||
_mm = mm;
|
||||
}
|
||||
|
||||
public ISurface Get(IDecoder decoder, uint lumaOffset, uint chromaOffset, int width, int height)
|
||||
@@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
|
||||
if ((lumaOffset | chromaOffset) != 0)
|
||||
{
|
||||
SurfaceReader.Read(_gmm, surface, lumaOffset, chromaOffset);
|
||||
SurfaceReader.Read(_mm, surface, lumaOffset, chromaOffset);
|
||||
}
|
||||
|
||||
MoveToFront(i);
|
||||
@@ -100,7 +100,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
|
||||
if ((lumaOffset | chromaOffset) != 0)
|
||||
{
|
||||
SurfaceReader.Read(_gmm, surface, lumaOffset, chromaOffset);
|
||||
SurfaceReader.Read(_mm, surface, lumaOffset, chromaOffset);
|
||||
}
|
||||
|
||||
MoveToFront(MaxItems - 1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Device;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
using Ryujinx.Graphics.Video;
|
||||
using System;
|
||||
@@ -11,13 +11,13 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
{
|
||||
static class SurfaceReader
|
||||
{
|
||||
public static void Read(MemoryManager gmm, ISurface surface, uint lumaOffset, uint chromaOffset)
|
||||
public static void Read(DeviceMemoryManager mm, ISurface surface, uint lumaOffset, uint chromaOffset)
|
||||
{
|
||||
int width = surface.Width;
|
||||
int height = surface.Height;
|
||||
int stride = surface.Stride;
|
||||
|
||||
ReadOnlySpan<byte> luma = gmm.DeviceGetSpan(lumaOffset, GetBlockLinearSize(width, height, 1));
|
||||
ReadOnlySpan<byte> luma = mm.DeviceGetSpan(lumaOffset, GetBlockLinearSize(width, height, 1));
|
||||
|
||||
ReadLuma(surface.YPlane.AsSpan(), luma, stride, width, height);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
int uvHeight = surface.UvHeight;
|
||||
int uvStride = surface.UvStride;
|
||||
|
||||
ReadOnlySpan<byte> chroma = gmm.DeviceGetSpan(chromaOffset, GetBlockLinearSize(uvWidth, uvHeight, 2));
|
||||
ReadOnlySpan<byte> chroma = mm.DeviceGetSpan(chromaOffset, GetBlockLinearSize(uvWidth, uvHeight, 2));
|
||||
|
||||
ReadChroma(surface.UPlane.AsSpan(), surface.VPlane.AsSpan(), chroma, uvStride, uvWidth, uvHeight);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Device;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
using Ryujinx.Graphics.Video;
|
||||
using System;
|
||||
@@ -12,11 +12,11 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
{
|
||||
static class SurfaceWriter
|
||||
{
|
||||
public static void Write(MemoryManager gmm, ISurface surface, uint lumaOffset, uint chromaOffset)
|
||||
public static void Write(DeviceMemoryManager mm, ISurface surface, uint lumaOffset, uint chromaOffset)
|
||||
{
|
||||
int lumaSize = GetBlockLinearSize(surface.Width, surface.Height, 1);
|
||||
|
||||
using var luma = gmm.GetWritableRegion(ExtendOffset(lumaOffset), lumaSize);
|
||||
using var luma = mm.GetWritableRegion(ExtendOffset(lumaOffset), lumaSize);
|
||||
|
||||
WriteLuma(
|
||||
luma.Memory.Span,
|
||||
@@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
|
||||
int chromaSize = GetBlockLinearSize(surface.UvWidth, surface.UvHeight, 2);
|
||||
|
||||
using var chroma = gmm.GetWritableRegion(ExtendOffset(chromaOffset), chromaSize);
|
||||
using var chroma = mm.GetWritableRegion(ExtendOffset(chromaOffset), chromaSize);
|
||||
|
||||
WriteChroma(
|
||||
chroma.Memory.Span,
|
||||
@@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
}
|
||||
|
||||
public static void WriteInterlaced(
|
||||
MemoryManager gmm,
|
||||
DeviceMemoryManager mm,
|
||||
ISurface surface,
|
||||
uint lumaTopOffset,
|
||||
uint chromaTopOffset,
|
||||
@@ -48,8 +48,8 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
{
|
||||
int lumaSize = GetBlockLinearSize(surface.Width, surface.Height / 2, 1);
|
||||
|
||||
using var lumaTop = gmm.GetWritableRegion(ExtendOffset(lumaTopOffset), lumaSize);
|
||||
using var lumaBottom = gmm.GetWritableRegion(ExtendOffset(lumaBottomOffset), lumaSize);
|
||||
using var lumaTop = mm.GetWritableRegion(ExtendOffset(lumaTopOffset), lumaSize);
|
||||
using var lumaBottom = mm.GetWritableRegion(ExtendOffset(lumaBottomOffset), lumaSize);
|
||||
|
||||
WriteLuma(
|
||||
lumaTop.Memory.Span,
|
||||
@@ -67,8 +67,8 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||
|
||||
int chromaSize = GetBlockLinearSize(surface.UvWidth, surface.UvHeight / 2, 2);
|
||||
|
||||
using var chromaTop = gmm.GetWritableRegion(ExtendOffset(chromaTopOffset), chromaSize);
|
||||
using var chromaBottom = gmm.GetWritableRegion(ExtendOffset(chromaBottomOffset), chromaSize);
|
||||
using var chromaTop = mm.GetWritableRegion(ExtendOffset(chromaTopOffset), chromaSize);
|
||||
using var chromaBottom = mm.GetWritableRegion(ExtendOffset(chromaBottomOffset), chromaSize);
|
||||
|
||||
WriteChroma(
|
||||
chromaTop.Memory.Span,
|
||||
|
||||
Reference in New Issue
Block a user