diff --git a/src/Ryujinx.Graphics.OpenGL/Buffer.cs b/src/Ryujinx.Graphics.OpenGL/Buffer.cs index 630cc8073..e5c2e0723 100644 --- a/src/Ryujinx.Graphics.OpenGL/Buffer.cs +++ b/src/Ryujinx.Graphics.OpenGL/Buffer.cs @@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.OpenGL size, PixelFormat.RgbaInteger, PixelType.UnsignedByte, - (IntPtr)valueArr); + valueArr); } } @@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.OpenGL uint handle = api.GenBuffer(); api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle); - api.BufferData(BufferTargetARB.CopyWriteBuffer, (uint)size, UIntPtr.Zero, BufferUsageARB.DynamicDraw); + api.BufferData(BufferTargetARB.CopyWriteBuffer, (uint)size, in UIntPtr.Zero, BufferUsageARB.DynamicDraw); return Handle.FromUInt32(handle); } @@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.OpenGL uint handle = api.GenBuffer(); api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle); - api.BufferStorage(BufferStorageTarget.CopyWriteBuffer, (uint)size, UIntPtr.Zero, + api.BufferStorage(BufferStorageTarget.CopyWriteBuffer, (uint)size, in UIntPtr.Zero, BufferStorageMask.MapPersistentBit | BufferStorageMask.MapCoherentBit | BufferStorageMask.ClientStorageBit | @@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.OpenGL public static void Resize(GL api, BufferHandle handle, int size) { api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle.ToUInt32()); - api.BufferData(BufferTargetARB.CopyWriteBuffer, (uint)size, UIntPtr.Zero, BufferUsageARB.StreamCopy); + api.BufferData(BufferTargetARB.CopyWriteBuffer, (uint)size, in UIntPtr.Zero, BufferUsageARB.StreamCopy); } public static void SetData(GL api, BufferHandle buffer, int offset, ReadOnlySpan data) diff --git a/src/Ryujinx.Graphics.OpenGL/Debugger.cs b/src/Ryujinx.Graphics.OpenGL/Debugger.cs index dc1aecf24..963bb0b5d 100644 --- a/src/Ryujinx.Graphics.OpenGL/Debugger.cs +++ b/src/Ryujinx.Graphics.OpenGL/Debugger.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.OpenGL if (logLevel == GraphicsDebugLevel.None) { gl.Disable(EnableCap.DebugOutputSynchronous); - gl.DebugMessageCallback(null, IntPtr.Zero); + gl.DebugMessageCallback(null, in IntPtr.Zero); return; } @@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.OpenGL _counter = 0; _debugCallback = GLDebugHandler; - gl.DebugMessageCallback(_debugCallback, IntPtr.Zero); + gl.DebugMessageCallback(_debugCallback, in IntPtr.Zero); Logger.Warning?.Print(LogClass.Gpu, "OpenGL Debugging is enabled. Performance will be negatively impacted."); } diff --git a/src/Ryujinx.Graphics.OpenGL/EnumConversion.cs b/src/Ryujinx.Graphics.OpenGL/EnumConversion.cs index 81dbb7b5b..75528e67b 100644 --- a/src/Ryujinx.Graphics.OpenGL/EnumConversion.cs +++ b/src/Ryujinx.Graphics.OpenGL/EnumConversion.cs @@ -14,7 +14,9 @@ namespace Ryujinx.Graphics.OpenGL switch (mode) { case AddressMode.Clamp: +#pragma warning disable CS0618 // Type or member is obsolete return TextureWrapMode.Clamp; +#pragma warning restore CS0618 // Type or member is obsolete case AddressMode.Repeat: return TextureWrapMode.Repeat; case AddressMode.MirrorClamp: @@ -33,7 +35,9 @@ namespace Ryujinx.Graphics.OpenGL Logger.Debug?.Print(LogClass.Gpu, $"Invalid {nameof(AddressMode)} enum value: {mode}."); +#pragma warning disable CS0618 // Type or member is obsolete return TextureWrapMode.Clamp; +#pragma warning restore CS0618 // Type or member is obsolete } public static NV Convert(this AdvancedBlendOp op) @@ -451,7 +455,9 @@ namespace Ryujinx.Graphics.OpenGL case PrimitiveTopology.Quads: return PrimitiveType.Quads; case PrimitiveTopology.QuadStrip: +#pragma warning disable CS0618 // Type or member is obsolete return PrimitiveType.QuadStrip; +#pragma warning restore CS0618 // Type or member is obsolete case PrimitiveTopology.Polygon: return PrimitiveType.TriangleFan; case PrimitiveTopology.LinesAdjacency: diff --git a/src/Ryujinx.Graphics.OpenGL/HardwareCapabilities.cs b/src/Ryujinx.Graphics.OpenGL/HardwareCapabilities.cs index 704cbcd02..5e0ece3bf 100644 --- a/src/Ryujinx.Graphics.OpenGL/HardwareCapabilities.cs +++ b/src/Ryujinx.Graphics.OpenGL/HardwareCapabilities.cs @@ -152,8 +152,10 @@ namespace Ryujinx.Graphics.OpenGL public static bool SupportsQuadsCheck(GL api) { api.GetError(); // Clear any existing error. +#pragma warning disable CS0618 // Type or member is obsolete api.Begin(PrimitiveType.Quads); api.End(); +#pragma warning restore CS0618 // Type or member is obsolete return api.GetError() == GLEnum.NoError; } diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs index 1e70ab3ba..a3a65b9b2 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs @@ -464,7 +464,7 @@ namespace Ryujinx.Graphics.OpenGL.Image _copyPboSize = requiredSize; _gd.Api.BindBuffer(BufferTargetARB.PixelPackBuffer, _copyPboHandle); - _gd.Api.BufferData(BufferTargetARB.PixelPackBuffer, (uint)requiredSize, IntPtr.Zero, BufferUsageARB.DynamicCopy); + _gd.Api.BufferData(BufferTargetARB.PixelPackBuffer, (uint)requiredSize, in IntPtr.Zero, BufferUsageARB.DynamicCopy); } } diff --git a/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs b/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs index 33ef1b7d8..e80099499 100644 --- a/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs +++ b/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs @@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.OpenGL _copyBufferSize = requiredSize; _api.BindBuffer(BufferTargetARB.CopyWriteBuffer, _copyBufferHandle); - _api.BufferStorage(BufferStorageTarget.CopyWriteBuffer, (uint)requiredSize, IntPtr.Zero, BufferStorageMask.MapReadBit | BufferStorageMask.MapPersistentBit); + _api.BufferStorage(BufferStorageTarget.CopyWriteBuffer, (uint)requiredSize, in IntPtr.Zero, BufferStorageMask.MapReadBit | BufferStorageMask.MapPersistentBit); _bufferMap = (IntPtr)_api.MapBufferRange(BufferTargetARB.CopyWriteBuffer, IntPtr.Zero, (uint)requiredSize, MapBufferAccessMask.ReadBit | MapBufferAccessMask.PersistentBit); } diff --git a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs index d8aae8dd2..5f97fc25a 100644 --- a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -238,7 +238,9 @@ namespace Ryujinx.Graphics.OpenGL { DrawQuadsImpl(vertexCount, instanceCount, firstVertex, firstInstance); } +#pragma warning disable CS0618 // Type or member is obsolete else if (_primitiveType == PrimitiveType.QuadStrip && !_gd.Capabilities.SupportsQuads) +#pragma warning restore CS0618 // Type or member is obsolete { DrawQuadStripImpl(vertexCount, instanceCount, firstVertex, firstInstance); } @@ -376,7 +378,9 @@ namespace Ryujinx.Graphics.OpenGL firstVertex, firstInstance); } +#pragma warning disable CS0618 // Type or member is obsolete else if (_primitiveType == PrimitiveType.QuadStrip && !_gd.Capabilities.SupportsQuads) +#pragma warning restore CS0618 // Type or member is obsolete { DrawQuadStripIndexedImpl( indexCount, @@ -476,7 +480,7 @@ namespace Ryujinx.Graphics.OpenGL PrimitiveType.TriangleFan, countsPtr, _elementsType, - indicesPtr, + in indicesPtr, (uint)quadsCount, baseVerticesPtr); } @@ -523,7 +527,7 @@ namespace Ryujinx.Graphics.OpenGL PrimitiveType.TriangleFan, countsPtr, _elementsType, - indicesPtr, + in indicesPtr, (uint)quadsCount, baseVerticesPtr); } @@ -538,7 +542,7 @@ namespace Ryujinx.Graphics.OpenGL { if (firstInstance == 0 && firstVertex == 0 && instanceCount == 1) { - _gd.Api.DrawElements(_primitiveType, (uint)indexCount, _elementsType, indexBaseOffset); + _gd.Api.DrawElements(_primitiveType, (uint)indexCount, _elementsType, in indexBaseOffset); } else if (firstInstance == 0 && instanceCount == 1) { @@ -546,7 +550,7 @@ namespace Ryujinx.Graphics.OpenGL _primitiveType, (uint)indexCount, _elementsType, - indexBaseOffset, + in indexBaseOffset, firstVertex); } else if (firstInstance == 0 && firstVertex == 0) @@ -555,7 +559,7 @@ namespace Ryujinx.Graphics.OpenGL _primitiveType, (uint)indexCount, _elementsType, - indexBaseOffset, + in indexBaseOffset, (uint)instanceCount); } else if (firstInstance == 0) @@ -564,7 +568,7 @@ namespace Ryujinx.Graphics.OpenGL _primitiveType, (uint)indexCount, _elementsType, - indexBaseOffset, + in indexBaseOffset, (uint)instanceCount, firstVertex); } @@ -574,7 +578,7 @@ namespace Ryujinx.Graphics.OpenGL _primitiveType, (uint)indexCount, _elementsType, - indexBaseOffset, + in indexBaseOffset, (uint)instanceCount, (uint)firstInstance); } @@ -584,7 +588,7 @@ namespace Ryujinx.Graphics.OpenGL _primitiveType, (uint)indexCount, _elementsType, - indexBaseOffset, + in indexBaseOffset, (uint)instanceCount, firstVertex, (uint)firstInstance); @@ -605,7 +609,7 @@ namespace Ryujinx.Graphics.OpenGL _gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32()); - _gd.Api.DrawElementsIndirect(_primitiveType, _elementsType, (IntPtr)indirectBuffer.Offset); + _gd.Api.DrawElementsIndirect(_primitiveType, _elementsType, indirectBuffer.Offset); _vertexArray.RestoreIndexBuffer(); @@ -630,7 +634,7 @@ namespace Ryujinx.Graphics.OpenGL _gd.Api.MultiDrawElementsIndirectCount( _primitiveType, _elementsType, - (IntPtr)indirectBuffer.Offset, + indirectBuffer.Offset, parameterBuffer.Offset, (uint)maxDrawCount, (uint)stride); @@ -652,7 +656,7 @@ namespace Ryujinx.Graphics.OpenGL _gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32()); - _gd.Api.DrawArraysIndirect(_primitiveType, (IntPtr)indirectBuffer.Offset); + _gd.Api.DrawArraysIndirect(_primitiveType, indirectBuffer.Offset); PostDraw(); } @@ -672,7 +676,7 @@ namespace Ryujinx.Graphics.OpenGL _gd.Api.MultiDrawArraysIndirectCount( _primitiveType, - (IntPtr)indirectBuffer.Offset, + indirectBuffer.Offset, parameterBuffer.Offset, (uint)maxDrawCount, (uint)stride); @@ -778,6 +782,7 @@ namespace Ryujinx.Graphics.OpenGL _tfEnabled = false; } +#pragma warning disable CS0618 // Type or member is obsolete public void SetAlphaTest(bool enable, float reference, CompareOp op) { if (!enable) @@ -789,6 +794,7 @@ namespace Ryujinx.Graphics.OpenGL _gd.Api.AlphaFunc((AlphaFunction)op.Convert(), reference); _gd.Api.Enable(EnableCap.AlphaTest); } +#pragma warning restore CS0618 // Type or member is obsolete public void SetBlendState(AdvancedBlendDescriptor blend) { @@ -1068,6 +1074,7 @@ namespace Ryujinx.Graphics.OpenGL } } +#pragma warning disable CS0618 // Type or member is obsolete public void SetPointParameters(float size, bool isProgramPointSize, bool enablePointSprite, Origin origin) { // GL_POINT_SPRITE was deprecated in core profile 3.2+ and causes GL_INVALID_ENUM when set. @@ -1098,6 +1105,7 @@ namespace Ryujinx.Graphics.OpenGL // From the spec, GL_INVALID_VALUE is generated if size is less than or equal to 0. _gd.Api.PointSize(Math.Max(float.Epsilon, size)); } +#pragma warning restore CS0618 // Type or member is obsolete public void SetPolygonMode(GAL.PolygonMode frontMode, GAL.PolygonMode backMode) { diff --git a/src/Ryujinx.Graphics.OpenGL/Program.cs b/src/Ryujinx.Graphics.OpenGL/Program.cs index 9c59f402b..11a064fa1 100644 --- a/src/Ryujinx.Graphics.OpenGL/Program.cs +++ b/src/Ryujinx.Graphics.OpenGL/Program.cs @@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.OpenGL { fixed (byte* ptr = code) { - _gd.Api.ProgramBinary(Handle, (GLEnum)binaryFormat, (IntPtr)ptr, (uint)code.Length - 4); + _gd.Api.ProgramBinary(Handle, (GLEnum)binaryFormat, ptr, (uint)code.Length - 4); } } } diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs b/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs index a033ad0ba..8c9ce1d28 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs @@ -27,12 +27,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries _type = type; _api.BindBuffer(BufferTargetARB.QueryBuffer, _buffer); - - unsafe - { - long defaultValue = DefaultValue; - _api.BufferStorage(BufferStorageTarget.QueryBuffer, sizeof(long), (IntPtr)(&defaultValue), BufferStorageMask.MapReadBit | BufferStorageMask.MapWriteBit | BufferStorageMask.MapPersistentBit); - } + _api.BufferStorage(BufferStorageTarget.QueryBuffer, sizeof(long), DefaultValue, BufferStorageMask.MapReadBit | BufferStorageMask.MapWriteBit | BufferStorageMask.MapPersistentBit); unsafe {