diff --git a/src/Lab/Experiments/BlankWindow/BlankWindow.csproj b/src/Lab/Experiments/BlankWindow/BlankWindow.csproj
index e88c23b6b0..7fe54daa69 100644
--- a/src/Lab/Experiments/BlankWindow/BlankWindow.csproj
+++ b/src/Lab/Experiments/BlankWindow/BlankWindow.csproj
@@ -2,7 +2,7 @@
Exe
- netcoreapp3.1
+ net7.0
true
diff --git a/src/Windowing/Silk.NET.Windowing.Common/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt b/src/Windowing/Silk.NET.Windowing.Common/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt
index 1375c83df3..4f6a83f143 100644
--- a/src/Windowing/Silk.NET.Windowing.Common/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt
+++ b/src/Windowing/Silk.NET.Windowing.Common/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt
@@ -7,3 +7,4 @@ Silk.NET.Windowing.VideoMode.AspectRatioEstimate.get -> Silk.NET.Maths.Vector2D<
Silk.NET.Windowing.WindowOptions.TopMost.get -> bool
Silk.NET.Windowing.WindowOptions.TopMost.set -> void
Silk.NET.Windowing.WindowOptions.WindowOptions(bool isVisible, Silk.NET.Maths.Vector2D position, Silk.NET.Maths.Vector2D size, double framesPerSecond, double updatesPerSecond, Silk.NET.Windowing.GraphicsAPI api, string! title, Silk.NET.Windowing.WindowState windowState, Silk.NET.Windowing.WindowBorder windowBorder, bool isVSync, bool shouldSwapAutomatically, Silk.NET.Windowing.VideoMode videoMode, int? preferredDepthBufferBits = null, int? preferredStencilBufferBits = null, Silk.NET.Maths.Vector4D? preferredBitDepth = null, bool transparentFramebuffer = false, bool topMost = false, bool isEventDriven = false, Silk.NET.Core.Contexts.IGLContext? sharedContext = null, int? samples = null, string? windowClass = null, bool isContextControlDisabled = false) -> void
+static Silk.NET.Windowing.Window.PrioritizeOrAdd(System.Func! factory, bool isFirstParty = false) -> T
diff --git a/src/Windowing/Silk.NET.Windowing.Glfw/GlfwWindow.cs b/src/Windowing/Silk.NET.Windowing.Glfw/GlfwWindow.cs
index 6b74f7b770..2e364abcfa 100644
--- a/src/Windowing/Silk.NET.Windowing.Glfw/GlfwWindow.cs
+++ b/src/Windowing/Silk.NET.Windowing.Glfw/GlfwWindow.cs
@@ -424,6 +424,7 @@ public override void SetWindowIcon(ReadOnlySpan icons)
throw new InvalidOperationException("Window should be initialized.");
}
+ var budget = 1024;
if (icons == null)
{
_glfw.SetWindowIcon(_glfwWindow, 0, null);
@@ -431,11 +432,37 @@ public override void SetWindowIcon(ReadOnlySpan icons)
else
{
var images = stackalloc Image[icons.Length];
+ nint harr = 0;
+ var harrLen = 0;
+ var harrOff = 0;
for (var i = 0; i < icons.Length; i++)
{
var icon = icons[i];
// ReSharper disable once StackAllocInsideLoop
- Span iconMemory = stackalloc byte[icon.Pixels.Length];
+ var iconMemory = budget >= icon.Pixels.Length
+ ? stackalloc byte[icon.Pixels.Length]
+ : harr == 0
+ ? null
+ : new Span((void*)(harr + harrOff), icon.Pixels.Length);
+ if (iconMemory == null)
+ {
+ for (var j = i; j < icons.Length; j++)
+ {
+ harrLen += icons[j].Pixels.Length;
+ }
+
+ harr = SilkMarshal.Allocate(harrLen);
+ iconMemory = new Span((void*) harr, icon.Pixels.Length);
+ harrOff = icon.Pixels.Length;
+ }
+ else if (budget >= icon.Pixels.Length)
+ {
+ budget -= icon.Pixels.Length;
+ }
+ else
+ {
+ harrOff += icon.Pixels.Length;
+ }
images[i] = new()
{
Width = icon.Width, Height = icon.Height,
@@ -446,6 +473,10 @@ public override void SetWindowIcon(ReadOnlySpan icons)
}
_glfw.SetWindowIcon(_glfwWindow, icons.Length, images);
+ if (harr != 0)
+ {
+ SilkMarshal.Free(harr);
+ }
GLFW.Glfw.ThrowExceptions();
}
}