mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
fix(venus): destroying a null handle no longer grows the Mali layer's maps (#3101)
The handle maps use key 0 for an empty slot. vkDestroyBuffer, vkFreeMemory and the other destroy calls accept VK_NULL_HANDLE, and map_remove(0) matched the first empty slot it reached, so every such call lowered count without removing anything. Once count wrapped below zero, every map_put saw a full table and doubled it, and each rehash took twice as long as the one before. Steam's web helper frees null buffers about 50,000 times in a few minutes. On a Mali-G610 its UI stalled periodically for 0.2 s, 0.37 s, 0.75 s, 1.5 s and then 3 s, and the buffer map reported a count of 4294967295. map_get, map_put and map_remove now ignore key 0. On a Nothing Phone (2a) running 0.7.1 with this change, the buffer map stayed at 256 slots after 115,000 frees and the stalls were gone.
This commit is contained in:
1 parent
1f82db66ac
commit
6e252ea3ad
2 files changed
+26
-2
No files matched your search
@@ -182,6 +182,25 @@ static void test_spirv(const char *directory)
|
||||
assert(!spirv_strip_dual_source(truncated, 5, &out));
|
||||
}
|
||||
|
||||
static void test_handle_map_null_key(void)
|
||||
{
|
||||
struct handle_map map = {0};
|
||||
int first, second;
|
||||
map_put(&map, 0x1000, &first);
|
||||
map_put(&map, 0x2000, &second);
|
||||
for (int i = 0; i < 1000; i++)
|
||||
assert(!map_remove(&map, 0));
|
||||
map_put(&map, 0, &first);
|
||||
assert(map.count == 2 && !map_get(&map, 0));
|
||||
for (uint64_t key = 1; key <= 30; key++) {
|
||||
map_put(&map, 0x100000 + key, &first);
|
||||
assert(map_remove(&map, 0x100000 + key) == &first);
|
||||
}
|
||||
assert(map.count == 2 && map.capacity == 64);
|
||||
assert(map_get(&map, 0x1000) == &first && map_get(&map, 0x2000) == &second);
|
||||
map_free(&map);
|
||||
}
|
||||
|
||||
static VkResult VKAPI_CALL mock_create_instance(const VkInstanceCreateInfo *info, const VkAllocationCallbacks *allocator,
|
||||
VkInstance *instance)
|
||||
{
|
||||
@@ -464,6 +483,7 @@ static void test_capable_device(void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_spirv(argc > 1 ? argv[1] : NULL);
|
||||
test_handle_map_null_key();
|
||||
|
||||
setenv("WINEPREFIX", "/nonexistent", 1);
|
||||
unsetenv("DROIDDECK_MALI_COMPAT");
|
||||
|
||||
Reference in new issue
Block a user