From 0eb787c7abb55adcd6952ca1d9d6e1cb2c84cfc4 Mon Sep 17 00:00:00 2001 From: Dreitone Date: Sun, 22 Feb 2026 19:23:29 -0600 Subject: [PATCH] run on main thread primitive effect loading/disposal --- .../3DRendering/SanePrimitiveRenderer.cs | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Graphics/Primitives/3DRendering/SanePrimitiveRenderer.cs b/Graphics/Primitives/3DRendering/SanePrimitiveRenderer.cs index 3284326808..b91430f31e 100644 --- a/Graphics/Primitives/3DRendering/SanePrimitiveRenderer.cs +++ b/Graphics/Primitives/3DRendering/SanePrimitiveRenderer.cs @@ -180,23 +180,28 @@ public static class SanePrimitiveRenderer public static void Initialize() { - if (_graphicsDevice == null) - throw new ArgumentNullException(nameof(_graphicsDevice)); - - _effect?.Dispose(); - _effect = new BasicEffect(_graphicsDevice) + Main.RunOnMainThread(() => { - VertexColorEnabled = true, - TextureEnabled = true, - LightingEnabled = false, - FogEnabled = false, - Texture = TextureAssets.Logo.Value - }; + if (_graphicsDevice == null) + throw new ArgumentNullException(nameof(_graphicsDevice)); + + _effect?.Dispose(); + _effect = new BasicEffect(_graphicsDevice) + { + VertexColorEnabled = true, + TextureEnabled = true, + LightingEnabled = false, + FogEnabled = false, + Texture = TextureAssets.Logo.Value + }; + }); } public static void Dispose() { - _effect?.Dispose(); + Main.RunOnMainThread(() => + _effect?.Dispose() + ); } ///