Fix segfaults

This commit is contained in:
IsaacMarovitz 2024-05-10 13:21:07 -04:00
parent eff2d891c5
commit 4aa0ea11d2
No known key found for this signature in database
GPG key ID: 7B138C0A9A1D297E
4 changed files with 12 additions and 12 deletions

View file

@ -32,22 +32,22 @@ namespace Ryujinx.Graphics.OpenGL
return Handle.FromUInt32<BufferHandle>(api.GenBuffer()); return Handle.FromUInt32<BufferHandle>(api.GenBuffer());
} }
public static BufferHandle Create(GL api, int size) public unsafe static BufferHandle Create(GL api, int size)
{ {
uint handle = api.GenBuffer(); uint handle = api.GenBuffer();
api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle); api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle);
api.BufferData(BufferTargetARB.CopyWriteBuffer, (uint)size, in UIntPtr.Zero, BufferUsageARB.DynamicDraw); api.BufferData(BufferTargetARB.CopyWriteBuffer, (uint)size, null, BufferUsageARB.DynamicDraw);
return Handle.FromUInt32<BufferHandle>(handle); return Handle.FromUInt32<BufferHandle>(handle);
} }
public static BufferHandle CreatePersistent(GL api, int size) public unsafe static BufferHandle CreatePersistent(GL api, int size)
{ {
uint handle = api.GenBuffer(); uint handle = api.GenBuffer();
api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle); api.BindBuffer(BufferTargetARB.CopyWriteBuffer, handle);
api.BufferStorage(BufferStorageTarget.CopyWriteBuffer, (uint)size, in UIntPtr.Zero, api.BufferStorage(BufferStorageTarget.CopyWriteBuffer, (uint)size, null,
BufferStorageMask.MapPersistentBit | BufferStorageMask.MapPersistentBit |
BufferStorageMask.MapCoherentBit | BufferStorageMask.MapCoherentBit |
BufferStorageMask.ClientStorageBit | BufferStorageMask.ClientStorageBit |
@ -92,10 +92,10 @@ namespace Ryujinx.Graphics.OpenGL
return new PinnedSpan<byte>(target.ToPointer(), size); return new PinnedSpan<byte>(target.ToPointer(), size);
} }
public static void Resize(GL api, BufferHandle handle, int size) public unsafe 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, in UIntPtr.Zero, BufferUsageARB.StreamCopy); api.BufferData(BufferTargetARB.CopyWriteBuffer, (uint)size, null, 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

@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.OpenGL
private static int _counter; private static int _counter;
public static void Initialize(GL gl, GraphicsDebugLevel logLevel) public unsafe static void Initialize(GL gl, GraphicsDebugLevel logLevel)
{ {
// Disable everything // Disable everything
gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (uint[])null, false); gl.DebugMessageControl(DebugSource.DontCare, DebugType.DontCare, DebugSeverity.DontCare, 0, (uint[])null, false);
@ -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, in IntPtr.Zero); gl.DebugMessageCallback(null, null);
return; return;
} }
@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.OpenGL
_counter = 0; _counter = 0;
_debugCallback = GLDebugHandler; _debugCallback = GLDebugHandler;
gl.DebugMessageCallback(_debugCallback, in IntPtr.Zero); gl.DebugMessageCallback(_debugCallback, null);
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

@ -442,7 +442,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
_gd.Api.BindBuffer(BufferTargetARB.PixelUnpackBuffer, 0); _gd.Api.BindBuffer(BufferTargetARB.PixelUnpackBuffer, 0);
} }
private void EnsurePbo(TextureView view) private unsafe void EnsurePbo(TextureView view)
{ {
int requiredSize = 0; int requiredSize = 0;
@ -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, in IntPtr.Zero, BufferUsageARB.DynamicCopy); _gd.Api.BufferData(BufferTargetARB.PixelPackBuffer, (uint)requiredSize, null, 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, in IntPtr.Zero, BufferStorageMask.MapReadBit | BufferStorageMask.MapPersistentBit); _api.BufferStorage(BufferStorageTarget.CopyWriteBuffer, (uint)requiredSize, null, 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);
} }