Cleanup: BLI: Merge files #126169
@ -31,7 +31,6 @@ set(SRC
|
||||
intern/BLI_ghash_utils.cc
|
||||
intern/BLI_heap.c
|
||||
intern/BLI_heap_simple.c
|
||||
intern/BLI_index_range.cc
|
||||
intern/BLI_kdopbvh.c
|
||||
intern/BLI_linklist.c
|
||||
intern/BLI_linklist_lockfree.c
|
||||
|
@ -1,42 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "BLI_index_range.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
AlignedIndexRanges split_index_range_by_alignment(const IndexRange range, const int64_t alignment)
|
||||
{
|
||||
BLI_assert(is_power_of_2(alignment));
|
||||
const int64_t mask = alignment - 1;
|
||||
|
||||
AlignedIndexRanges aligned_ranges;
|
||||
|
||||
const int64_t start_chunk = range.start() & ~mask;
|
||||
const int64_t end_chunk = range.one_after_last() & ~mask;
|
||||
if (start_chunk == end_chunk) {
|
||||
aligned_ranges.prefix = range;
|
||||
}
|
||||
else {
|
||||
int64_t prefix_size = 0;
|
||||
int64_t suffix_size = 0;
|
||||
if (range.start() != start_chunk) {
|
||||
prefix_size = alignment - (range.start() & mask);
|
||||
}
|
||||
if (range.one_after_last() != end_chunk) {
|
||||
suffix_size = range.one_after_last() - end_chunk;
|
||||
}
|
||||
aligned_ranges.prefix = IndexRange(range.start(), prefix_size);
|
||||
aligned_ranges.suffix = IndexRange(end_chunk, suffix_size);
|
||||
aligned_ranges.aligned = IndexRange(aligned_ranges.prefix.one_after_last(),
|
||||
range.size() - prefix_size - suffix_size);
|
||||
}
|
||||
|
||||
return aligned_ranges;
|
||||
}
|
||||
|
||||
} // namespace blender
|
@ -3,11 +3,42 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BLI_index_range.hh"
|
||||
mod_moder marked this conversation as resolved
Outdated
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace blender {
|
||||
|
||||
AlignedIndexRanges split_index_range_by_alignment(const IndexRange range, const int64_t alignment)
|
||||
{
|
||||
BLI_assert(is_power_of_2(alignment));
|
||||
const int64_t mask = alignment - 1;
|
||||
|
||||
AlignedIndexRanges aligned_ranges;
|
||||
|
||||
const int64_t start_chunk = range.start() & ~mask;
|
||||
const int64_t end_chunk = range.one_after_last() & ~mask;
|
||||
if (start_chunk == end_chunk) {
|
||||
aligned_ranges.prefix = range;
|
||||
}
|
||||
else {
|
||||
int64_t prefix_size = 0;
|
||||
int64_t suffix_size = 0;
|
||||
if (range.start() != start_chunk) {
|
||||
prefix_size = alignment - (range.start() & mask);
|
||||
}
|
||||
if (range.one_after_last() != end_chunk) {
|
||||
suffix_size = range.one_after_last() - end_chunk;
|
||||
}
|
||||
aligned_ranges.prefix = IndexRange(range.start(), prefix_size);
|
||||
aligned_ranges.suffix = IndexRange(end_chunk, suffix_size);
|
||||
aligned_ranges.aligned = IndexRange(aligned_ranges.prefix.one_after_last(),
|
||||
range.size() - prefix_size - suffix_size);
|
||||
}
|
||||
|
||||
return aligned_ranges;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &stream, IndexRange range)
|
||||
{
|
||||
stream << '[' << range.start() << ", " << range.one_after_last() << ')';
|
||||
|
Loading…
Reference in New Issue
Block a user
This include does not seem necessary by the function.