Skip to content

Commit

Permalink
[Vulkan] Fix race condition with image sampler arrays
Browse files Browse the repository at this point in the history
See: 6a5c280
  • Loading branch information
hyazinthh committed Jan 23, 2025
1 parent e854719 commit 3c9495d
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/Aardvark.Rendering.Vulkan/Management/ResourceManager.fs
Original file line number Diff line number Diff line change
Expand Up @@ -797,27 +797,28 @@ module Resources =
let mutable changed = deltas.Count > 0

for image in pending.GetAndClear() do
let info = image.Update(user, token, renderToken)

for i in indices.[image] do
if indices.Contains image then
let info = image.Update(user, token, renderToken)

for i in indices.[image] do

// If handle is zero handle, a new resource has been bound to the slot.
// In this case versionOffsets stores the previous version on that slot.
// Compute a new offset for the new handle, so the effective version is incremented by 1.
if Object.ReferenceEquals(handle.[i], zeroHandle) then
let offset = (versionOffsets.[i] - info.version) + 1
handle.[i] <- { info with version = info.version + offset }
versionOffsets.[i] <- offset
changed <- true

// If handle is zero handle, a new resource has been bound to the slot.
// In this case versionOffsets stores the previous version on that slot.
// Compute a new offset for the new handle, so the effective version is incremented by 1.
if Object.ReferenceEquals(handle.[i], zeroHandle) then
let offset = (versionOffsets.[i] - info.version) + 1
handle.[i] <- { info with version = info.version + offset }
versionOffsets.[i] <- offset
changed <- true
// Otherwise, the bound resource has not changed.
// Check if its version has changed.
else
let version = info.version + versionOffsets.[i]

// Otherwise, the bound resource has not changed.
// Check if its version has changed.
else
let version = info.version + versionOffsets.[i]

if version <> handle.[i].version then
handle.[i] <- { info with version = version }
changed <- true
if version <> handle.[i].version then
handle.[i] <- { info with version = version }
changed <- true

if changed then
inc &version
Expand Down

0 comments on commit 3c9495d

Please sign in to comment.