diff options
author | Yahan Zhou <yahan@google.com> | 2024-03-06 20:53:25 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-03-06 20:53:25 +0000 |
commit | 3b32088273b2c947185680d7888a097bcdf18149 (patch) | |
tree | 4534bb42fab7a013e76d0fcfe25ff13d27682cde | |
parent | 9d8fb629f8c6565d19d5c238e7724a2e310aee6f (diff) | |
parent | aa954c7dcfbd3f8d32d66f0bad93de38852a850b (diff) | |
download | gfxstream-emu-34-2-dev.tar.gz |
Merge "Use update instead of addFixed when applicable" into mainemu-34-2-dev
-rw-r--r-- | host/vulkan/VkDecoderGlobalState.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/host/vulkan/VkDecoderGlobalState.cpp b/host/vulkan/VkDecoderGlobalState.cpp index 2536720e..4c26a281 100644 --- a/host/vulkan/VkDecoderGlobalState.cpp +++ b/host/vulkan/VkDecoderGlobalState.cpp @@ -245,6 +245,17 @@ class BoxedHandleManager { return res; } + void update(uint64_t handle, const T& item, BoxedHandleTypeTag tag) { + auto storedItem = store.get(handle); + uint64_t oldHandle = (uint64_t)storedItem->underlying; + *storedItem = item; + AutoLock l(lock); + if (oldHandle) { + reverseMap.erase(oldHandle); + } + reverseMap[(uint64_t)(item.underlying)] = handle; + } + void remove(uint64_t h) { auto item = get(h); if (item) { @@ -2286,7 +2297,6 @@ class VkDecoderGlobalState::Impl { { std::lock_guard<std::recursive_mutex> lock(mLock); auto boxed_fence = unboxed_to_boxed_non_dispatchable_VkFence(fence); - delete_VkFence(boxed_fence); set_boxed_non_dispatchable_VkFence(boxed_fence, replacement); auto& fenceInfo = mFenceInfo[replacement]; @@ -6000,7 +6010,7 @@ class VkDecoderGlobalState::Impl { void set_boxed_non_dispatchable_##type(type boxed, type underlying) { \ DispatchableHandleInfo<uint64_t> item; \ item.underlying = (uint64_t)underlying; \ - sBoxedHandleManager.addFixed((uint64_t)boxed, item, Tag_##type); \ + sBoxedHandleManager.update((uint64_t)boxed, item, Tag_##type); \ } \ type unboxed_to_boxed_non_dispatchable_##type(type unboxed) { \ AutoLock lock(sBoxedHandleManager.lock); \ |