BLI: Add missing overrides to some generic virtual array implementations #118161

Merged
Hans Goudey merged 5 commits from HooglyBoogly/blender:gvarray-missing-overrides into main 2024-02-13 20:00:07 +01:00
1 changed files with 40 additions and 14 deletions

View File

@ -265,21 +265,33 @@ template<int BufferSize> class GVArrayImpl_For_SmallTrivialSingleValue : public
}
private:
void get(const int64_t /*index*/, void *r_value) const override
void get(const int64_t index, void *r_value) const final
{
this->copy_value_to(r_value);
this->get_to_uninitialized(index, r_value);
}
void get_to_uninitialized(const int64_t /*index*/, void *r_value) const override
void get_to_uninitialized(const int64_t /*index*/, void *r_value) const final
{
this->copy_value_to(r_value);
memcpy(r_value, &buffer_, type_->size());
}
void copy_value_to(void *dst) const
void materialize(const IndexMask &mask, void *dst) const final
{
memcpy(dst, &buffer_, type_->size());
this->materialize_to_uninitialized(mask, dst);
}
void materialize_to_uninitialized(const IndexMask &mask, void *dst) const final
{
type_->fill_construct_indices(buffer_, dst, mask);
HooglyBoogly marked this conversation as resolved Outdated

To be locally correct, this should use fill_construct_indices instead of assign. Same below.

To be locally correct, this should use `fill_construct_indices` instead of `assign`. Same below.
}
void materialize_compressed(const IndexMask &mask, void *dst) const final
{
this->materialize_compressed_to_uninitialized(mask, dst);
}
void materialize_compressed_to_uninitialized(const IndexMask &mask, void *dst) const final
{
type_->fill_construct_n(buffer_, dst, mask.size());
}
CommonVArrayInfo common_info() const override
CommonVArrayInfo common_info() const final
{
return CommonVArrayInfo{CommonVArrayInfo::Type::Single, true, &buffer_};
}
@ -499,15 +511,29 @@ class GVArrayImpl_For_SlicedGVArray : public GVArrayImpl {
return {};
}
void materialize(const IndexMask &mask, void *dst) const final
{
IndexMaskMemory memory;
HooglyBoogly marked this conversation as resolved Outdated

What do you think about creating a shifted version of the mask and to pass that into varray_? Then it wouldn't be necessary to iterate over the segments here.

What do you think about creating a shifted version of the mask and to pass that into `varray_`? Then it wouldn't be necessary to iterate over the segments here.
const IndexMask shifted_mask = mask.shift(offset_, memory);
varray_.materialize(shifted_mask, dst);
}
void materialize_to_uninitialized(const IndexMask &mask, void *dst) const final
{
IndexMaskMemory memory;
const IndexMask shifted_mask = mask.shift(offset_, memory);
varray_.materialize_to_uninitialized(shifted_mask, dst);
}
void materialize_compressed(const IndexMask &mask, void *dst) const final
{
IndexMaskMemory memory;
const IndexMask shifted_mask = mask.shift(offset_, memory);
varray_.materialize_compressed(shifted_mask, dst);
}
void materialize_compressed_to_uninitialized(const IndexMask &mask, void *dst) const override
{
IndexMaskFromSegment mask_from_segment;
mask.foreach_segment([&](const IndexMaskSegment segment, const int64_t start) {
const IndexMask &segment_mask = mask_from_segment.update(
{segment.offset() + offset_, segment.base_span()});
varray_.materialize_compressed_to_uninitialized(segment_mask,
POINTER_OFFSET(dst, type_->size() * start));
});
IndexMaskMemory memory;
const IndexMask shifted_mask = mask.shift(offset_, memory);
varray_.materialize_compressed_to_uninitialized(shifted_mask, dst);
}
};