Skip to content

Commit

Permalink
Merge pull request #5689 from frenzibyte/fix-veldrid-gl-make-current
Browse files Browse the repository at this point in the history
Fix draw thread unnecessarily marking GL context as current
  • Loading branch information
smoogipoo committed Mar 21, 2023
2 parents 6d7938d + 03d8a7b commit 1ff6694
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 3 additions & 0 deletions osu.Framework/Graphics/OpenGL/GLRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ protected internal override void BeginFrame(Vector2 windowSize)
lastBoundBuffers.AsSpan().Clear();
lastBoundVertexArray = 0;

// Seems to be required on some drivers as the context is lost from the draw thread.
MakeCurrent();

GL.UseProgram(0);

base.BeginFrame(windowSize);
Expand Down
7 changes: 1 addition & 6 deletions osu.Framework/Threading/DrawThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ protected sealed override void OnInitialize()

if (window != null)
{
host.Renderer.MakeCurrent();

host.Renderer.BeginFrame(new Vector2(window.ClientSize.Width, window.ClientSize.Height));
host.Renderer.FinishFrame();
}
Expand All @@ -40,16 +38,13 @@ internal sealed override void MakeCurrent()
base.MakeCurrent();

ThreadSafety.IsDrawThread = true;

if (host.Renderer.IsInitialised)
// Seems to be required on some drivers as the context is lost from the draw thread.
host.Renderer.MakeCurrent();
}

protected sealed override void OnSuspended()
{
base.OnSuspended();

// if we've acquired the GL context before in this thread, make sure to release it before suspension.
if (host.Renderer.IsInitialised)
host.Renderer.ClearCurrent();
}
Expand Down

0 comments on commit 1ff6694

Please sign in to comment.