Skip to content

Commit

Permalink
Merge pull request #2065 from js6i/bit-array-fix
Browse files Browse the repository at this point in the history
Fix MVKBitArray::getIndexOfFirstSetBit() skipping over entries.
  • Loading branch information
billhollings authored Nov 15, 2023
2 parents ab84de5 + 36e57f4 commit abeed4e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion MoltenVK/MoltenVK/Utility/MVKBitArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ class MVKBitArray {
* and optionally clears that bit. If no bits are set, returns the size() of this bit array.
*/
size_t getIndexOfFirstSetBit(size_t startIndex, bool shouldClear) {
size_t startSecIdx = std::max(getIndexOfSection(startIndex), _clearedSectionCount);
size_t startSecIdx = getIndexOfSection(startIndex);
if (startSecIdx < _clearedSectionCount) {
startSecIdx = _clearedSectionCount;
startIndex = 0;
}
size_t bitIdx = startSecIdx << SectionMaskSize;
size_t secCnt = getSectionCount();
for (size_t secIdx = startSecIdx; secIdx < secCnt; secIdx++) {
Expand All @@ -101,6 +105,7 @@ class MVKBitArray {
if (shouldClear) { clearBit(bitIdx); }
return std::min(bitIdx, _bitCount);
}
startIndex = 0;
}
return std::min(bitIdx, _bitCount);
}
Expand Down

0 comments on commit abeed4e

Please sign in to comment.