From ad061413cd1b9a323c3f5ac92667bb533574784e Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sun, 4 Jun 2023 13:15:14 +0600 Subject: [PATCH] Make the current context current before updating the texture snapshot --- .../Server/ServerCompositionDrawingSurface.cs | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionDrawingSurface.cs b/src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionDrawingSurface.cs index 9c6c78c1ad..da24b3812a 100644 --- a/src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionDrawingSurface.cs +++ b/src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionDrawingSurface.cs @@ -49,22 +49,31 @@ internal class ServerCompositionDrawingSurface : ServerCompositionSurface, IDisp public void UpdateWithAutomaticSync(CompositionImportedGpuImage image) { - PerformSanityChecks(image); - Update(image.Image.SnapshotWithAutomaticSync(), image.Context); + using (Compositor.RenderInterface.EnsureCurrent()) + { + PerformSanityChecks(image); + Update(image.Image.SnapshotWithAutomaticSync(), image.Context); + } } public void UpdateWithKeyedMutex(CompositionImportedGpuImage image, uint acquireIndex, uint releaseIndex) { - PerformSanityChecks(image); - Update(image.Image.SnapshotWithKeyedMutex(acquireIndex, releaseIndex), image.Context); + using (Compositor.RenderInterface.EnsureCurrent()) + { + PerformSanityChecks(image); + Update(image.Image.SnapshotWithKeyedMutex(acquireIndex, releaseIndex), image.Context); + } } public void UpdateWithSemaphores(CompositionImportedGpuImage image, CompositionImportedGpuSemaphore wait, CompositionImportedGpuSemaphore signal) { - PerformSanityChecks(image); - if (!wait.IsUsable || !signal.IsUsable) - throw new PlatformGraphicsContextLostException(); - Update(image.Image.SnapshotWithSemaphores(wait.Semaphore, signal.Semaphore), image.Context); + using (Compositor.RenderInterface.EnsureCurrent()) + { + PerformSanityChecks(image); + if (!wait.IsUsable || !signal.IsUsable) + throw new PlatformGraphicsContextLostException(); + Update(image.Image.SnapshotWithSemaphores(wait.Semaphore, signal.Semaphore), image.Context); + } } public void Dispose()