|
Blender V5.0
|
Namespaces | |
| namespace | detail |
| namespace | tests |
Classes | |
| class | BitGroupVector |
| class | BitRef |
| class | MutableBitRef |
| class | BitIteratorBase |
| class | BitIterator |
| class | MutableBitIterator |
| class | BitSpan |
| class | BoundedBitSpan |
| class | MutableBitSpan |
| class | MutableBoundedBitSpan |
| class | BitVector |
| struct | BoolToBit |
Typedefs | |
| using | BitInt = uint64_t |
Functions | |
| bool | or_bools_into_bits (Span< bool > bools, MutableBitSpan r_bits, int64_t allowed_overshoot=0) |
| BitInt | mask_first_n_bits (const int64_t n) |
| BitInt | mask_last_n_bits (const int64_t n) |
| BitInt | mask_range_bits (const int64_t start, const int64_t size) |
| BitInt | mask_single_bit (const int64_t bit_index) |
| BitInt * | int_containing_bit (BitInt *data, const int64_t bit_index) |
| const BitInt * | int_containing_bit (const BitInt *data, const int64_t bit_index) |
| std::ostream & | operator<< (std::ostream &stream, const BitRef &bit) |
| std::ostream & | operator<< (std::ostream &stream, const MutableBitRef &bit) |
| bool | is_bounded_span (const BitSpan span) |
| std::optional< BoundedBitSpan > | try_get_bounded_span (const BitSpan span) |
| template<typename T> | |
| T | to_best_bit_span (const T &data) |
| std::ostream & | operator<< (std::ostream &stream, const BitSpan &span) |
| std::ostream & | operator<< (std::ostream &stream, const MutableBitSpan &span) |
| template<typename ExprFn, typename FirstBitSpanT, typename... BitSpanT> | |
| void | mix_into_first_expr (ExprFn &&expr, FirstBitSpanT &&first_arg, const BitSpanT &...args) |
| template<typename ExprFn, typename FirstBitSpanT, typename... BitSpanT> | |
| bool | any_set_expr (ExprFn &&expr, const FirstBitSpanT &first_arg, const BitSpanT &...args) |
| template<typename ExprFn, typename HandleFn, typename FirstBitSpanT, typename... BitSpanT> | |
| void | foreach_1_index_expr (ExprFn &&expr, HandleFn &&handle, const FirstBitSpanT &first_arg, const BitSpanT &...args) |
| template<typename BitSpanT> | |
| void | invert (BitSpanT &&data) |
| template<typename FirstBitSpanT, typename... BitSpanT> | |
| void | inplace_or (FirstBitSpanT &first_arg, const BitSpanT &...args) |
| template<typename FirstBitSpanT, typename MaskBitSpanT, typename... BitSpanT> | |
| void | inplace_or_masked (FirstBitSpanT &&first_arg, const MaskBitSpanT &mask, const BitSpanT &...args) |
| template<typename FirstBitSpanT, typename... BitSpanT> | |
| void | copy_from_or (FirstBitSpanT &first_arg, const BitSpanT &...args) |
| template<typename FirstBitSpanT, typename... BitSpanT> | |
| void | inplace_and (FirstBitSpanT &first_arg, const BitSpanT &...args) |
| template<typename... BitSpanT> | |
| void | operator|= (MutableBitSpan first_arg, const BitSpanT &...args) |
| template<typename... BitSpanT> | |
| void | operator|= (MutableBoundedBitSpan first_arg, const BitSpanT &...args) |
| template<typename... BitSpanT> | |
| void | operator&= (MutableBitSpan first_arg, const BitSpanT &...args) |
| template<typename... BitSpanT> | |
| void | operator&= (MutableBoundedBitSpan first_arg, const BitSpanT &...args) |
| template<typename... BitSpanT> | |
| bool | has_common_set_bits (const BitSpanT &...args) |
| template<typename BitSpanT> | |
| bool | any_bit_set (const BitSpanT &arg) |
| template<typename... BitSpanT> | |
| bool | has_common_unset_bits (const BitSpanT &...args) |
| template<typename BitSpanT> | |
| bool | any_bit_unset (const BitSpanT &arg) |
| template<typename BitSpanT, typename Fn> | |
| void | foreach_1_index (const BitSpanT &data, Fn &&fn) |
| template<typename BitSpanT, typename Fn> | |
| void | foreach_0_index (const BitSpanT &data, Fn &&fn) |
| template<typename ExprFn, typename FirstBitSpanT, typename... BitSpanT> | |
| std::optional< int64_t > | find_first_1_index_expr (ExprFn &&Expr, const FirstBitSpanT &first_arg, const BitSpanT &...args) |
| template<typename BitSpanT> | |
| std::optional< int64_t > | find_first_1_index (const BitSpanT &data) |
| template<typename BitSpanT> | |
| std::optional< int64_t > | find_first_0_index (const BitSpanT &data) |
| template<typename BitSpanT1, typename BitSpanT2> | |
| bool | spans_equal (const BitSpanT1 &a, const BitSpanT2 &b) |
| template<typename BitSpanT1, typename BitSpanT2, typename BitSpanT3> | |
| bool | spans_equal_masked (const BitSpanT1 &a, const BitSpanT2 &b, const BitSpanT3 &mask) |
| template<typename IntT> | |
| void | bits_to_index_ranges (const BitSpan bits, IndexRangesBuilder< IntT > &builder) |
| template<int64_t InlineBufferCapacity, typename Allocator> | |
| BoundedBitSpan | to_best_bit_span (const BitVector< InlineBufferCapacity, Allocator > &data) |
| template<int64_t InlineBufferCapacity, typename Allocator> | |
| MutableBoundedBitSpan | to_best_bit_span (BitVector< InlineBufferCapacity, Allocator > &data) |
| template<typename ByteToBit> | |
| bool | or_bytes_into_bits (const Span< char > bytes, MutableBitSpan r_bits, const int64_t allowed_overshoot, const ByteToBit &byte_to_bit) |
Variables | |
| static constexpr int64_t | BitsPerInt = int64_t(sizeof(BitInt) * 8) |
| static constexpr int64_t | BitToIntIndexShift |
| static constexpr BitInt | BitIndexMask = (BitInt(1) << BitToIntIndexShift) - 1 |
| template<typename... Args> | |
| constexpr bool | all_bounded_spans |
| using blender::bits::BitInt = uint64_t |
Using a large integer type is better because then it's easier to process many bits at once.
Definition at line 27 of file BLI_bit_ref.hh.
|
inline |
Definition at line 304 of file BLI_bit_span_ops.hh.
References has_common_set_bits().
|
inline |
Definition at line 314 of file BLI_bit_span_ops.hh.
References has_common_unset_bits().
|
inline |
Definition at line 224 of file BLI_bit_span_ops.hh.
References blender::bits::detail::any_set_expr(), and to_best_bit_span().
Referenced by has_common_set_bits(), has_common_unset_bits(), spans_equal(), and spans_equal_masked().
|
inline |
Extracts index ranges from the given bits. For example 00111011 would result in two ranges: [2-4], [6-7].
It's especially optimized to handle cases where there are very many or very few set bits.
Definition at line 27 of file BLI_bit_span_to_index_ranges.hh.
References blender::IndexRangesBuilder< T >::add_range(), blender::AlignedIndexRanges::aligned, BitIndexMask, bitscan_forward_uint64(), BitsPerInt, BLI_assert, data, blender::IndexRange::from_begin_end(), blender::IndexRange::from_begin_size(), int_containing_bit(), blender::IndexRange::is_empty(), blender::IndexRange::last(), mask(), mask_first_n_bits(), mask_range_bits(), blender::AlignedIndexRanges::prefix, blender::IndexRange::shift(), blender::IndexRange::size(), blender::split_index_range_by_alignment(), blender::IndexRange::start(), blender::AlignedIndexRanges::suffix, and UNUSED_VARS_NDEBUG.
Referenced by blender::index_mask::from_bits_batch_predicate(), blender::bits::tests::TEST(), and blender::bits::tests::TEST().
|
inline |
Definition at line 263 of file BLI_bit_span_ops.hh.
References mix_into_first_expr().
Referenced by blender::bits::MutableBitSpan::copy_from(), blender::bits::MutableBitSpan::copy_from(), blender::bits::MutableBoundedBitSpan::copy_from(), blender::bits::MutableBoundedBitSpan::copy_from(), and blender::index_mask::evaluate_exact_with_bits().
|
inline |
Definition at line 343 of file BLI_bit_span_ops.hh.
References data, find_first_1_index_expr(), and x.
Referenced by blender::bits::tests::TEST().
|
inline |
Definition at line 338 of file BLI_bit_span_ops.hh.
References data, find_first_1_index_expr(), and x.
Referenced by blender::bits::tests::TEST().
|
inline |
Definition at line 330 of file BLI_bit_span_ops.hh.
References blender::bits::detail::find_first_1_index_expr(), and to_best_bit_span().
Referenced by find_first_0_index(), find_first_1_index(), and blender::bits::tests::TEST().
|
inline |
Definition at line 324 of file BLI_bit_span_ops.hh.
References data, foreach_1_index_expr(), and x.
Referenced by BKE_subdiv_ccg_foreach_visible_grid_vert(), blender::ed::sculpt_paint::cloth::calc_visible_vert_indices_grids(), blender::ed::sculpt_paint::mask::fill_mask_grids(), and blender::ed::sculpt_paint::mask::invert_mask_grids().
|
inline |
Definition at line 319 of file BLI_bit_span_ops.hh.
References data, foreach_1_index_expr(), and x.
Referenced by blender::index_mask::bits_to_indices(), blender::ed::sculpt_paint::mask::copy_old_hidden_mask_grids(), blender::bke::get_direct_zone_relations(), blender::bke::node_tree_reference_lifetimes::get_tree_relations(), blender::bke::node_tree_reference_lifetimes::bNodeTreeBitGroupVectorOptions::socket_name(), blender::bke::node_structure_type_inferencing::store_auto_output_structure_types(), blender::bits::tests::TEST(), blender::bits::tests::TEST(), and blender::bke::update_zone_per_node().
|
inline |
Definition at line 230 of file BLI_bit_span_ops.hh.
References blender::bits::detail::foreach_1_index_expr(), and to_best_bit_span().
Referenced by foreach_0_index(), and foreach_1_index().
|
inline |
Definition at line 299 of file BLI_bit_span_ops.hh.
References any_set_expr(), and x.
Referenced by any_bit_set(), and blender::bke::discover_tree_zones().
|
inline |
Definition at line 309 of file BLI_bit_span_ops.hh.
References any_set_expr(), and x.
Referenced by any_bit_unset().
|
inline |
Definition at line 270 of file BLI_bit_span_ops.hh.
References mix_into_first_expr(), and x.
Referenced by operator&=(), and operator&=().
|
inline |
Definition at line 245 of file BLI_bit_span_ops.hh.
References mix_into_first_expr(), and x.
Referenced by operator|=(), and operator|=().
|
inline |
Definition at line 251 of file BLI_bit_span_ops.hh.
References mask(), mix_into_first_expr(), and x.
Referenced by blender::bke::node_tree_reference_lifetimes::or_into_each_other_masked(), and blender::bke::node_tree_reference_lifetimes::pass_left_to_right().
Definition at line 70 of file BLI_bit_ref.hh.
References BitToIntIndexShift, and data.
Referenced by blender::bits::BitRef::BitRef(), bits_to_index_ranges(), blender::bits::MutableBitRef::MutableBitRef(), or_bytes_into_bits(), blender::bits::MutableBitSpan::reset_all(), blender::bits::MutableBitSpan::set_all(), and blender::bits::tests::TEST().
|
inline |
Definition at line 75 of file BLI_bit_ref.hh.
References BitToIntIndexShift, and data.
|
inline |
Definition at line 239 of file BLI_bit_span_ops.hh.
References data, mix_into_first_expr(), and x.
Referenced by blender::ed::sculpt_paint::expand::enabled_state_to_bitmap(), blender::index_mask::IndexMask::from_bools_inverse(), blender::ed::sculpt_paint::hide::invert_visibility_grids(), and blender::index_mask::tests::TEST().
|
inline |
Checks if the span fulfills the requirements for a bounded span. Bounded spans can often be processed more efficiently, because fewer cases have to be considered when aligning multiple such spans.
See comments in the function for the exact requirements.
Don't allow small sized spans to cross BitInt boundaries.
Definition at line 166 of file BLI_bit_span.hh.
References blender::bits::BitSpan::bit_range(), BitsPerInt, blender::bits::BitSpan::size(), size(), and blender::IndexRange::start().
Referenced by blender::bits::BoundedBitSpan::BoundedBitSpan(), blender::bits::BoundedBitSpan::BoundedBitSpan(), blender::bits::BoundedBitSpan::BoundedBitSpan(), blender::bits::MutableBoundedBitSpan::MutableBoundedBitSpan(), blender::bits::MutableBoundedBitSpan::MutableBoundedBitSpan(), blender::bits::MutableBoundedBitSpan::MutableBoundedBitSpan(), blender::bits::tests::TEST(), and try_get_bounded_span().
Definition at line 36 of file BLI_bit_ref.hh.
References BitsPerInt, and BLI_assert.
Referenced by blender::bits::detail::any_set_expr(), bits_to_index_ranges(), blender::bits::detail::foreach_1_index_expr(), mask_last_n_bits(), blender::bits::MutableBitSpan::reset_all(), blender::bits::MutableBitSpan::set_all(), and blender::bits::tests::TEST().
Definition at line 46 of file BLI_bit_ref.hh.
References BitsPerInt, and mask_first_n_bits().
Referenced by mask_range_bits(), and blender::bits::tests::TEST().
Definition at line 51 of file BLI_bit_ref.hh.
References BitsPerInt, BLI_assert, mask_last_n_bits(), and size().
Referenced by bits_to_index_ranges(), blender::bits::detail::mix_into_first_expr(), blender::bits::MutableBitSpan::reset_all(), blender::bits::MutableBitSpan::set_all(), and blender::bits::tests::TEST().
Definition at line 63 of file BLI_bit_ref.hh.
References BitsPerInt, and BLI_assert.
Referenced by blender::bits::BitRef::BitRef(), blender::bits::detail::foreach_1_index_expr(), blender::bits::MutableBitRef::MutableBitRef(), and blender::bits::tests::TEST().
|
inline |
Definition at line 218 of file BLI_bit_span_ops.hh.
References blender::bits::detail::mix_into_first_expr(), and to_best_bit_span().
Referenced by copy_from_or(), blender::index_mask::evaluate_exact_with_bits(), inplace_and(), inplace_or(), inplace_or_masked(), and invert().
|
inline |
Definition at line 288 of file BLI_bit_span_ops.hh.
References inplace_and().
|
inline |
Definition at line 294 of file BLI_bit_span_ops.hh.
References inplace_and().
| std::ostream & blender::bits::operator<< | ( | std::ostream & | stream, |
| const BitRef & | bit ) |
Definition at line 15 of file bit_ref.cc.
| std::ostream & blender::bits::operator<< | ( | std::ostream & | stream, |
| const BitSpan & | span ) |
Definition at line 90 of file bit_span.cc.
References blender::bits::BitSpan::size().
| std::ostream & blender::bits::operator<< | ( | std::ostream & | stream, |
| const MutableBitRef & | bit ) |
Definition at line 20 of file bit_ref.cc.
| std::ostream & blender::bits::operator<< | ( | std::ostream & | stream, |
| const MutableBitSpan & | span ) |
Definition at line 100 of file bit_span.cc.
|
inline |
Definition at line 276 of file BLI_bit_span_ops.hh.
References inplace_or().
|
inline |
Definition at line 282 of file BLI_bit_span_ops.hh.
References inplace_or().
| bool blender::bits::or_bools_into_bits | ( | Span< bool > | bools, |
| MutableBitSpan | r_bits, | ||
| int64_t | allowed_overshoot = 0 ) |
Converts the bools to bits and ors them into the given bits. For pure conversion, the bits should therefore be zero initialized before they are passed into this function.
| allowed_overshoot | How many bools/bits can be read/written after the end of the given spans. This can help with performance because the internal algorithm can process many elements at once. |
Definition at line 88 of file bit_bool_conversion.cc.
References blender::Span< T >::cast(), and or_bytes_into_bits().
Referenced by blender::index_mask::IndexMask::from_bools(), and blender::bits::tests::TEST().
| bool blender::bits::or_bytes_into_bits | ( | const Span< char > | bytes, |
| MutableBitSpan | r_bits, | ||
| const int64_t | allowed_overshoot, | ||
| const ByteToBit & | byte_to_bit ) |
Definition at line 15 of file bit_bool_conversion.cc.
References blender::bits::MutableBitSpan::bit_range(), BitIndexMask, BitsPerInt, BLI_assert, blender::bits::MutableBitSpan::data(), blender::Span< T >::data(), int_containing_bit(), blender::Span< T >::is_empty(), blender::bits::MutableBitSpan::size(), blender::Span< T >::size(), and blender::IndexRange::start().
Referenced by or_bools_into_bits().
|
inline |
Definition at line 349 of file BLI_bit_span_ops.hh.
References any_set_expr(), and b.
Referenced by blender::bke::node_tree_reference_lifetimes::or_into_each_other().
|
inline |
Definition at line 358 of file BLI_bit_span_ops.hh.
References any_set_expr(), b, BLI_assert, and mask().
Referenced by blender::bke::node_tree_reference_lifetimes::or_into_each_other_masked().
|
inline |
Definition at line 395 of file BLI_bit_vector.hh.
References data.
|
inline |
Definition at line 389 of file BLI_bit_vector.hh.
References data.
Overloaded in BLI_bit_vector.hh. The purpose is to make passing BitVector into bit span operations more efficient (interpreting it as BoundedBitSpan instead of just BitSpan).
Definition at line 404 of file BLI_bit_span.hh.
References data, blender::is_same_any_v, and T.
Referenced by any_set_expr(), find_first_1_index_expr(), foreach_1_index_expr(), and mix_into_first_expr().
|
inline |
Definition at line 388 of file BLI_bit_span.hh.
References blender::bits::BitSpan::bit_range(), BitsPerInt, BitToIntIndexShift, blender::bits::BitSpan::data(), is_bounded_span(), blender::bits::BitSpan::size(), and blender::IndexRange::start().
|
constexpr |
Definition at line 415 of file BLI_bit_span.hh.
Referenced by blender::bits::detail::any_set_expr(), blender::bits::detail::foreach_1_index_expr(), and blender::bits::detail::mix_into_first_expr().
|
staticconstexpr |
Bit mask containing a 1 for the last few bits that index a bit inside of an BitInt.
Definition at line 34 of file BLI_bit_ref.hh.
Referenced by blender::bits::BitRef::BitRef(), bits_to_index_ranges(), blender::bits::BoundedBitSpan::final_bits_num(), blender::bits::MutableBoundedBitSpan::final_bits_num(), blender::bits::MutableBitRef::MutableBitRef(), blender::bits::BitGroupVector< InlineBufferCapacity, Allocator >::operator[](), blender::bits::BitGroupVector< InlineBufferCapacity, Allocator >::operator[](), or_bytes_into_bits(), blender::bits::MutableBitSpan::reset_all(), and blender::bits::MutableBitSpan::set_all().
Number of bits that fit into BitInt.
Definition at line 29 of file BLI_bit_ref.hh.
Referenced by bits_to_index_ranges(), blender::bits::BitVector< InlineBufferCapacity, Allocator >::BitVector(), blender::ed::sculpt_paint::expand::enabled_state_to_bitmap(), blender::index_mask::evaluate_exact_with_bits(), is_bounded_span(), mask_first_n_bits(), mask_last_n_bits(), mask_range_bits(), mask_single_bit(), or_bytes_into_bits(), blender::bits::MutableBitSpan::reset_all(), blender::bits::MutableBitSpan::set_all(), blender::bits::tests::TEST(), blender::bits::tests::TEST(), blender::bits::tests::TEST(), blender::bits::tests::TEST(), and try_get_bounded_span().
|
staticconstexpr |
Shift amount to get from a bit index to an int index. Equivalent to log(BitsPerInt, 2).
Definition at line 31 of file BLI_bit_ref.hh.
Referenced by blender::bits::detail::foreach_1_index_expr(), blender::bits::BoundedBitSpan::full_ints_num(), blender::bits::MutableBoundedBitSpan::full_ints_num(), int_containing_bit(), int_containing_bit(), blender::bits::BitGroupVector< InlineBufferCapacity, Allocator >::operator[](), blender::bits::BitGroupVector< InlineBufferCapacity, Allocator >::operator[](), and try_get_bounded_span().