Commit 12990d73 by Mohan Maiya Committed by Commit Bot

GetBitSet now uses BitSetArray instead of IterableBitSet

Remove the now unused IterableBitSet class. Bug: angleproject:3877 Change-Id: I161e5d062c8183e30a7eb9040f3018116fe6e69e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2683494 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent dfd2a881
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <stdint.h> #include <stdint.h>
#include <bitset> #include <array>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/debug.h" #include "common/debug.h"
...@@ -153,106 +153,6 @@ class BitSetT final ...@@ -153,106 +153,6 @@ class BitSetT final
BitsT mBits; BitsT mBits;
}; };
template <size_t N>
class IterableBitSet : public std::bitset<N>
{
public:
constexpr IterableBitSet() {}
constexpr IterableBitSet(const std::bitset<N> &implicitBitSet) : std::bitset<N>(implicitBitSet)
{}
class Iterator final
{
public:
Iterator(const std::bitset<N> &bits);
Iterator &operator++();
bool operator==(const Iterator &other) const;
bool operator!=(const Iterator &other) const;
unsigned long operator*() const { return mCurrentBit; }
// These helper functions allow mutating an iterator in-flight.
// They only operate on later bits to ensure we don't iterate the same bit twice.
void resetLaterBit(std::size_t index)
{
ASSERT(index > mCurrentBit);
mBits.reset(index - mOffset);
}
void setLaterBit(std::size_t index)
{
ASSERT(index > mCurrentBit);
mBits.set(index - mOffset);
}
private:
unsigned long getNextBit();
static constexpr size_t BitsPerWord = sizeof(uint32_t) * 8;
std::bitset<N> mBits;
unsigned long mCurrentBit;
unsigned long mOffset;
};
Iterator begin() const { return Iterator(*this); }
Iterator end() const { return Iterator(std::bitset<N>(0)); }
};
template <size_t N>
IterableBitSet<N>::Iterator::Iterator(const std::bitset<N> &bitset)
: mBits(bitset), mCurrentBit(0), mOffset(0)
{
if (mBits.any())
{
mCurrentBit = getNextBit();
}
else
{
mOffset = static_cast<unsigned long>(rx::roundUpPow2(N, BitsPerWord));
}
}
template <size_t N>
ANGLE_INLINE typename IterableBitSet<N>::Iterator &IterableBitSet<N>::Iterator::operator++()
{
ASSERT(mBits.any());
mBits.set(mCurrentBit - mOffset, 0);
mCurrentBit = getNextBit();
return *this;
}
template <size_t N>
bool IterableBitSet<N>::Iterator::operator==(const Iterator &other) const
{
return mOffset == other.mOffset && mBits == other.mBits;
}
template <size_t N>
bool IterableBitSet<N>::Iterator::operator!=(const Iterator &other) const
{
return !(*this == other);
}
template <size_t N>
unsigned long IterableBitSet<N>::Iterator::getNextBit()
{
// TODO(jmadill): Use 64-bit scan when possible.
static constexpr std::bitset<N> wordMask(std::numeric_limits<uint32_t>::max());
while (mOffset < N)
{
uint32_t wordBits = static_cast<uint32_t>((mBits & wordMask).to_ulong());
if (wordBits != 0)
{
return gl::ScanForward(wordBits) + mOffset;
}
mBits >>= BitsPerWord;
mOffset += BitsPerWord;
}
return 0;
}
template <size_t N, typename BitsT, typename ParamT> template <size_t N, typename BitsT, typename ParamT>
constexpr BitSetT<N, BitsT, ParamT>::BitSetT() : mBits(0) constexpr BitSetT<N, BitsT, ParamT>::BitSetT() : mBits(0)
{ {
...@@ -538,6 +438,9 @@ using BitSet32 = BitSetT<N, uint32_t>; ...@@ -538,6 +438,9 @@ using BitSet32 = BitSetT<N, uint32_t>;
template <size_t N> template <size_t N>
using BitSet64 = BitSetT<N, uint64_t>; using BitSet64 = BitSetT<N, uint64_t>;
template <std::size_t N>
class BitSetArray;
namespace priv namespace priv
{ {
...@@ -547,7 +450,7 @@ using EnableIfBitsFit = typename std::enable_if<N <= sizeof(T) * 8>::type; ...@@ -547,7 +450,7 @@ using EnableIfBitsFit = typename std::enable_if<N <= sizeof(T) * 8>::type;
template <size_t N, typename Enable = void> template <size_t N, typename Enable = void>
struct GetBitSet struct GetBitSet
{ {
using Type = IterableBitSet<N>; using Type = BitSetArray<N>;
}; };
// Prefer 64-bit bitsets on 64-bit CPUs. They seem faster than 32-bit. // Prefer 64-bit bitsets on 64-bit CPUs. They seem faster than 32-bit.
......
...@@ -299,7 +299,8 @@ TYPED_TEST(BitSetIteratorTest, BitAssignment) ...@@ -299,7 +299,8 @@ TYPED_TEST(BitSetIteratorTest, BitAssignment)
TYPED_TEST(BitSetIteratorTest, SetLaterBit) TYPED_TEST(BitSetIteratorTest, SetLaterBit)
{ {
TypeParam mStateBits = this->mStateBits; TypeParam mStateBits = this->mStateBits;
std::set<size_t> expectedValues = {1, 3, 5, 7, 9}; std::set<size_t> expectedValues = {0, 1, 3, 5, 7, 9, 35};
mStateBits.set(0);
mStateBits.set(1); mStateBits.set(1);
std::set<size_t> actualValues; std::set<size_t> actualValues;
...@@ -312,6 +313,7 @@ TYPED_TEST(BitSetIteratorTest, SetLaterBit) ...@@ -312,6 +313,7 @@ TYPED_TEST(BitSetIteratorTest, SetLaterBit)
iter.setLaterBit(5); iter.setLaterBit(5);
iter.setLaterBit(7); iter.setLaterBit(7);
iter.setLaterBit(9); iter.setLaterBit(9);
iter.setLaterBit(35);
} }
actualValues.insert(*iter); actualValues.insert(*iter);
......
...@@ -829,7 +829,7 @@ using DrawBuffersVector = angle::FixedVector<T, IMPLEMENTATION_MAX_DRAW_BUFFERS> ...@@ -829,7 +829,7 @@ using DrawBuffersVector = angle::FixedVector<T, IMPLEMENTATION_MAX_DRAW_BUFFERS>
template <typename T> template <typename T>
using AttribArray = std::array<T, MAX_VERTEX_ATTRIBS>; using AttribArray = std::array<T, MAX_VERTEX_ATTRIBS>;
using ActiveTextureMask = angle::BitSetArray<IMPLEMENTATION_MAX_ACTIVE_TEXTURES>; using ActiveTextureMask = angle::BitSet<IMPLEMENTATION_MAX_ACTIVE_TEXTURES>;
template <typename T> template <typename T>
using ActiveTextureArray = std::array<T, IMPLEMENTATION_MAX_ACTIVE_TEXTURES>; using ActiveTextureArray = std::array<T, IMPLEMENTATION_MAX_ACTIVE_TEXTURES>;
...@@ -846,7 +846,7 @@ using AtomicCounterBufferMask = angle::BitSet<IMPLEMENTATION_MAX_ATOMIC_COUNTE ...@@ -846,7 +846,7 @@ using AtomicCounterBufferMask = angle::BitSet<IMPLEMENTATION_MAX_ATOMIC_COUNTE
template <typename T> template <typename T>
using ImagesArray = std::array<T, IMPLEMENTATION_MAX_IMAGE_UNITS>; using ImagesArray = std::array<T, IMPLEMENTATION_MAX_IMAGE_UNITS>;
using ImageUnitMask = angle::BitSetArray<IMPLEMENTATION_MAX_IMAGE_UNITS>; using ImageUnitMask = angle::BitSet<IMPLEMENTATION_MAX_IMAGE_UNITS>;
using SupportedSampleSet = std::set<GLuint>; using SupportedSampleSet = std::set<GLuint>;
......
...@@ -48,10 +48,8 @@ void BitSetIteratorPerfTest<T>::step() ...@@ -48,10 +48,8 @@ void BitSetIteratorPerfTest<T>::step()
} }
// These type names unfortunately don't get printed correctly in Gtest. // These type names unfortunately don't get printed correctly in Gtest.
using TestTypes = Types<angle::IterableBitSet<32>, using TestTypes = Types<angle::BitSet32<32>,
angle::BitSet32<32>,
angle::BitSet64<32>, angle::BitSet64<32>,
angle::IterableBitSet<64>,
angle::BitSet64<64>, angle::BitSet64<64>,
angle::BitSet<96>, angle::BitSet<96>,
angle::BitSetArray<96>>; angle::BitSetArray<96>>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment