Skip to content

Commit 0471c5d

Browse files
authored
vk: use firstBitSet API (#9128)
This is more efficient than the prevoius way
1 parent 65cca71 commit 0471c5d

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

filament/backend/src/vulkan/VulkanQueryManager.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,13 @@ fvkmemory::resource_ptr<VulkanTimerQuery> VulkanQueryManager::getNextQuery(
4646
return {};
4747
}
4848

49-
bool found = false;
5049
std::pair<uint32_t, uint32_t> queryIndices;
51-
unused.forEachSetBit([&](size_t index) {
52-
if (found) {
53-
return;
54-
}
50+
size_t const firstUnused = unused.firstSetBit();
51+
{
5552
std::unique_lock<utils::Mutex> lock(mMutex);
56-
mUsed.set(index);
57-
found = true;
58-
queryIndices = std::make_pair(index * 2, index * 2 + 1);
59-
});
53+
mUsed.set(firstUnused);
54+
queryIndices = { firstUnused * 2, firstUnused * 2 + 1 };
55+
}
6056
return fvkmemory::resource_ptr<VulkanTimerQuery>::construct(resourceManager, queryIndices.first,
6157
queryIndices.second);
6258
}

0 commit comments

Comments
 (0)