Skip to content

Commit 79a03d3

Browse files
committed
Merge branch 'baw' of github.com:Devsh-Graphics-Programming/Nabla into baw
2 parents 6dfc510 + 54ae86e commit 79a03d3

File tree

5 files changed

+16
-31
lines changed

5 files changed

+16
-31
lines changed

include/nbl/asset/IAssetManager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,6 @@ class IAssetManager : public core::IReferenceCounted, public core::QuitSignallin
654654
if (file) // could fail creating file (lack of permissions)
655655
{
656656
bool res = writeAsset(file.get(), _params, _override);
657-
file->drop();
658657
return res;
659658
}
660659
else

include/nbl/asset/filters/CBasicImageFilterCommon.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CBasicImageFilterCommon
2626
public:
2727
using iterator_category = std::random_access_iterator_tag;
2828
using difference_type = int64_t;
29-
using value_type = const uint32_t*;
29+
using value_type = std::array<uint32_t,batch_dims>;
3030
using pointer = const value_type*;
3131
using reference = value_type;
3232

@@ -35,17 +35,17 @@ class CBasicImageFilterCommon
3535
BlockIterator()
3636
{
3737
std::fill_n(extentBatches,batch_dims,0u);
38-
std::fill_n(batchCoord,batch_dims,0u);
38+
std::fill_n(batchCoord.begin(),batch_dims,0u);
3939
}
4040
explicit inline BlockIterator(const uint32_t* _extentBatches)
4141
{
4242
std::copy_n(_extentBatches,batch_dims,extentBatches);
43-
std::fill_n(batchCoord,batch_dims,0u);
43+
std::fill_n(batchCoord.begin(),batch_dims,0u);
4444
}
4545
explicit inline BlockIterator(const uint32_t* _extentBatches, const uint32_t* _batchCoord)
4646
{
4747
std::copy_n(_extentBatches,batch_dims,extentBatches);
48-
std::copy_n(_batchCoord,batch_dims,batchCoord);
48+
std::copy_n(_batchCoord,batch_dims,batchCoord.begin());
4949
}
5050
BlockIterator(const BlockIterator<batch_dims>& other) = default;
5151
BlockIterator(BlockIterator<batch_dims>&& other) = default;
@@ -59,11 +59,9 @@ class CBasicImageFilterCommon
5959
}
6060
inline pointer operator->() const {return &batchCoord;}
6161

62-
inline value_type operator[] (int index)
62+
inline value_type operator[] (int index) const
6363
{
64-
BlockIterator<batch_dims> temp = BlockIterator<batch_dims>(this->extentBatches);
65-
temp+=index;
66-
return *temp;
64+
return *(operator+(index));
6765
}
6866

6967
inline bool operator< (const BlockIterator<batch_dims>& _rhs) const
@@ -108,7 +106,7 @@ class CBasicImageFilterCommon
108106
return copy;
109107
}
110108

111-
inline bool operator==(const BlockIterator<batch_dims>& other) const {return std::equal(batchCoord,batchCoord+batch_dims,other.batchCoord);}
109+
inline bool operator==(const BlockIterator<batch_dims>& other) const {return std::equal(batchCoord.begin(),batchCoord.end(),other.batchCoord.begin());}
112110
inline bool operator!=(const BlockIterator<batch_dims>& other) const {return !operator==(other);}
113111

114112
inline BlockIterator<batch_dims>& operator+=(const difference_type advance)
@@ -134,7 +132,7 @@ class CBasicImageFilterCommon
134132
inline const uint32_t* getExtentBatches() const {return extentBatches;}
135133
private:
136134
uint32_t extentBatches[batch_dims];
137-
uint32_t batchCoord[batch_dims];
135+
value_type batchCoord;
138136

139137

140138
explicit inline BlockIterator(const uint32_t* _extentBatches, difference_type linearAddress)
@@ -184,15 +182,15 @@ class CBasicImageFilterCommon
184182

185183
const auto strides = region.getByteStrides(blockInfo);
186184

187-
auto batch1D = [&f,&region,trueExtent,strides,trueOffset](const uint32_t* batchCoord)
185+
auto batch1D = [&f,&region,trueExtent,strides,trueOffset](const std::array<uint32_t,3u>& batchCoord)
188186
{
189187
for (auto xBlock=0u; xBlock<trueExtent.x; ++xBlock)
190188
{
191189
const core::vectorSIMDu32 localCoord(xBlock,batchCoord[0],batchCoord[1],batchCoord[2]);
192190
f(region.getByteOffset(localCoord,strides),localCoord+trueOffset);
193191
}
194192
};
195-
auto batch2D = [&f,&region,trueExtent,strides,trueOffset](const uint32_t* batchCoord)
193+
auto batch2D = [&f,&region,trueExtent,strides,trueOffset](const std::array<uint32_t,2u>& batchCoord)
196194
{
197195
for (auto yBlock=0u; yBlock<trueExtent.y; ++yBlock)
198196
for (auto xBlock=0u; xBlock<trueExtent.x; ++xBlock)
@@ -201,7 +199,7 @@ class CBasicImageFilterCommon
201199
f(region.getByteOffset(localCoord,strides),localCoord+trueOffset);
202200
}
203201
};
204-
auto batch3D = [&f,&region,trueExtent,strides,trueOffset](const uint32_t* batchCoord)
202+
auto batch3D = [&f,&region,trueExtent,strides,trueOffset](const std::array<uint32_t,1u>& batchCoord)
205203
{
206204
for (auto zBlock=0u; zBlock<trueExtent.z; ++zBlock)
207205
for (auto yBlock=0u; yBlock<trueExtent.y; ++yBlock)

include/nbl/asset/filters/CBlitImageFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class CBlitImageFilter : public CImageFilter<CBlitImageFilter<Swizzle,Dither,Nor
461461
CBasicImageFilterCommon::BlockIterator<batch_dims> begin(batchExtent);
462462
const uint32_t spaceFillingEnd[batch_dims] = {0u,batchExtent[1]};
463463
CBasicImageFilterCommon::BlockIterator<batch_dims> end(begin.getExtentBatches(),spaceFillingEnd);
464-
std::for_each(policy,begin,end,[&](const uint32_t* batchCoord) -> void
464+
std::for_each(policy,begin,end,[&](const std::array<uint32_t,batch_dims>& batchCoord) -> void
465465
{
466466
// we need some tmp memory for threads in the first pass so that they dont step on each other
467467
uint32_t decode_offset;

src/nbl/system/CArchiveLoaderZip.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@ namespace nbl::system
410410
if (!pBuf)
411411
{
412412
delete[] decryptedBuf;
413-
if (decrypted)
414-
decrypted->drop();
415413
return 0;
416414
}
417415

@@ -457,9 +455,7 @@ namespace nbl::system
457455
inflateEnd(&stream);
458456
}
459457

460-
if (decrypted)
461-
decrypted->drop();
462-
else
458+
if (!decrypted)
463459
delete[] pcData;
464460

465461
delete[] decryptedBuf;
@@ -496,8 +492,6 @@ namespace nbl::system
496492
{
497493
m_logger.log("Not enough memory for decompressing %s", ILogger::ELL_ERROR, params.absolutePath.string().c_str());
498494
delete[] decryptedBuf;
499-
if (decrypted)
500-
decrypted->drop();
501495
return 0;
502496
}
503497

@@ -541,9 +535,7 @@ namespace nbl::system
541535
err = BZ2_bzDecompress(&bz_ctx);
542536
err = BZ2_bzDecompressEnd(&bz_ctx);
543537

544-
if (decrypted)
545-
decrypted->drop();
546-
else
538+
if (!decrypted)
547539
delete[] pcData;
548540

549541
if (err != BZ_OK)
@@ -579,8 +571,6 @@ namespace nbl::system
579571
{
580572
m_logger.log("Not enough memory for decompressing %s", ILogger::ELL_ERROR, params.absolutePath.c_str());
581573
delete[] decryptedBuf;
582-
if (decrypted)
583-
decrypted->drop();
584574
return 0;
585575
}
586576

@@ -615,9 +605,7 @@ namespace nbl::system
615605
&lzmaAlloc);
616606
uncompressedSize = tmpDstSize; // may be different to expected value
617607

618-
if (decrypted)
619-
decrypted->drop();
620-
else
608+
if (!decrypted)
621609
delete[] pcData;
622610

623611
delete[] decryptedBuf;

src/nbl/video/COpenGL_Connection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ core::smart_refctd_ptr<COpenGL_Connection<API_TYPE>> COpenGL_Connection<API_TYPE
3535

3636
if (!physicalDevice)
3737
{
38-
retval->drop();
38+
retval->drop(); // maual drop needed, haven't made a smart pointer yet
3939
return nullptr;
4040
}
4141
retval->m_physicalDevices.push_back(std::move(physicalDevice));

0 commit comments

Comments
 (0)