|
3 | 3 | #include "nbl/asset/filters/CMatchedSizeInOutImageFilterCommon.h"
|
4 | 4 | #include "nbl/asset/filters/CFlattenRegionsImageFilter.h"
|
5 | 5 |
|
| 6 | +#include <ranges> |
| 7 | + |
6 | 8 | using namespace nbl;
|
7 | 9 | using namespace asset;
|
8 | 10 |
|
@@ -81,56 +83,6 @@ class CFlattenRegionsStreamHashImageFilter : public CMatchedSizeInOutImageFilter
|
81 | 83 |
|
82 | 84 | using state_type = CState;
|
83 | 85 |
|
84 |
| - // A wrapper for an additive, in[de]crementable value, so you can use values as iterators |
85 |
| - template <typename Type, typename DiffType = std::ptrdiff_t> |
86 |
| - struct ValueIterator { |
87 |
| - |
88 |
| - // Iterator type traits |
89 |
| - using iterator_category = std::random_access_iterator_tag; |
90 |
| - using difference_type = DiffType; //must be a signed integer-like type |
91 |
| - using value_type = Type; |
92 |
| - using reference = Type; |
93 |
| - using pointer = Type; |
94 |
| - |
95 |
| - inline explicit ValueIterator(value_type value) : m_value(value) {}; |
96 |
| - inline ValueIterator() : m_value{} {}; |
97 |
| - ValueIterator(const ValueIterator& other) = default; |
98 |
| - ValueIterator(ValueIterator&& other) = default; |
99 |
| - |
100 |
| - ValueIterator& operator=(const ValueIterator& other) = default; |
101 |
| - ValueIterator& operator=(ValueIterator&& other) = default; |
102 |
| - |
103 |
| - // Iterator traits |
104 |
| - inline reference operator*() const { return m_value; } |
105 |
| - inline ValueIterator& operator++() { m_value++; return *this; } |
106 |
| - inline ValueIterator operator++(int) { ValueIterator tmp = *this; ++(*this); return tmp; } |
107 |
| - |
108 |
| - // InputIterator traits |
109 |
| - inline bool operator==(const ValueIterator& other) const { return m_value == other.operator*(); } |
110 |
| - inline bool operator!=(const ValueIterator& other) const { return !operator==(other); } |
111 |
| - inline pointer operator->() const { return m_value; } |
112 |
| - |
113 |
| - // BidirectionalIterator traits |
114 |
| - inline ValueIterator& operator--() { m_value--; return *this; } |
115 |
| - inline ValueIterator operator--(int) { ValueIterator tmp = *this; --(*this); return tmp; } |
116 |
| - |
117 |
| - //RandomAccessIterator traits |
118 |
| - inline ValueIterator& operator+=(difference_type advance) { m_value += advance; return *this; } |
119 |
| - inline ValueIterator operator+(difference_type advance) const { return ValueIterator(m_value + advance); } |
120 |
| - friend inline ValueIterator operator+(difference_type advance, const ValueIterator& other) { return valueIterator(advance + *other); } |
121 |
| - inline ValueIterator& operator-=(difference_type advance) { m_value -= advance; return *this; } |
122 |
| - inline ValueIterator operator-(difference_type advance) const { return ValueIterator(m_value - advance); } |
123 |
| - inline value_type operator[] (int index) const { return m_value + index; } |
124 |
| - inline difference_type operator-(const ValueIterator& other) const { return m_value - *other; } |
125 |
| - inline bool operator< (const ValueIterator& other) const { return m_value < *other; } |
126 |
| - inline bool operator> (const ValueIterator& other) const { return m_value > *other; } |
127 |
| - inline bool operator>= (const ValueIterator& other) const { return m_value >= *other; } |
128 |
| - inline bool operator<= (const ValueIterator& other) const { return m_value <= *other; } |
129 |
| - |
130 |
| - private: |
131 |
| - value_type m_value; |
132 |
| - }; |
133 |
| - |
134 | 86 | static inline bool validate(state_type* state)
|
135 | 87 | {
|
136 | 88 | if (!state)
|
@@ -253,13 +205,8 @@ class CFlattenRegionsStreamHashImageFilter : public CMatchedSizeInOutImageFilter
|
253 | 205 | const auto texelOrBlockByteSize = asset::getTexelOrBlockBytesize(parameters.format);
|
254 | 206 | const uint8_t* inData = reinterpret_cast<const uint8_t*>(image->getBuffer()->getPointer());
|
255 | 207 |
|
256 |
| - struct range { |
257 |
| - ValueIterator<uint32_t> begin; |
258 |
| - ValueIterator<uint32_t> end; |
259 |
| - }; |
260 |
| - |
261 |
| - range layers = { .begin{0}, .end{parameters.arrayLayers} }; |
262 |
| - range levels = { .begin{0}, .end{parameters.mipLevels} }; |
| 208 | + auto layers = std::views::iota(0u, parameters.arrayLayers); |
| 209 | + auto levels = std::views::iota(0u, parameters.mipLevels); |
263 | 210 |
|
264 | 211 | /*
|
265 | 212 | we stream-hash texels per given mip level & layer
|
@@ -298,10 +245,10 @@ class CFlattenRegionsStreamHashImageFilter : public CMatchedSizeInOutImageFilter
|
298 | 245 | blake3_hasher_finalize(hasher, reinterpret_cast<uint8_t*>(hash), sizeof(CState::hash_t)); // finalize hash for layer + put it to heap for given mip level
|
299 | 246 | };
|
300 | 247 |
|
301 |
| - std::for_each(policy, layers.begin, layers.end, executePerLayer); // fire per layer for given given mip level with specified execution policy, yes you can use parallel policy here if you want at it will work |
| 248 | + std::for_each(policy, layers.begin(), layers.end(), executePerLayer); // fire per layer for given given mip level with specified execution policy, yes you can use parallel policy here if you want at it will work |
302 | 249 | };
|
303 | 250 |
|
304 |
| - std::for_each(policy, levels.begin, levels.end, executePerMipLevel); // fire per block of layers for given mip level with specified execution policy, yes you can use parallel policy here if you want at it will work |
| 251 | + std::for_each(policy, levels.begin(), levels.end(), executePerMipLevel); // fire per block of layers for given mip level with specified execution policy, yes you can use parallel policy here if you want at it will work |
305 | 252 |
|
306 | 253 | /*
|
307 | 254 | scratch's heap is filled with all hashes,
|
|
0 commit comments