Skip to content

Commit 2b2e469

Browse files
test radix sort and fix a few unrelated bugs
1 parent 355dd24 commit 2b2e469

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

examples_tests/18.MitsubaLoader/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ int main()
212212
asset::CQuantNormalCache* qnc = am->getMeshManipulator()->getQuantNormalCache();
213213

214214
auto serializedLoader = core::make_smart_refctd_ptr<nbl::ext::MitsubaLoader::CSerializedLoader>(am);
215-
auto mitsubaLoader = core::make_smart_refctd_ptr<nbl::ext::MitsubaLoader::CMitsubaLoader>(am,fs);
215+
auto mitsubaLoader = core::make_smart_refctd_ptr<nbl::ext::MitsubaLoader::CMitsubaLoader>(am, fs);
216+
serializedLoader->initialize();
217+
mitsubaLoader->initialize();
216218
am->addAssetLoader(std::move(serializedLoader));
217219
am->addAssetLoader(std::move(mitsubaLoader));
218220

@@ -327,7 +329,11 @@ int main()
327329
// look out for this!!!
328330
// when added, CMitsubaLoader inserts its own include loader into GLSLCompiler
329331
// thats why i have to add it again here (after device recreation) to be able to compile shaders
330-
am->addAssetLoader(core::make_smart_refctd_ptr<nbl::ext::MitsubaLoader::CMitsubaLoader>(am, device->getFileSystem()));
332+
{
333+
auto mitsubaLoader = core::make_smart_refctd_ptr<nbl::ext::MitsubaLoader::CMitsubaLoader>(am, fs);
334+
mitsubaLoader->initialize();
335+
am->addAssetLoader(std::move(mitsubaLoader));
336+
}
331337

332338
core::smart_refctd_ptr<asset::ICPUDescriptorSetLayout> ds2layout;
333339
{

include/nbl/core/algorithm/radix_sort.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ struct RadixSorter
6161
template<class RandomIt, class KeyAccessor>
6262
inline RandomIt operator()(RandomIt input, RandomIt output, const histogram_t rangeSize, const KeyAccessor& comp)
6363
{
64-
return impl<RandomIt,KeyAccessor,0ull>(input,output,rangeSize,comp);
64+
return pass<RandomIt,KeyAccessor,0ull>(input,output,rangeSize,comp);
6565
}
6666
private:
6767
template<class RandomIt, class KeyAccessor, size_t pass_ix>
68-
inline RandomIt impl(RandomIt input, RandomIt output, const histogram_t rangeSize, const KeyAccessor& comp)
68+
inline RandomIt pass(RandomIt input, RandomIt output, const histogram_t rangeSize, const KeyAccessor& comp)
6969
{
7070
// clear
7171
std::fill_n(histogram,histogram_size,static_cast<histogram_t>(0u));
@@ -80,7 +80,7 @@ struct RadixSorter
8080
output[--histogram[comp.operator()<shift,radix_mask>(input[i])]] = input[i];
8181

8282
if constexpr (pass_ix != last_pass)
83-
return impl<RandomIt,KeyAccessor,pass_ix+1ull>(output,input,rangeSize,comp);
83+
return pass<RandomIt,KeyAccessor,pass_ix+1ull>(output,input,rangeSize,comp);
8484
else
8585
return output;
8686
}

src/nbl/asset/utils/CSmoothNormalGenerator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ void CSmoothNormalGenerator::VertexHashMap::validate()
132132
{
133133
const auto oldSize = vertices.size();
134134
vertices.resize(oldSize*2u);
135+
// TODO: maybe use counting sort (or big radix) and use the histogram directly for the buckets
135136
auto finalSortedOutput = core::radix_sort(vertices.data(),vertices.data()+oldSize,oldSize,KeyAccessor());
137+
// TODO: optimize out the erase
136138
if (finalSortedOutput!=vertices.data())
137139
vertices.erase(vertices.begin(),vertices.begin()+oldSize);
138140
else
139141
vertices.erase(vertices.begin()+oldSize,vertices.end());
140142

143+
// TODO: are `buckets` even begin USED!?
141144
uint16_t prevHash = vertices[0].hash;
142145
core::vector<IMeshManipulator::SSNGVertexData>::iterator prevBegin = vertices.begin();
143146
buckets.push_back(prevBegin);

0 commit comments

Comments
 (0)