mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-05 04:33:51 +00:00
fix: data race on collision query profiling counters
queryTimeMs and queryCallCount on WMORenderer and M2Renderer were plain mutable doubles/uint32s written by getFloorHeight (dispatched on async threads from CameraController) and read by the main thread. This is undefined behavior per C++ — thread sanitizer would flag it. Changed to std::atomic with relaxed ordering (adequate for diagnostics) and updated QueryTimer to use atomic fetch_add/compare_exchange.
This commit is contained in:
parent
3dd1128ecf
commit
bbb560f93c
3 changed files with 23 additions and 12 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <vulkan/vulkan.h>
|
||||
#include <vk_mem_alloc.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
|
@ -740,9 +741,10 @@ private:
|
|||
std::vector<uint32_t> portalVisibleGroups_; // reused per frame (portal culling scratch)
|
||||
std::unordered_set<uint32_t> portalVisibleGroupSet_; // reused per frame (portal culling scratch)
|
||||
|
||||
// Collision query profiling (per frame).
|
||||
mutable double queryTimeMs = 0.0;
|
||||
mutable uint32_t queryCallCount = 0;
|
||||
// Collision query profiling — atomic because getFloorHeight is dispatched
|
||||
// on async threads from camera_controller while the main thread reads these.
|
||||
mutable std::atomic<double> queryTimeMs{0.0};
|
||||
mutable std::atomic<uint32_t> queryCallCount{0};
|
||||
|
||||
// Floor height cache - persistent precomputed grid
|
||||
static constexpr float FLOOR_GRID_CELL_SIZE = 2.0f; // 2 unit grid cells
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue