Skip to content

Commit

Permalink
Merge branch 'master' into v55
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Jul 11, 2024
2 parents a8fb504 + c70611c commit 37ef313
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
- [Vulkan] Removed unused `Pipeline` type
- [Vulkan] Removed `TextureFormat.ofGLSLType`

### 5.4.12
- [GL] Fixed potential memory leak after ContextHandle is disposed
- Optimized generic dispatch
- Fixed potential leaks with ConcurrentDictionary.GetOrAdd

### 5.4.11
- [Application.WPF.GL] SharingRenderControl implementation now uses Silk.NET.Direct3D9 instead of SharpDX
- Removed SharpDX dependency
Expand Down
10 changes: 10 additions & 0 deletions src/Aardvark.Rendering.GL/Core/ContextHandles.fs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type ContextHandle(handle : IGraphicsContext, window : IWindowInfo) =
(handle |> unbox<IGraphicsContextInternal>).GetAddress(name)

member x.OnMakeCurrent(f : unit -> unit) =
if isDisposed then failwith "Failed to register OnMakeCurrent callback, the context is already disposed!"
Interlocked.CompareExchange(&onMakeCurrent, ConcurrentHashSet(), null) |> ignore
onMakeCurrent.Add f |> ignore

Expand Down Expand Up @@ -214,6 +215,15 @@ type ContextHandle(handle : IGraphicsContext, window : IWindowInfo) =

if lockTaken then
if not isDisposed then

// release potentially pending UnsharedObjects
let actions = Interlocked.Exchange(&onMakeCurrent, null)
if actions <> null then
x.Use(fun () ->
for a in actions do
a()
)

isDisposed <- true
debugOutput |> Option.iter (fun dbg -> dbg.Dispose())
onDisposed.Trigger()
Expand Down

0 comments on commit 37ef313

Please sign in to comment.