From b8d0c9c4e0a253cd9aa475e7cb52a69d90965699 Mon Sep 17 00:00:00 2001 From: gdk Date: Wed, 16 Mar 2022 15:11:48 -0300 Subject: [PATCH] XML docs + nits --- Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs | 19 +++++++++++ Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs | 34 ++++++++++++++++---- Ryujinx.Graphics.Gpu/Memory/PteKind.cs | 5 +++ 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs b/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs index 298904367..df7e55a11 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs @@ -350,6 +350,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma } } + /// + /// Copies block linear data with block linear GOBs to a block linear destination with linear GOBs. + /// + /// GPU memory manager + /// Source GPU virtual address + /// Destination GPU virtual address + /// Size in bytes of the copy private static void CopyGobBlockLinearToLinear(MemoryManager memoryManager, ulong srcGpuVa, ulong dstGpuVa, ulong size) { if (((srcGpuVa | dstGpuVa | size) & 0xf) == 0) @@ -370,6 +377,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma } } + /// + /// Copies block linear data with linear GOBs to a block linear destination with block linear GOBs. + /// + /// GPU memory manager + /// Source GPU virtual address + /// Destination GPU virtual address + /// Size in bytes of the copy private static void CopyGobLinearToBlockLinear(MemoryManager memoryManager, ulong srcGpuVa, ulong dstGpuVa, ulong size) { if (((srcGpuVa | dstGpuVa | size) & 0xf) == 0) @@ -390,6 +404,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma } } + /// + /// Calculates the GOB block linear address from a linear address. + /// + /// Linear address + /// Block linear address private static ulong ConvertGobLinearToBlockLinearAddress(ulong address) { // y2 y1 y0 x5 x4 x3 x2 x1 x0 -> x5 y2 y1 x4 y0 x3 x2 x1 x0 diff --git a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs index 2b2bbecb6..c57f1a6f1 100644 --- a/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs @@ -470,9 +470,15 @@ namespace Ryujinx.Graphics.Gpu.Memory return PteUnmapped; } - return UnpackVaFromPte(pte) + (va & PageMask); + return UnpackPaFromPte(pte) + (va & PageMask); } + /// + /// Gets the kind of a given memory page. + /// This might indicate the type of resource that can be allocated on the page, and also texture tiling. + /// + /// GPU virtual address + /// Kind of the memory page public PteKind GetKind(ulong va) { if (!ValidateAddress(va)) @@ -531,19 +537,35 @@ namespace Ryujinx.Graphics.Gpu.Memory _pageTable[l0][l1] = pte; } - private static ulong PackPte(ulong va, PteKind kind) + /// + /// Creates a page table entry from a physical address and kind. + /// + /// Physical address + /// Kind + /// Page table entry + private static ulong PackPte(ulong pa, PteKind kind) { - return va | ((ulong)kind << 48); + return pa | ((ulong)kind << 56); } + /// + /// Unpacks kind from a page table entry. + /// + /// Page table entry + /// Kind private static PteKind UnpackKindFromPte(ulong pte) { - return (PteKind)(pte >> 48); + return (PteKind)(pte >> 56); } - private static ulong UnpackVaFromPte(ulong pte) + /// + /// Unpacks physical address from a page table entry. + /// + /// Page table entry + /// Physical address + private static ulong UnpackPaFromPte(ulong pte) { - return pte & 0xffffffffffffUL; + return pte & 0xffffffffffffffUL; } } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/Memory/PteKind.cs b/Ryujinx.Graphics.Gpu/Memory/PteKind.cs index 4c9c24916..4ceb6bcf4 100644 --- a/Ryujinx.Graphics.Gpu/Memory/PteKind.cs +++ b/Ryujinx.Graphics.Gpu/Memory/PteKind.cs @@ -255,6 +255,11 @@ namespace Ryujinx.Graphics.Gpu.Memory static class PteKindExtensions { + /// + /// Checks if the kind is pitch. + /// + /// Kind to check + /// True if pitch, false otherwise public static bool IsPitch(this PteKind kind) { return kind == PteKind.Pitch || kind == PteKind.PitchNoSwizzle;