diff --git a/src/Ryujinx.Graphics.OpenGL/Buffer.cs b/src/Ryujinx.Graphics.OpenGL/Buffer.cs index e5c2e0723..e7dcfbc3f 100644 --- a/src/Ryujinx.Graphics.OpenGL/Buffer.cs +++ b/src/Ryujinx.Graphics.OpenGL/Buffer.cs @@ -78,20 +78,18 @@ namespace Ryujinx.Graphics.OpenGL { return new PinnedSpan(IntPtr.Add(ptr, offset).ToPointer(), size); } - else if (gd.Capabilities.UsePersistentBufferForFlush) + + if (gd.Capabilities.UsePersistentBufferForFlush) { return PinnedSpan.UnsafeFromSpan(gd.PersistentBuffers.Default.GetBufferData(buffer, offset, size)); } - else - { - IntPtr target = gd.PersistentBuffers.Default.GetHostArray(size); - gd.Api.BindBuffer(BufferTargetARB.CopyReadBuffer, buffer.ToUInt32()); + IntPtr target = gd.PersistentBuffers.Default.GetHostArray(size); - gd.Api.GetBufferSubData(BufferTargetARB.CopyReadBuffer, offset, (uint)size, (void*)target); + gd.Api.BindBuffer(BufferTargetARB.CopyReadBuffer, buffer.ToUInt32()); + gd.Api.GetBufferSubData(BufferTargetARB.CopyReadBuffer, offset, (uint)size, (void*)target); - return new PinnedSpan(target.ToPointer(), size); - } + return new PinnedSpan(target.ToPointer(), size); } public static void Resize(GL api, BufferHandle handle, int size) diff --git a/src/Ryujinx.Graphics.OpenGL/Debugger.cs b/src/Ryujinx.Graphics.OpenGL/Debugger.cs index 963bb0b5d..1a3107ef3 100644 --- a/src/Ryujinx.Graphics.OpenGL/Debugger.cs +++ b/src/Ryujinx.Graphics.OpenGL/Debugger.cs @@ -28,18 +28,18 @@ namespace Ryujinx.Graphics.OpenGL gl.Enable(EnableCap.DebugOutputSynchronous); - if (logLevel == GraphicsDebugLevel.Error) + switch (logLevel) { - gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true); - } - else if (logLevel == GraphicsDebugLevel.Slowdowns) - { - gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true); - gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypePerformance, DebugSeverity.DontCare, 0, (uint[])null, true); - } - else - { - gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (uint[])null, true); + case GraphicsDebugLevel.Error: + gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true); + break; + case GraphicsDebugLevel.Slowdowns: + gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypeError, DebugSeverity.DontCare, 0, (uint[])null, true); + gl.DebugMessageControl(DebugSource.DontCare, DebugType.DebugTypePerformance, DebugSeverity.DontCare, 0, (uint[])null, true); + break; + default: + gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (uint[])null, true); + break; } _counter = 0; diff --git a/src/Ryujinx.Graphics.OpenGL/Framebuffer.cs b/src/Ryujinx.Graphics.OpenGL/Framebuffer.cs index 1a0ecf66b..91947b0ca 100644 --- a/src/Ryujinx.Graphics.OpenGL/Framebuffer.cs +++ b/src/Ryujinx.Graphics.OpenGL/Framebuffer.cs @@ -127,14 +127,13 @@ namespace Ryujinx.Graphics.OpenGL { return FramebufferAttachment.DepthStencilAttachment; } - else if (FormatTable.IsDepthOnly(format)) + + if (FormatTable.IsDepthOnly(format)) { return FramebufferAttachment.DepthAttachment; } - else - { - return FramebufferAttachment.StencilAttachment; - } + + return FramebufferAttachment.StencilAttachment; } public int GetColorLayerCount(int index) diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs index 26d14f5fb..5ce8e3a0c 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs @@ -190,7 +190,7 @@ void main() { uint csHandle = _gd.Api.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]; diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs index 5c40cc177..e3a859ebe 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs @@ -64,13 +64,13 @@ namespace Ryujinx.Graphics.OpenGL.Image _gd.Api.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) { diff --git a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs index deea560ac..53b0715d6 100644 --- a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs +++ b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs @@ -76,13 +76,11 @@ namespace Ryujinx.Graphics.OpenGL return handle; } - else - { - return Buffer.Create(Api, size); - } + + return Buffer.Create(Api, size); } - public BufferHandle CreateBuffer(int size, GAL.BufferAccess access, BufferHandle storageHint) + public BufferHandle CreateBuffer(int size, BufferAccess access, BufferHandle storageHint) { return CreateBuffer(size, access); } @@ -118,10 +116,8 @@ namespace Ryujinx.Graphics.OpenGL { return new TextureBuffer(this, info); } - else - { - return ResourcePool.GetTextureOrNull(info) ?? new TextureStorage(this, info).CreateDefaultView(); - } + + return ResourcePool.GetTextureOrNull(info) ?? new TextureStorage(this, info).CreateDefaultView(); } public ITextureArray CreateTextureArray(int size, bool isBuffer) diff --git a/src/Ryujinx.Graphics.OpenGL/VertexArray.cs b/src/Ryujinx.Graphics.OpenGL/VertexArray.cs index 4961f8a2d..b5eca3bdf 100644 --- a/src/Ryujinx.Graphics.OpenGL/VertexArray.cs +++ b/src/Ryujinx.Graphics.OpenGL/VertexArray.cs @@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.OpenGL Buffer.Copy(_api, vb.Buffer.Handle, tempVertexBuffer, vb.Buffer.Offset, currentTempVbOffset, vb.Buffer.Size); Buffer.Clear(_api, tempVertexBuffer, currentTempVbOffset + vb.Buffer.Size, (uint)(requiredSize - vb.Buffer.Size), 0); - _api.BindVertexBuffer((uint)vbIndex, tempVertexBuffer.ToUInt32(), (IntPtr)currentTempVbOffset, (uint)vb.Stride); + _api.BindVertexBuffer((uint)vbIndex, tempVertexBuffer.ToUInt32(), currentTempVbOffset, (uint)vb.Stride); currentTempVbOffset += requiredSize; _vertexBuffersLimited |= 1u << vbIndex; @@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.OpenGL ref var vb = ref _vertexBuffers[vbIndex]; - _api.BindVertexBuffer((uint)vbIndex, vb.Buffer.Handle.ToUInt32(), (IntPtr)vb.Buffer.Offset, (uint)vb.Stride); + _api.BindVertexBuffer((uint)vbIndex, vb.Buffer.Handle.ToUInt32(), vb.Buffer.Offset, (uint)vb.Stride); buffersLimited &= ~(1u << vbIndex); } diff --git a/src/Ryujinx.Graphics.OpenGL/Window.cs b/src/Ryujinx.Graphics.OpenGL/Window.cs index 0d04114f8..56481ead3 100644 --- a/src/Ryujinx.Graphics.OpenGL/Window.cs +++ b/src/Ryujinx.Graphics.OpenGL/Window.cs @@ -83,7 +83,7 @@ namespace Ryujinx.Graphics.OpenGL { var swappedView = _gd.TextureCopy.BgraSwap(viewConverted); - viewConverted?.Dispose(); + viewConverted.Dispose(); viewConverted = swappedView; } diff --git a/src/Ryujinx.Gtk3/UI/SPBOpenGLContext.cs b/src/Ryujinx.Gtk3/UI/SPBOpenGLContext.cs index 11c5f5be9..21673d83f 100644 --- a/src/Ryujinx.Gtk3/UI/SPBOpenGLContext.cs +++ b/src/Ryujinx.Gtk3/UI/SPBOpenGLContext.cs @@ -1,5 +1,4 @@ using Ryujinx.Graphics.OpenGL; -using Silk.NET.OpenGL.Legacy; using SPB.Graphics; using SPB.Graphics.OpenGL; using SPB.Platform; @@ -38,9 +37,6 @@ namespace Ryujinx.UI context.Initialize(window); context.MakeCurrent(window); - - GL api = GL.GetApi(context.GetProcAddress); - context.MakeCurrent(null); return new SPBOpenGLContext(context, window); diff --git a/src/Ryujinx/UI/Renderer/SPBOpenGLContext.cs b/src/Ryujinx/UI/Renderer/SPBOpenGLContext.cs index 0dc354ec6..0085589ee 100644 --- a/src/Ryujinx/UI/Renderer/SPBOpenGLContext.cs +++ b/src/Ryujinx/UI/Renderer/SPBOpenGLContext.cs @@ -1,5 +1,4 @@ using Ryujinx.Graphics.OpenGL; -using Silk.NET.OpenGL.Legacy; using SPB.Graphics; using SPB.Graphics.OpenGL; using SPB.Platform; @@ -38,9 +37,6 @@ namespace Ryujinx.Ava.UI.Renderer context.Initialize(window); context.MakeCurrent(window); - - GL api = GL.GetApi(context.GetProcAddress); - context.MakeCurrent(null); return new SPBOpenGLContext(context, window);