Fix some stack overflows

This commit is contained in:
IsaacMarovitz 2024-05-09 22:15:55 -04:00
parent e584f8d37d
commit e72bf35c03
No known key found for this signature in database
GPG key ID: 7B138C0A9A1D297E
2 changed files with 21 additions and 28 deletions

View file

@ -103,14 +103,7 @@ namespace Ryujinx.Graphics.OpenGL
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)
{ {
api.BindBuffer(BufferTargetARB.CopyWriteBuffer, buffer.ToUInt32()); api.BindBuffer(BufferTargetARB.CopyWriteBuffer, buffer.ToUInt32());
api.BufferSubData(BufferTargetARB.CopyWriteBuffer, offset, (uint)data.Length, data);
unsafe
{
fixed (byte* ptr = data)
{
api.BufferSubData(BufferTargetARB.CopyWriteBuffer, offset, (uint)data.Length, (IntPtr)ptr);
}
}
} }
public static void Delete(GL api, BufferHandle buffer) public static void Delete(GL api, BufferHandle buffer)

View file

@ -554,7 +554,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
return data; return data;
} }
private void ReadFrom2D(IntPtr data, int layer, int level, int x, int y, int width, int height, int mipSize) private unsafe void ReadFrom2D(IntPtr data, int layer, int level, int x, int y, int width, int height, int mipSize)
{ {
TextureTarget target = Target.Convert(); TextureTarget target = Target.Convert();
@ -574,7 +574,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
(uint)width, (uint)width,
(InternalFormat)format.PixelFormat, (InternalFormat)format.PixelFormat,
(uint)mipSize, (uint)mipSize,
data); (void*)data);
} }
else else
{ {
@ -585,7 +585,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
(uint)width, (uint)width,
format.PixelFormat, format.PixelFormat,
format.PixelType, format.PixelType,
data); (void*)data);
} }
break; break;
@ -601,7 +601,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
1, 1,
(InternalFormat)format.PixelFormat, (InternalFormat)format.PixelFormat,
(uint)mipSize, (uint)mipSize,
data); (void*)data);
} }
else else
{ {
@ -614,7 +614,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
1, 1,
format.PixelFormat, format.PixelFormat,
format.PixelType, format.PixelType,
data); (void*)data);
} }
break; break;
@ -630,7 +630,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
(uint)height, (uint)height,
(InternalFormat)format.PixelFormat, (InternalFormat)format.PixelFormat,
(uint)mipSize, (uint)mipSize,
data); (void*)data);
} }
else else
{ {
@ -643,7 +643,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
(uint)height, (uint)height,
format.PixelFormat, format.PixelFormat,
format.PixelType, format.PixelType,
data); (void*)data);
} }
break; break;
@ -663,7 +663,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
1, 1,
(InternalFormat)format.PixelFormat, (InternalFormat)format.PixelFormat,
(uint)mipSize, (uint)mipSize,
data); (void*)data);
} }
else else
{ {
@ -678,7 +678,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
1, 1,
format.PixelFormat, format.PixelFormat,
format.PixelType, format.PixelType,
data); (void*)data);
} }
break; break;
@ -694,7 +694,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
(uint)height, (uint)height,
(InternalFormat)format.PixelFormat, (InternalFormat)format.PixelFormat,
(uint)mipSize, (uint)mipSize,
data); (void*)data);
} }
else else
{ {
@ -707,13 +707,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
(uint)height, (uint)height,
format.PixelFormat, format.PixelFormat,
format.PixelType, format.PixelType,
data); (void*)data);
} }
break; break;
} }
} }
private void ReadFrom(IntPtr data, int size) private unsafe void ReadFrom(IntPtr data, int size)
{ {
TextureTarget target = Target.Convert(); TextureTarget target = Target.Convert();
uint baseLevel = 0; uint baseLevel = 0;
@ -762,7 +762,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
width, width,
(InternalFormat)format.PixelFormat, (InternalFormat)format.PixelFormat,
(uint)mipSize, (uint)mipSize,
data); (void*)data);
} }
else else
{ {
@ -773,7 +773,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
width, width,
format.PixelFormat, format.PixelFormat,
format.PixelType, format.PixelType,
data); (void*)data);
} }
break; break;
@ -790,7 +790,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
height, height,
(InternalFormat)format.PixelFormat, (InternalFormat)format.PixelFormat,
(uint)mipSize, (uint)mipSize,
data); (void*)data);
} }
else else
{ {
@ -803,7 +803,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
height, height,
format.PixelFormat, format.PixelFormat,
format.PixelType, format.PixelType,
data); (void*)data);
} }
break; break;
@ -823,7 +823,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
depth, depth,
(InternalFormat)format.PixelFormat, (InternalFormat)format.PixelFormat,
(uint)mipSize, (uint)mipSize,
data); (void*)data);
} }
else else
{ {
@ -838,7 +838,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
depth, depth,
format.PixelFormat, format.PixelFormat,
format.PixelType, format.PixelType,
data); (void*)data);
} }
break; break;
@ -858,7 +858,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
height, height,
(InternalFormat)format.PixelFormat, (InternalFormat)format.PixelFormat,
(uint)mipSize / 6, (uint)mipSize / 6,
data + faceOffset); (void*)(data + faceOffset));
} }
else else
{ {
@ -871,7 +871,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
height, height,
format.PixelFormat, format.PixelFormat,
format.PixelType, format.PixelType,
data + faceOffset); (void*)(data + faceOffset));
} }
} }
break; break;