Fix some warnings

This commit is contained in:
Isaac Marovitz 2024-05-09 23:10:13 -04:00
parent 2b07d783c8
commit bab7457b99
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
9 changed files with 38 additions and 27 deletions

View file

@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.OpenGL
size, size,
PixelFormat.RgbaInteger, PixelFormat.RgbaInteger,
PixelType.UnsignedByte, PixelType.UnsignedByte,
(IntPtr)valueArr); valueArr);
} }
} }
@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.OpenGL
uint handle = api.GenBuffer(); uint handle = api.GenBuffer();
api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle); 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<BufferHandle>(handle); return Handle.FromUInt32<BufferHandle>(handle);
} }
@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.OpenGL
uint handle = api.GenBuffer(); uint handle = api.GenBuffer();
api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle); 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.MapPersistentBit |
BufferStorageMask.MapCoherentBit | BufferStorageMask.MapCoherentBit |
BufferStorageMask.ClientStorageBit | BufferStorageMask.ClientStorageBit |
@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.OpenGL
public static void Resize(GL api, BufferHandle handle, int size) public static void Resize(GL api, BufferHandle handle, int size)
{ {
api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle.ToUInt32()); 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<byte> data) public static void SetData(GL api, BufferHandle buffer, int offset, ReadOnlySpan<byte> data)

View file

@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.OpenGL
if (logLevel == GraphicsDebugLevel.None) if (logLevel == GraphicsDebugLevel.None)
{ {
gl.Disable(EnableCap.DebugOutputSynchronous); gl.Disable(EnableCap.DebugOutputSynchronous);
gl.DebugMessageCallback(null, IntPtr.Zero); gl.DebugMessageCallback(null, in IntPtr.Zero);
return; return;
} }
@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.OpenGL
_counter = 0; _counter = 0;
_debugCallback = GLDebugHandler; _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."); Logger.Warning?.Print(LogClass.Gpu, "OpenGL Debugging is enabled. Performance will be negatively impacted.");
} }

View file

@ -14,7 +14,9 @@ namespace Ryujinx.Graphics.OpenGL
switch (mode) switch (mode)
{ {
case AddressMode.Clamp: case AddressMode.Clamp:
#pragma warning disable CS0618 // Type or member is obsolete
return TextureWrapMode.Clamp; return TextureWrapMode.Clamp;
#pragma warning restore CS0618 // Type or member is obsolete
case AddressMode.Repeat: case AddressMode.Repeat:
return TextureWrapMode.Repeat; return TextureWrapMode.Repeat;
case AddressMode.MirrorClamp: case AddressMode.MirrorClamp:
@ -33,7 +35,9 @@ namespace Ryujinx.Graphics.OpenGL
Logger.Debug?.Print(LogClass.Gpu, $"Invalid {nameof(AddressMode)} enum value: {mode}."); Logger.Debug?.Print(LogClass.Gpu, $"Invalid {nameof(AddressMode)} enum value: {mode}.");
#pragma warning disable CS0618 // Type or member is obsolete
return TextureWrapMode.Clamp; return TextureWrapMode.Clamp;
#pragma warning restore CS0618 // Type or member is obsolete
} }
public static NV Convert(this AdvancedBlendOp op) public static NV Convert(this AdvancedBlendOp op)
@ -451,7 +455,9 @@ namespace Ryujinx.Graphics.OpenGL
case PrimitiveTopology.Quads: case PrimitiveTopology.Quads:
return PrimitiveType.Quads; return PrimitiveType.Quads;
case PrimitiveTopology.QuadStrip: case PrimitiveTopology.QuadStrip:
#pragma warning disable CS0618 // Type or member is obsolete
return PrimitiveType.QuadStrip; return PrimitiveType.QuadStrip;
#pragma warning restore CS0618 // Type or member is obsolete
case PrimitiveTopology.Polygon: case PrimitiveTopology.Polygon:
return PrimitiveType.TriangleFan; return PrimitiveType.TriangleFan;
case PrimitiveTopology.LinesAdjacency: case PrimitiveTopology.LinesAdjacency:

View file

@ -152,8 +152,10 @@ namespace Ryujinx.Graphics.OpenGL
public static bool SupportsQuadsCheck(GL api) public static bool SupportsQuadsCheck(GL api)
{ {
api.GetError(); // Clear any existing error. api.GetError(); // Clear any existing error.
#pragma warning disable CS0618 // Type or member is obsolete
api.Begin(PrimitiveType.Quads); api.Begin(PrimitiveType.Quads);
api.End(); api.End();
#pragma warning restore CS0618 // Type or member is obsolete
return api.GetError() == GLEnum.NoError; return api.GetError() == GLEnum.NoError;
} }

View file

@ -464,7 +464,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
_copyPboSize = requiredSize; _copyPboSize = requiredSize;
_gd.Api.BindBuffer(BufferTargetARB.PixelPackBuffer, _copyPboHandle); _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);
} }
} }

View file

@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.OpenGL
_copyBufferSize = requiredSize; _copyBufferSize = requiredSize;
_api.BindBuffer(BufferTargetARB.CopyWriteBuffer, _copyBufferHandle); _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); _bufferMap = (IntPtr)_api.MapBufferRange(BufferTargetARB.CopyWriteBuffer, IntPtr.Zero, (uint)requiredSize, MapBufferAccessMask.ReadBit | MapBufferAccessMask.PersistentBit);
} }

View file

@ -238,7 +238,9 @@ namespace Ryujinx.Graphics.OpenGL
{ {
DrawQuadsImpl(vertexCount, instanceCount, firstVertex, firstInstance); DrawQuadsImpl(vertexCount, instanceCount, firstVertex, firstInstance);
} }
#pragma warning disable CS0618 // Type or member is obsolete
else if (_primitiveType == PrimitiveType.QuadStrip && !_gd.Capabilities.SupportsQuads) else if (_primitiveType == PrimitiveType.QuadStrip && !_gd.Capabilities.SupportsQuads)
#pragma warning restore CS0618 // Type or member is obsolete
{ {
DrawQuadStripImpl(vertexCount, instanceCount, firstVertex, firstInstance); DrawQuadStripImpl(vertexCount, instanceCount, firstVertex, firstInstance);
} }
@ -376,7 +378,9 @@ namespace Ryujinx.Graphics.OpenGL
firstVertex, firstVertex,
firstInstance); firstInstance);
} }
#pragma warning disable CS0618 // Type or member is obsolete
else if (_primitiveType == PrimitiveType.QuadStrip && !_gd.Capabilities.SupportsQuads) else if (_primitiveType == PrimitiveType.QuadStrip && !_gd.Capabilities.SupportsQuads)
#pragma warning restore CS0618 // Type or member is obsolete
{ {
DrawQuadStripIndexedImpl( DrawQuadStripIndexedImpl(
indexCount, indexCount,
@ -476,7 +480,7 @@ namespace Ryujinx.Graphics.OpenGL
PrimitiveType.TriangleFan, PrimitiveType.TriangleFan,
countsPtr, countsPtr,
_elementsType, _elementsType,
indicesPtr, in indicesPtr,
(uint)quadsCount, (uint)quadsCount,
baseVerticesPtr); baseVerticesPtr);
} }
@ -523,7 +527,7 @@ namespace Ryujinx.Graphics.OpenGL
PrimitiveType.TriangleFan, PrimitiveType.TriangleFan,
countsPtr, countsPtr,
_elementsType, _elementsType,
indicesPtr, in indicesPtr,
(uint)quadsCount, (uint)quadsCount,
baseVerticesPtr); baseVerticesPtr);
} }
@ -538,7 +542,7 @@ namespace Ryujinx.Graphics.OpenGL
{ {
if (firstInstance == 0 && firstVertex == 0 && instanceCount == 1) 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) else if (firstInstance == 0 && instanceCount == 1)
{ {
@ -546,7 +550,7 @@ namespace Ryujinx.Graphics.OpenGL
_primitiveType, _primitiveType,
(uint)indexCount, (uint)indexCount,
_elementsType, _elementsType,
indexBaseOffset, in indexBaseOffset,
firstVertex); firstVertex);
} }
else if (firstInstance == 0 && firstVertex == 0) else if (firstInstance == 0 && firstVertex == 0)
@ -555,7 +559,7 @@ namespace Ryujinx.Graphics.OpenGL
_primitiveType, _primitiveType,
(uint)indexCount, (uint)indexCount,
_elementsType, _elementsType,
indexBaseOffset, in indexBaseOffset,
(uint)instanceCount); (uint)instanceCount);
} }
else if (firstInstance == 0) else if (firstInstance == 0)
@ -564,7 +568,7 @@ namespace Ryujinx.Graphics.OpenGL
_primitiveType, _primitiveType,
(uint)indexCount, (uint)indexCount,
_elementsType, _elementsType,
indexBaseOffset, in indexBaseOffset,
(uint)instanceCount, (uint)instanceCount,
firstVertex); firstVertex);
} }
@ -574,7 +578,7 @@ namespace Ryujinx.Graphics.OpenGL
_primitiveType, _primitiveType,
(uint)indexCount, (uint)indexCount,
_elementsType, _elementsType,
indexBaseOffset, in indexBaseOffset,
(uint)instanceCount, (uint)instanceCount,
(uint)firstInstance); (uint)firstInstance);
} }
@ -584,7 +588,7 @@ namespace Ryujinx.Graphics.OpenGL
_primitiveType, _primitiveType,
(uint)indexCount, (uint)indexCount,
_elementsType, _elementsType,
indexBaseOffset, in indexBaseOffset,
(uint)instanceCount, (uint)instanceCount,
firstVertex, firstVertex,
(uint)firstInstance); (uint)firstInstance);
@ -605,7 +609,7 @@ namespace Ryujinx.Graphics.OpenGL
_gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32()); _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(); _vertexArray.RestoreIndexBuffer();
@ -630,7 +634,7 @@ namespace Ryujinx.Graphics.OpenGL
_gd.Api.MultiDrawElementsIndirectCount( _gd.Api.MultiDrawElementsIndirectCount(
_primitiveType, _primitiveType,
_elementsType, _elementsType,
(IntPtr)indirectBuffer.Offset, indirectBuffer.Offset,
parameterBuffer.Offset, parameterBuffer.Offset,
(uint)maxDrawCount, (uint)maxDrawCount,
(uint)stride); (uint)stride);
@ -652,7 +656,7 @@ namespace Ryujinx.Graphics.OpenGL
_gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32()); _gd.Api.BindBuffer(BufferTargetARB.DrawIndirectBuffer, indirectBuffer.Handle.ToUInt32());
_gd.Api.DrawArraysIndirect(_primitiveType, (IntPtr)indirectBuffer.Offset); _gd.Api.DrawArraysIndirect(_primitiveType, indirectBuffer.Offset);
PostDraw(); PostDraw();
} }
@ -672,7 +676,7 @@ namespace Ryujinx.Graphics.OpenGL
_gd.Api.MultiDrawArraysIndirectCount( _gd.Api.MultiDrawArraysIndirectCount(
_primitiveType, _primitiveType,
(IntPtr)indirectBuffer.Offset, indirectBuffer.Offset,
parameterBuffer.Offset, parameterBuffer.Offset,
(uint)maxDrawCount, (uint)maxDrawCount,
(uint)stride); (uint)stride);
@ -778,6 +782,7 @@ namespace Ryujinx.Graphics.OpenGL
_tfEnabled = false; _tfEnabled = false;
} }
#pragma warning disable CS0618 // Type or member is obsolete
public void SetAlphaTest(bool enable, float reference, CompareOp op) public void SetAlphaTest(bool enable, float reference, CompareOp op)
{ {
if (!enable) if (!enable)
@ -789,6 +794,7 @@ namespace Ryujinx.Graphics.OpenGL
_gd.Api.AlphaFunc((AlphaFunction)op.Convert(), reference); _gd.Api.AlphaFunc((AlphaFunction)op.Convert(), reference);
_gd.Api.Enable(EnableCap.AlphaTest); _gd.Api.Enable(EnableCap.AlphaTest);
} }
#pragma warning restore CS0618 // Type or member is obsolete
public void SetBlendState(AdvancedBlendDescriptor blend) 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) 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. // 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. // 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)); _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) public void SetPolygonMode(GAL.PolygonMode frontMode, GAL.PolygonMode backMode)
{ {

View file

@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.OpenGL
{ {
fixed (byte* ptr = code) 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);
} }
} }
} }

View file

@ -27,12 +27,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
_type = type; _type = type;
_api.BindBuffer(BufferTargetARB.QueryBuffer, _buffer); _api.BindBuffer(BufferTargetARB.QueryBuffer, _buffer);
_api.BufferStorage(BufferStorageTarget.QueryBuffer, sizeof(long), DefaultValue, BufferStorageMask.MapReadBit | BufferStorageMask.MapWriteBit | BufferStorageMask.MapPersistentBit);
unsafe
{
long defaultValue = DefaultValue;
_api.BufferStorage(BufferStorageTarget.QueryBuffer, sizeof(long), (IntPtr)(&defaultValue), BufferStorageMask.MapReadBit | BufferStorageMask.MapWriteBit | BufferStorageMask.MapPersistentBit);
}
unsafe unsafe
{ {