From c4e92114303938fc573c046bbbc6b2cafeace91e Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Fri, 18 Oct 2024 12:58:23 +0200 Subject: [PATCH 1/3] Include , which is used for the bit array. --- MoltenVK/MoltenVK/Utility/MVKBitArray.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MoltenVK/MoltenVK/Utility/MVKBitArray.h b/MoltenVK/MoltenVK/Utility/MVKBitArray.h index 48c967a00..9fdf49e22 100755 --- a/MoltenVK/MoltenVK/Utility/MVKBitArray.h +++ b/MoltenVK/MoltenVK/Utility/MVKBitArray.h @@ -19,6 +19,7 @@ #pragma once #include "MVKFoundation.h" +#include #pragma mark - From 05d9d1a76cb07cdefc4803bbfe9297195c779a74 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Fri, 18 Oct 2024 12:31:06 +0200 Subject: [PATCH 2/3] Do not access invalid MVKBitArray sections when all the bits are disabled. --- MoltenVK/MoltenVK/Utility/MVKBitArray.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MoltenVK/MoltenVK/Utility/MVKBitArray.h b/MoltenVK/MoltenVK/Utility/MVKBitArray.h index 9fdf49e22..fffbb5bc1 100755 --- a/MoltenVK/MoltenVK/Utility/MVKBitArray.h +++ b/MoltenVK/MoltenVK/Utility/MVKBitArray.h @@ -105,6 +105,10 @@ class MVKBitArray { secIdx = _fullyDisabledSectionCount; startIndex = 0; } + /* If all bits are disabled and the number of bits is precisely a multiple of SectionBitCount, + * then we'd be trying to access a section that doesn't exist, so we must bail out immediately. */ + if (secIdx >= getSectionCount()) + return _bitCount; return std::min((secIdx * SectionBitCount) + getIndexOfFirstEnabledBitInSection(getSection(secIdx), getBitIndexInSection(startIndex)), _bitCount); } From 26689acbd03eceb21cca41a5818b0856412c1bfa Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Fri, 18 Oct 2024 11:42:05 -0400 Subject: [PATCH 3/3] Apply suggestions from code review Clean up PR for style consistency. --- MoltenVK/MoltenVK/Utility/MVKBitArray.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/MoltenVK/MoltenVK/Utility/MVKBitArray.h b/MoltenVK/MoltenVK/Utility/MVKBitArray.h index fffbb5bc1..117fd091d 100755 --- a/MoltenVK/MoltenVK/Utility/MVKBitArray.h +++ b/MoltenVK/MoltenVK/Utility/MVKBitArray.h @@ -19,7 +19,6 @@ #pragma once #include "MVKFoundation.h" -#include #pragma mark - @@ -105,10 +104,7 @@ class MVKBitArray { secIdx = _fullyDisabledSectionCount; startIndex = 0; } - /* If all bits are disabled and the number of bits is precisely a multiple of SectionBitCount, - * then we'd be trying to access a section that doesn't exist, so we must bail out immediately. */ - if (secIdx >= getSectionCount()) - return _bitCount; + if (secIdx >= getSectionCount()) { return _bitCount; } return std::min((secIdx * SectionBitCount) + getIndexOfFirstEnabledBitInSection(getSection(secIdx), getBitIndexInSection(startIndex)), _bitCount); }