[Ryujinx.Graphics.Gpu] Address dotnet-format issues (#5367)

* 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

* Silence dotnet format IDE0052 warnings

* Address dotnet format CA1816 warnings

* Address or silence dotnet format CA1069 warnings

* Address or silence dotnet format CA2211 warnings

* Address remaining dotnet format analyzer warnings

* Address review comments

* 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

* Format if-blocks correctly

* Run dotnet format whitespace after rebase

* Run dotnet format style after rebase

* Another rebase, another dotnet format run

* Run dotnet format style after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Disable 'prefer switch expression' rule

* Add comments to disabled warnings

* Remove a few unused parameters

* Replace MmeShadowScratch with Array256<uint>

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Start working on disabled warnings

* Fix and silence a few dotnet-format warnings again

* Run dotnet format after rebase

* Address IDE0251 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

* First pass of dotnet format

* Add unsafe dotnet format changes

* Fix typos

* Add trailing commas

* Disable formatting for FormatTable

* Address review feedback
This commit is contained in:
TSRBerry
2023-07-02 02:47:54 +02:00
committed by GitHub
parent 2457cfc911
commit 3b46bb73f7
145 changed files with 1445 additions and 1427 deletions

View File

@@ -209,14 +209,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
new AdvancedBlendUcode(AdvancedBlendOp.HslHue, AdvancedBlendOverlap.Conjoint, false, GenConjointHslHue),
new AdvancedBlendUcode(AdvancedBlendOp.HslSaturation, AdvancedBlendOverlap.Conjoint, false, GenConjointHslSaturation),
new AdvancedBlendUcode(AdvancedBlendOp.HslColor, AdvancedBlendOverlap.Conjoint, false, GenConjointHslColor),
new AdvancedBlendUcode(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, GenConjointHslLuminosity)
new AdvancedBlendUcode(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, GenConjointHslLuminosity),
};
public static string GenTable()
{
// This can be used to generate the table on AdvancedBlendPreGenTable.
StringBuilder sb = new StringBuilder();
StringBuilder sb = new();
sb.AppendLine($"private static Dictionary<Hash128, AdvancedBlendEntry> _entries = new()");
sb.AppendLine("{");
@@ -4223,4 +4223,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
return new FixedFunctionAlpha(BlendOp.MaximumGl, BlendFactor.OneGl, BlendFactor.OneGl);
}
}
}
}

View File

@@ -54,12 +54,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <returns>True if the function was found, false otherwise</returns>
public bool TryGetAdvancedBlend(out AdvancedBlendDescriptor descriptor)
{
Span<uint> currentCode = new Span<uint>(_code);
Span<uint> currentCode = new(_code);
byte codeLength = (byte)_state.State.BlendUcodeSize;
if (currentCode.Length > codeLength)
{
currentCode = currentCode.Slice(0, codeLength);
currentCode = currentCode[..codeLength];
}
Hash128 hash = XXHash128.ComputeHash(MemoryMarshal.Cast<uint, byte>(currentCode));
@@ -112,4 +112,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
return true;
}
}
}
}

View File

@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Advanced blend function entry.
/// </summary>
struct AdvancedBlendEntry
readonly struct AdvancedBlendEntry
{
/// <summary>
/// Advanced blend operation.
@@ -270,4 +270,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
{ new Hash128(0x8652300E32D93050, 0x9460E7B449132371), new AdvancedBlendEntry(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, new[] { new RgbFloat(0.3f, 0.59f, 0.11f) }, new FixedFunctionAlpha(BlendUcodeEnable.EnableRGB, BlendOp.MaximumGl, BlendFactor.OneGl, BlendFactor.OneGl)) },
};
}
}
}

View File

@@ -5,12 +5,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Fixed function alpha state used for a advanced blend function.
/// </summary>
struct FixedFunctionAlpha
readonly struct FixedFunctionAlpha
{
/// <summary>
/// Fixed function alpha state with alpha blending disabled.
/// </summary>
public static FixedFunctionAlpha Disabled => new FixedFunctionAlpha(BlendUcodeEnable.EnableRGBA, default, default, default);
public static FixedFunctionAlpha Disabled => new(BlendUcodeEnable.EnableRGBA, default, default, default);
/// <summary>
/// Individual enable bits for the RGB and alpha components.
@@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Advanced blend microcode state.
/// </summary>
struct AdvancedBlendUcode
readonly struct AdvancedBlendUcode
{
/// <summary>
/// Advanced blend operation.
@@ -117,10 +117,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Overlap = overlap;
SrcPreMultiplied = srcPreMultiplied;
UcodeAssembler asm = new UcodeAssembler();
UcodeAssembler asm = new();
Alpha = genFunc(ref asm);
Code = asm.GetCode();
Constants = asm.GetConstants();
}
}
}
}

View File

@@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Max = 3,
Rcp = 4,
Add = 5,
Sub = 6
Sub = 6,
}
/// <summary>
@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
LT = 4,
LE = 5,
GT = 6,
GE = 7
GE = 7,
}
/// <summary>
@@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp1 = 0xa,
Temp2 = 0xb,
PBR = 0xc,
ConstantRGB = 0xd
ConstantRGB = 0xd,
}
/// <summary>
@@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp0 = 4,
Temp1 = 5,
Temp2 = 6,
PBR = 7
PBR = 7,
}
/// <summary>
@@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp0 = 0,
Temp1 = 1,
Temp2 = 2,
PBR = 3
PBR = 3,
}
/// <summary>
@@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
RRR = 2,
GGG = 3,
BBB = 4,
RToA = 5
RToA = 5,
}
/// <summary>
@@ -99,13 +99,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
RGB = 0,
R = 1,
G = 2,
B = 3
B = 3,
}
/// <summary>
/// Floating-point RGB color values.
/// </summary>
struct RgbFloat
readonly struct RgbFloat
{
/// <summary>
/// Red component value.
@@ -139,24 +139,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Blend microcode destination operand, including swizzle, write mask and condition code update flag.
/// </summary>
struct Dest
readonly struct Dest
{
public static Dest Temp0 => new Dest(OpDst.Temp0, Swizzle.RGB, WriteMask.RGB, false);
public static Dest Temp1 => new Dest(OpDst.Temp1, Swizzle.RGB, WriteMask.RGB, false);
public static Dest Temp2 => new Dest(OpDst.Temp2, Swizzle.RGB, WriteMask.RGB, false);
public static Dest PBR => new Dest(OpDst.PBR, Swizzle.RGB, WriteMask.RGB, false);
public static Dest Temp0 => new(OpDst.Temp0, Swizzle.RGB, WriteMask.RGB, false);
public static Dest Temp1 => new(OpDst.Temp1, Swizzle.RGB, WriteMask.RGB, false);
public static Dest Temp2 => new(OpDst.Temp2, Swizzle.RGB, WriteMask.RGB, false);
public static Dest PBR => new(OpDst.PBR, Swizzle.RGB, WriteMask.RGB, false);
public Dest GBR => new Dest(Dst, Swizzle.GBR, WriteMask, WriteCC);
public Dest RRR => new Dest(Dst, Swizzle.RRR, WriteMask, WriteCC);
public Dest GGG => new Dest(Dst, Swizzle.GGG, WriteMask, WriteCC);
public Dest BBB => new Dest(Dst, Swizzle.BBB, WriteMask, WriteCC);
public Dest RToA => new Dest(Dst, Swizzle.RToA, WriteMask, WriteCC);
public Dest GBR => new(Dst, Swizzle.GBR, WriteMask, WriteCC);
public Dest RRR => new(Dst, Swizzle.RRR, WriteMask, WriteCC);
public Dest GGG => new(Dst, Swizzle.GGG, WriteMask, WriteCC);
public Dest BBB => new(Dst, Swizzle.BBB, WriteMask, WriteCC);
public Dest RToA => new(Dst, Swizzle.RToA, WriteMask, WriteCC);
public Dest R => new Dest(Dst, Swizzle, WriteMask.R, WriteCC);
public Dest G => new Dest(Dst, Swizzle, WriteMask.G, WriteCC);
public Dest B => new Dest(Dst, Swizzle, WriteMask.B, WriteCC);
public Dest R => new(Dst, Swizzle, WriteMask.R, WriteCC);
public Dest G => new(Dst, Swizzle, WriteMask.G, WriteCC);
public Dest B => new(Dst, Swizzle, WriteMask.B, WriteCC);
public Dest CC => new Dest(Dst, Swizzle, WriteMask, true);
public Dest CC => new(Dst, Swizzle, WriteMask, true);
public OpDst Dst { get; }
public Swizzle Swizzle { get; }
@@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Blend microcode operaiton.
/// </summary>
struct UcodeOp
readonly struct UcodeOp
{
public readonly uint Word;
@@ -292,14 +292,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
_constantIndex = index;
}
public uint[] GetCode()
public readonly uint[] GetCode()
{
return _code?.ToArray();
}
public RgbFloat[] GetConstants()
public readonly RgbFloat[] GetConstants()
{
return _constants;
}
}
}
}