ソースを参照

misc: chore: Use collection expressions in OpenGL project

Evan Husted 1 年間 前
コミット
a5dbcb75d0

+ 1 - 1
src/Ryujinx.Graphics.OpenGL/Effects/ShaderHelper.cs

@@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects
     {
         public static int CompileProgram(string shaderCode, ShaderType shaderType)
         {
-            return CompileProgram(new string[] { shaderCode }, shaderType);
+            return CompileProgram([shaderCode], shaderType);
         }
 
         public static int CompileProgram(string[] shaders, ShaderType shaderType)

+ 5 - 5
src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs

@@ -44,11 +44,11 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
         {
             _renderer = renderer;
 
-            _edgeShaderPrograms = Array.Empty<int>();
-            _blendShaderPrograms = Array.Empty<int>();
-            _neighbourShaderPrograms = Array.Empty<int>();
+            _edgeShaderPrograms = [];
+            _blendShaderPrograms = [];
+            _neighbourShaderPrograms = [];
 
-            _qualities = new string[] { "SMAA_PRESET_LOW", "SMAA_PRESET_MEDIUM", "SMAA_PRESET_HIGH", "SMAA_PRESET_ULTRA" };
+            _qualities = ["SMAA_PRESET_LOW", "SMAA_PRESET_MEDIUM", "SMAA_PRESET_HIGH", "SMAA_PRESET_ULTRA"];
 
             Quality = quality;
 
@@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
                 string blendShaderData = EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/smaa_blend.glsl");
                 string neighbourShaderData = EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/smaa_neighbour.glsl");
 
-                string[] shaders = new string[] { presets, edgeShaderData };
+                string[] shaders = [presets, edgeShaderData];
                 int edgeProgram = ShaderHelper.CompileProgram(shaders, ShaderType.ComputeShader);
 
                 shaders[1] = blendShaderData;

+ 1 - 1
src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs

@@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
         public IntermediatePool(OpenGLRenderer renderer)
         {
             _renderer = renderer;
-            _entries = new List<TextureView>();
+            _entries = [];
         }
 
         public TextureView GetOrCreateWithAtLeast(

+ 2 - 1
src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs

@@ -190,7 +190,8 @@ void main()
             {
                 int csHandle = GL.CreateShader(ShaderType.ComputeShader);
 
-                string[] formatTable = new[] { "r8ui", "r16ui", "r32ui", "rg8ui", "rg16ui", "rg32ui", "rgba8ui", "rgba16ui", "rgba32ui" };
+                string[] formatTable = ["r8ui", "r16ui", "r32ui", "rg8ui", "rg16ui", "rg32ui", "rgba8ui", "rgba16ui", "rgba32ui"
+                ];
 
                 string srcFormat = formatTable[srcIndex];
                 string dstFormat = formatTable[dstIndex];

+ 4 - 4
src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs

@@ -67,13 +67,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
 
             GL.BindTexture(target, Handle);
 
-            int[] swizzleRgba = new int[]
-            {
+            int[] swizzleRgba =
+            [
                 (int)Info.SwizzleR.Convert(),
                 (int)Info.SwizzleG.Convert(),
                 (int)Info.SwizzleB.Convert(),
-                (int)Info.SwizzleA.Convert(),
-            };
+                (int)Info.SwizzleA.Convert()
+            ];
 
             if (Info.Format == Format.A1B5G5R5Unorm)
             {

+ 3 - 3
src/Ryujinx.Graphics.OpenGL/Pipeline.cs

@@ -35,8 +35,8 @@ namespace Ryujinx.Graphics.OpenGL
         private bool _stencilTestEnable;
         private bool _cullEnable;
 
-        private float[] _viewportArray = Array.Empty<float>();
-        private double[] _depthRangeArray = Array.Empty<double>();
+        private float[] _viewportArray = [];
+        private double[] _depthRangeArray = [];
 
         private int _boundDrawFramebuffer;
         private int _boundReadFramebuffer;
@@ -111,7 +111,7 @@ namespace Ryujinx.Graphics.OpenGL
                 (componentMask & 4) != 0,
                 (componentMask & 8) != 0);
 
-            float[] colors = new float[] { color.Red, color.Green, color.Blue, color.Alpha };
+            float[] colors = [color.Red, color.Green, color.Blue, color.Alpha];
 
             if (layer != 0 || layerCount != _framebuffer.GetColorLayerCount(index))
             {

+ 1 - 1
src/Ryujinx.Graphics.OpenGL/ResourcePool.cs

@@ -34,7 +34,7 @@ namespace Ryujinx.Graphics.OpenGL
             {
                 if (!_textures.TryGetValue(view.Info, out List<DisposedTexture> list))
                 {
-                    list = new List<DisposedTexture>();
+                    list = [];
                     _textures.Add(view.Info, list);
                 }
 

+ 1 - 1
src/Ryujinx.Graphics.OpenGL/Sync.cs

@@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.OpenGL
         private ulong _firstHandle = 0;
         private static ClientWaitSyncFlags SyncFlags => HwCapabilities.RequiresSyncFlush ? ClientWaitSyncFlags.None : ClientWaitSyncFlags.SyncFlushCommandsBit;
 
-        private readonly List<SyncHandle> _handles = new();
+        private readonly List<SyncHandle> _handles = [];
 
         public void Create(ulong id)
         {