aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-06-28 09:26:39 +0200
committerGitHub <noreply@github.com>2023-06-28 09:26:39 +0200
commit6aa8d71588af4615019cd91b8a31f69dbfaa815d (patch)
tree4b60ed9aeb846ca3bf50f1e9dac97ddfdbc269de /src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
parent9becbd7d728fc2002c176dfd9d1d1aae86f86b12 (diff)
[Ryujinx.Graphics.Nvdec.Vp9] Address dotnet-format issues (#5371)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Address or silence dotnet format IDE1006 warnings * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Fix empty lines before return Co-authored-by: Ac_K <Acoustik666@gmail.com> * Add trailing commas, remove redundant code and remove static modifier from Surface.HighBd * Fix naming rule violations * Fix naming rule violations * Fix empty line before return * Fix comment style Co-authored-by: Ac_K <Acoustik666@gmail.com> * Remove comment alignment * Address review feedback * Separate comments by 2 spaces and fix other formatting issues * Make HighBd an auto-property * Replace if-chain with if-else-chain * Fix new naming rule violations --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
Diffstat (limited to 'src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs')
-rw-r--r--src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
index d5b51bc2..7f34faa5 100644
--- a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
+++ b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
@@ -11,11 +11,11 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types
public ArrayPtr<byte> UBuffer;
public ArrayPtr<byte> VBuffer;
- public unsafe Plane YPlane => new Plane((IntPtr)YBuffer.ToPointer(), YBuffer.Length);
- public unsafe Plane UPlane => new Plane((IntPtr)UBuffer.ToPointer(), UBuffer.Length);
- public unsafe Plane VPlane => new Plane((IntPtr)VBuffer.ToPointer(), VBuffer.Length);
+ public readonly unsafe Plane YPlane => new((IntPtr)YBuffer.ToPointer(), YBuffer.Length);
+ public readonly unsafe Plane UPlane => new((IntPtr)UBuffer.ToPointer(), UBuffer.Length);
+ public readonly unsafe Plane VPlane => new((IntPtr)VBuffer.ToPointer(), VBuffer.Length);
- public FrameField Field => FrameField.Progressive;
+ public readonly FrameField Field => FrameField.Progressive;
public int Width { get; }
public int Height { get; }
@@ -27,29 +27,31 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types
public int UvAlignedWidth { get; }
public int UvAlignedHeight { get; }
public int UvStride { get; }
- public bool HighBd => false;
+
+ public bool HighBd { get; }
private readonly IntPtr _pointer;
public Surface(int width, int height)
{
- const int border = 32;
- const int ssX = 1;
- const int ssY = 1;
- const bool highbd = false;
+ HighBd = false;
+
+ const int Border = 32;
+ const int SsX = 1;
+ const int SsY = 1;
int alignedWidth = (width + 7) & ~7;
int alignedHeight = (height + 7) & ~7;
- int yStride = ((alignedWidth + 2 * border) + 31) & ~31;
- int yplaneSize = (alignedHeight + 2 * border) * yStride;
- int uvWidth = alignedWidth >> ssX;
- int uvHeight = alignedHeight >> ssY;
- int uvStride = yStride >> ssX;
- int uvBorderW = border >> ssX;
- int uvBorderH = border >> ssY;
+ int yStride = ((alignedWidth + 2 * Border) + 31) & ~31;
+ int yplaneSize = (alignedHeight + 2 * Border) * yStride;
+ int uvWidth = alignedWidth >> SsX;
+ int uvHeight = alignedHeight >> SsY;
+ int uvStride = yStride >> SsX;
+ int uvBorderW = Border >> SsX;
+ int uvBorderH = Border >> SsY;
int uvplaneSize = (uvHeight + 2 * uvBorderH) * uvStride;
- int frameSize = (highbd ? 2 : 1) * (yplaneSize + 2 * uvplaneSize);
+ int frameSize = (HighBd ? 2 : 1) * (yplaneSize + 2 * uvplaneSize);
IntPtr pointer = Marshal.AllocHGlobal(frameSize);
_pointer = pointer;
@@ -58,23 +60,23 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types
AlignedWidth = alignedWidth;
AlignedHeight = alignedHeight;
Stride = yStride;
- UvWidth = (width + ssX) >> ssX;
- UvHeight = (height + ssY) >> ssY;
+ UvWidth = (width + SsX) >> SsX;
+ UvHeight = (height + SsY) >> SsY;
UvAlignedWidth = uvWidth;
UvAlignedHeight = uvHeight;
UvStride = uvStride;
- ArrayPtr<byte> NewPlane(int start, int size, int border)
+ ArrayPtr<byte> NewPlane(int start, int size, int planeBorder)
{
- return new ArrayPtr<byte>(pointer + start + border, size - border);
+ return new ArrayPtr<byte>(pointer + start + planeBorder, size - planeBorder);
}
- YBuffer = NewPlane(0, yplaneSize, (border * yStride) + border);
+ YBuffer = NewPlane(0, yplaneSize, (Border * yStride) + Border);
UBuffer = NewPlane(yplaneSize, uvplaneSize, (uvBorderH * uvStride) + uvBorderW);
VBuffer = NewPlane(yplaneSize + uvplaneSize, uvplaneSize, (uvBorderH * uvStride) + uvBorderW);
}
- public void Dispose()
+ public readonly void Dispose()
{
Marshal.FreeHGlobal(_pointer);
}