Skip to content

Commit 013abca

Browse files
making sure our headers don't mess up external projects (core::min and core::max always need template parameters)
1 parent 34baef6 commit 013abca

17 files changed

+81
-78
lines changed

include/IDriver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class IDriver : public virtual core::IReferenceCounted, public IVideoCapabilityR
337337
const void* dataPtr = reinterpret_cast<const uint8_t*>(data)+uploadedSize;
338338
uint32_t localOffset = video::StreamingTransientDataBufferMT<>::invalid_address;
339339
uint32_t alignment = 64u; // smallest mapping alignment capability
340-
uint32_t subSize = static_cast<uint32_t>(core::min(core::alignDown(defaultUploadBuffer.get()->max_size(),alignment),size-uploadedSize));
340+
uint32_t subSize = static_cast<uint32_t>(core::min<uint32_t>(core::alignDown(defaultUploadBuffer.get()->max_size(),alignment),size-uploadedSize));
341341

342342
defaultUploadBuffer.get()->multi_place(std::chrono::microseconds(500u),1u,(const void* const*)&dataPtr,&localOffset,&subSize,&alignment);
343343
// keep trying again

include/IDriverMemoryBacked.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class IDriverMemoryBacked : public virtual core::IReferenceCounted
7070
if (!isPowerOfTwo(a.vulkanReqs.alignment) || !isPowerOfTwo(b.vulkanReqs.alignment))
7171
return false;
7272

73-
out.vulkanReqs.size = std::max(a.vulkanReqs.size,b.vulkanReqs.size);
74-
out.vulkanReqs.alignment = std::max(a.vulkanReqs.alignment,b.vulkanReqs.alignment);
73+
out.vulkanReqs.size = std::max<uint32_t>(a.vulkanReqs.size,b.vulkanReqs.size);
74+
out.vulkanReqs.alignment = std::max<uint32_t>(a.vulkanReqs.alignment,b.vulkanReqs.alignment);
7575
out.vulkanReqs.memoryTypeBits = a.vulkanReqs.memoryTypeBits&b.vulkanReqs.memoryTypeBits;
7676
if (out.vulkanReqs.memoryTypeBits!=0u)
7777
return false;

include/IFileSystem.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ class IFileSystem : public virtual core::IReferenceCounted
241241
//! Determines if a file exists and could be opened.
242242
/** \param filename is the string identifying the file which should be tested for existence.
243243
\return True if file exists, and false if it does not exist or an error occured. */
244-
virtual bool existFile(const path& filename) const =0;
245-
246-
244+
virtual bool existFile(const path& filename) const =0;
245+
246+
247247
//! Run-time resource ID, `builtinPath` includes the "irr/builtin" prefix
248248
inline core::smart_refctd_ptr<asset::ICPUBuffer> loadBuiltinData(const std::string& builtinPath)
249249
{
@@ -275,7 +275,7 @@ class IFileSystem : public virtual core::IReferenceCounted
275275
}
276276
return nullptr;
277277
#endif
278-
}
278+
}
279279
//! Compile time resource ID
280280
template<typename StringUniqueType>
281281
inline core::smart_refctd_ptr<asset::ICPUBuffer> loadBuiltinData()
@@ -292,8 +292,8 @@ class IFileSystem : public virtual core::IReferenceCounted
292292
#else
293293
return loadBuiltinData(StringUniqueType::value);
294294
#endif
295-
}
296-
295+
}
296+
297297

298298
//! Get the directory a file is located in.
299299
/** \param filename: The file to get the directory from.
@@ -303,18 +303,18 @@ class IFileSystem : public virtual core::IReferenceCounted
303303
// find last forward or backslash
304304
int32_t lastSlash = filename.findLast('/');
305305
const int32_t lastBackSlash = filename.findLast('\\'); //! Just remove those '\' on Linux
306-
lastSlash = core::max(lastSlash, lastBackSlash);
306+
lastSlash = core::max<int32_t>(lastSlash, lastBackSlash);
307307

308308
if ((uint32_t)lastSlash < filename.size())
309309
return filename.subString(0, lastSlash);
310310
else
311311
return path(".");
312-
}
312+
}
313313

314314
//! flatten a path and file name for example: "/you/me/../." becomes "/you"
315315
static inline path flattenFilename(const path& _directory, const path& root="/")
316-
{
317-
auto directory(_directory);
316+
{
317+
auto directory(_directory);
318318
handleBackslashes(&directory);
319319

320320
io::path dir;
@@ -363,19 +363,19 @@ class IFileSystem : public virtual core::IReferenceCounted
363363
process();
364364
}
365365
return dir;
366-
}
366+
}
367367

368368
//! Get the base part of a filename, i.e. the name without the directory part.
369369
/** If no directory is prefixed, the full name is returned.
370370
\param filename: The file to get the basename from
371371
\param keepExtension True if filename with extension is returned otherwise everything
372372
after the final '.' is removed as well. */
373-
static inline path getFileBasename(const path& filename, bool keepExtension=true)
373+
static inline path getFileBasename(const path& filename, bool keepExtension=true)
374374
{
375375
// find last forward or backslash
376376
int32_t lastSlash = filename.findLast('/');
377377
const int32_t lastBackSlash = filename.findLast('\\'); //! Just remove those '\' on Linux
378-
lastSlash = core::max(lastSlash, lastBackSlash);
378+
lastSlash = core::max<int32_t>(lastSlash, lastBackSlash);
379379

380380
// get number of chars after last dot
381381
int32_t end = 0;
@@ -395,7 +395,7 @@ class IFileSystem : public virtual core::IReferenceCounted
395395
else if (end != 0)
396396
return filename.subString(0, filename.size()-end);
397397
else
398-
return filename;
398+
return filename;
399399
}
400400

401401
protected:

include/irr/asset/ICPUVirtualTexture.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ICPUVirtualTexture final : public IVirtualTexture<ICPUImageView, ICPUSampl
6161
{
6262
const auto& params = _img->getCreationParameters();
6363
const auto originalExtent = params.extent;
64-
const uint32_t paddedExtent = core::roundUpToPoT(std::max(params.extent.width,params.extent.height));
64+
const uint32_t paddedExtent = core::roundUpToPoT(std::max<uint32_t>(params.extent.width,params.extent.height));
6565

6666
//create PoT and square image with regions for all mips
6767
ICPUImage::SCreationParams paddedParams = params;
@@ -167,7 +167,7 @@ class ICPUVirtualTexture final : public IVirtualTexture<ICPUImageView, ICPUSampl
167167
const VkExtent3D extent = {_addr.origsize_x, _addr.origsize_y, 1u};
168168

169169
const uint32_t levelsTakingAtLeastOnePageCount = countLevelsTakingAtLeastOnePage(extent);
170-
const uint32_t levelsToPack = std::min(_subres.levelCount, m_pageTable->getCreationParameters().mipLevels+m_pgSzxy_log2);
170+
const uint32_t levelsToPack = std::min<uint32_t>(_subres.levelCount, m_pageTable->getCreationParameters().mipLevels+m_pgSzxy_log2);
171171

172172
uint32_t miptailPgAddr = SPhysPgOffset::invalid_addr;
173173

@@ -233,9 +233,9 @@ class ICPUVirtualTexture final : public IVirtualTexture<ICPUImageView, ICPUSampl
233233
copy.extentLayerCount = core::vectorSIMDu32(m_pgSzxy, m_pgSzxy, 1u, 1u);
234234
copy.relativeOffset = {0u,0u,0u};
235235
if (x == w-1u)
236-
copy.extentLayerCount.x = std::max(extent.width>>i,1u)-copy.inOffsetBaseLayer.x;
236+
copy.extentLayerCount.x = std::max<uint32_t>(extent.width>>i,1u)-copy.inOffsetBaseLayer.x;
237237
if (y == h-1u)
238-
copy.extentLayerCount.y = std::max(extent.height>>i,1u)-copy.inOffsetBaseLayer.y;
238+
copy.extentLayerCount.y = std::max<uint32_t>(extent.height>>i,1u)-copy.inOffsetBaseLayer.y;
239239
memcpy(&copy.paddedExtent.width,(copy.extentLayerCount+core::vectorSIMDu32(2u*m_tilePadding)).pointer, 2u*sizeof(uint32_t));
240240
copy.paddedExtent.depth = 1u;
241241
if (w>1u)
@@ -293,7 +293,7 @@ class ICPUVirtualTexture final : public IVirtualTexture<ICPUImageView, ICPUSampl
293293
{
294294
copy.inMipLevel = _subresRelativeToMaster.baseMipLevel+i;
295295
copy.outMipLevel = i;
296-
copy.extent = {std::max(extent.width>>i,1u), std::max(extent.height>>i,1u), 1u};
296+
copy.extent = {std::max<uint32_t>(extent.width>>i,1u), std::max<uint32_t>(extent.height>>i,1u), 1u};
297297
copy.inOffset = {static_cast<uint32_t>(_addr.pgTab_x>>(copy.inMipLevel)),static_cast<uint32_t>(_addr.pgTab_y>>(copy.inMipLevel)),0u};
298298
copy.outOffset = {static_cast<uint32_t>(aliasAddr.pgTab_x>>i), static_cast<uint32_t>(aliasAddr.pgTab_y>>i), 0u};
299299

@@ -401,4 +401,4 @@ class ICPUVirtualTexture final : public IVirtualTexture<ICPUImageView, ICPUSampl
401401

402402
}}
403403

404-
#endif
404+
#endif

include/irr/asset/IDescriptorSet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class IDescriptorSet : public virtual core::IReferenceCounted
7474

7575
SDescriptorInfo()
7676
{
77-
memset(&buffer, 0, std::max(sizeof(buffer), sizeof(image)));
77+
memset(&buffer, 0, core::max<size_t>(sizeof(buffer), sizeof(image)));
7878
}
7979
~SDescriptorInfo()
8080
{
@@ -195,4 +195,4 @@ class IEmulatedDescriptorSet
195195
}
196196
}
197197

198-
#endif
198+
#endif

include/irr/asset/IImage.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ class IImage : public IDescriptor
219219
switch (type)
220220
{
221221
case ET_3D:
222-
maxSideLen = core::max(extent.depth,maxSideLen);
222+
maxSideLen = core::max<uint32_t>(extent.depth,maxSideLen);
223223
_IRR_FALLTHROUGH;
224224
case ET_2D:
225-
maxSideLen = core::max(extent.height,maxSideLen);
225+
maxSideLen = core::max<uint32_t>(extent.height,maxSideLen);
226226
break;
227227
default:
228228
break;
@@ -446,11 +446,14 @@ class IImage : public IDescriptor
446446
//!
447447
inline core::vector3du32_SIMD getMipSize(uint32_t level=0u) const
448448
{
449-
return core::max( core::vector3du32_SIMD( params.extent.width,
450-
params.extent.height,
451-
params.extent.depth)
452-
/ (0x1u<<level),
453-
core::vector3du32_SIMD(1u,1u,1u));
449+
return core::max<core::vector3du32_SIMD>(
450+
core::vector3du32_SIMD(
451+
params.extent.width,
452+
params.extent.height,
453+
params.extent.depth
454+
)/(0x1u<<level),
455+
core::vector3du32_SIMD(1u,1u,1u)
456+
);
454457
}
455458

456459
//! Returns image data size in bytes

include/irr/asset/IPipelineLayout.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct SPushConstantRange
3939
const int32_t end1 = offset + size;
4040
const int32_t end2 = _other.offset + _other.size;
4141

42-
return (std::min(end1, end2) - std::max<int32_t>(offset, _other.offset)) > 0;
42+
return (std::min<int32_t>(end1, end2) - std::max<int32_t>(offset, _other.offset)) > 0;
4343
}
4444
};
4545

@@ -118,4 +118,4 @@ class IPipelineLayout
118118
}
119119
}
120120

121-
#endif
121+
#endif

include/irr/asset/IVirtualTexture.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class IVirtualTexture : public core::IReferenceCounted, public IVirtualTextureBa
202202
const uint32_t w = neededPageCountForSide(_w, _baseLevel);
203203
const uint32_t h = neededPageCountForSide(_h, _baseLevel);
204204

205-
return core::roundUpToPoT(std::max(w, h));
205+
return core::roundUpToPoT(std::max<uint32_t>(w, h));
206206
}
207207

208208
ISampler::SParams getPageTableSamplerParams() const
@@ -285,12 +285,12 @@ class IVirtualTexture : public core::IReferenceCounted, public IVirtualTextureBa
285285

286286
uint32_t countLevelsTakingAtLeastOnePage(const VkExtent3D& _extent, uint32_t _baseLevel = 0u)
287287
{
288-
const uint32_t baseMaxDim = core::roundUpToPoT(core::max(_extent.width, _extent.height))>>_baseLevel;
288+
const uint32_t baseMaxDim = core::roundUpToPoT(core::max<uint32_t>(_extent.width, _extent.height))>>_baseLevel;
289289
const int32_t lastFullMip = core::findMSB(baseMaxDim-1u)+1 - static_cast<int32_t>(m_pgSzxy_log2);
290290

291291
assert(lastFullMip<static_cast<int32_t>(m_pageTable->getCreationParameters().mipLevels));
292292

293-
return std::max(lastFullMip+1, 0);
293+
return core::max<int32_t>(lastFullMip+1, 0);
294294
}
295295

296296
//this is not static only because it has to call virtual member function
@@ -304,7 +304,7 @@ class IVirtualTexture : public core::IReferenceCounted, public IVirtualTextureBa
304304
params.arrayLayers = _pgTabLayers;
305305
params.extent = {pgTabSzxy,pgTabSzxy,1u};
306306
params.format = EF_R16G16_UINT;
307-
params.mipLevels = std::max(static_cast<int32_t>(_maxAllocatableTexSz_log2-_pgSzxy_log2+1u), 1);
307+
params.mipLevels = std::max<int32_t>(static_cast<int32_t>(_maxAllocatableTexSz_log2-_pgSzxy_log2+1u), 1);
308308
params.samples = IImage::ESCF_1_BIT;
309309
params.type = IImage::ET_2D;
310310
params.flags = static_cast<IImage::E_CREATE_FLAGS>(0);
@@ -393,7 +393,7 @@ class IVirtualTexture : public core::IReferenceCounted, public IVirtualTextureBa
393393
class IVTResidentStorage : public core::IReferenceCounted
394394
{
395395
protected:
396-
_IRR_STATIC_INLINE_CONSTEXPR uint32_t MAX_TILES_PER_DIM = std::min(SPhysPgOffset::PAGE_ADDR_X_MASK,SPhysPgOffset::PAGE_ADDR_Y_MASK) + 1u;
396+
_IRR_STATIC_INLINE_CONSTEXPR uint32_t MAX_TILES_PER_DIM = std::min<uint32_t>(SPhysPgOffset::PAGE_ADDR_X_MASK,SPhysPgOffset::PAGE_ADDR_Y_MASK) + 1u;
397397
_IRR_STATIC_INLINE_CONSTEXPR uint32_t MAX_LAYERS = (1u<<(SPhysPgOffset::PAGE_ADDR_BITLENGTH-SPhysPgOffset::PAGE_ADDR_LAYER_SHIFT));
398398

399399
virtual ~IVTResidentStorage()
@@ -772,7 +772,7 @@ class IVirtualTexture : public core::IReferenceCounted, public IVirtualTextureBa
772772
//! @returns pointer to reserved space for allocators
773773
uint8_t* copyVirtualSpaceAllocatorsState(uint32_t _count, pg_tab_addr_alctr_t* _dstArray)
774774
{
775-
_count = std::min(_count, m_pageTable->getCreationParameters().arrayLayers);
775+
_count = std::min<uint32_t>(_count, m_pageTable->getCreationParameters().arrayLayers);
776776
const uint32_t bufSz = m_pageTableLayerAllocators[0].get_total_size();
777777
const uint32_t resSpcPerAlctr = pg_tab_addr_alctr_t::reserved_size(m_pageTableLayerAllocators[0].get_total_size(), m_pageTableLayerAllocators[0]);
778778
uint8_t* reservedSpc = reinterpret_cast<uint8_t*>( _IRR_ALIGNED_MALLOC(resSpcPerAlctr*_count, _IRR_SIMD_ALIGNMENT) );
@@ -830,7 +830,7 @@ class IVirtualTexture : public core::IReferenceCounted, public IVirtualTextureBa
830830
std::pair<uint32_t,uint32_t> getDSlayoutBindings_internal(typename DSlayout_t::SBinding* _outBindings, core::smart_refctd_ptr<sampler_t>* _outSamplers, uint32_t _pgtBinding = 0u, uint32_t _fsamplersBinding = 1u, uint32_t _isamplersBinding = 2u, uint32_t _usamplersBinding = 3u) const
831831
{
832832
const uint32_t bindingCount = 1u+(getFloatViews().size()?1u:0u)+(getIntViews().size()?1u:0u)+(getUintViews().size()?1u:0u);
833-
const uint32_t samplerCount = 1u+std::max(getFloatViews().size(), std::max(getIntViews().size(), getUintViews().size()));
833+
const uint32_t samplerCount = 1u+std::max<uint32_t>(getFloatViews().size(), std::max<uint32_t>(getIntViews().size(), getUintViews().size()));
834834
if (!_outBindings || !_outSamplers)
835835
return std::make_pair(bindingCount, samplerCount);
836836

@@ -1040,4 +1040,4 @@ bool IVirtualTexture<image_view_t, sampler_t>::SMiptailPacker::computeMiptailOff
10401040

10411041
}}
10421042

1043-
#endif
1043+
#endif

include/irr/asset/filters/CBasicImageFilterCommon.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class CBasicImageFilterCommon
7979
const core::vector3du32_SIMD resultExtent(referenceRegion->imageExtent.width,referenceRegion->imageExtent.height,referenceRegion->imageExtent.depth,referenceRegion->imageSubresource.layerCount);
8080
const auto resultLimit = resultOffset+resultExtent;
8181

82-
auto offset = core::max(targetOffset,resultOffset);
83-
auto limit = core::min(targetLimit,resultLimit);
82+
auto offset = core::max<core::vector3du32_SIMD>(targetOffset,resultOffset);
83+
auto limit = core::min<core::vector3du32_SIMD>(targetLimit,resultLimit);
8484
if ((offset>=limit).any())
8585
return false;
8686

@@ -257,4 +257,4 @@ class CBasicInOutImageFilterCommon : public CBasicImageFilterCommon
257257
} // end namespace asset
258258
} // end namespace irr
259259

260-
#endif
260+
#endif

include/irr/asset/filters/CBlitImageFilter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class CBlitImageFilter : public CImageFilter<CBlitImageFilter<Kernel> >, public
299299
const int32_t rankIndex = (inverseCoverage*core::rational<int32_t>(outputTexelCount)).getIntegerApprox()-1;
300300
auto* const begin = intermediateStorage[(axis+1)%3];
301301
// this is our new reference value
302-
auto* const nth = begin+core::max(rankIndex,0);
302+
auto* const nth = begin+core::max<int32_t>(rankIndex,0);
303303
auto* const end = begin+outputTexelCount;
304304
for (auto i=0; i<outputTexelCount; i++)
305305
{
@@ -464,9 +464,9 @@ class CBlitImageFilter : public CImageFilter<CBlitImageFilter<Kernel> >, public
464464
const auto inType = state->inImage->getCreationParameters().type;
465465
const auto window_last = getKernelWindowLastCoord(state->contructScaledKernel(),inType);
466466
// TODO: account for the size needed for coverage adjustment
467-
auto texelCount = state->outExtent.width*core::max((state->inExtent.height+window_last[1])*(state->inExtent.depth+window_last[2]),state->outExtent.height*state->outExtent.depth);
467+
auto texelCount = state->outExtent.width*core::max<uint32_t>((state->inExtent.height+window_last[1])*(state->inExtent.depth+window_last[2]),state->outExtent.height*state->outExtent.depth);
468468
if (secondPong)
469-
texelCount += core::max(state->outExtent.width*state->outExtent.height*(state->inExtent.depth+window_last[2]),state->inExtent.width+window_last[0]);
469+
texelCount += core::max<uint32_t>(state->outExtent.width*state->outExtent.height*(state->inExtent.depth+window_last[2]),state->inExtent.width+window_last[0]);
470470
//
471471
return texelCount*Kernel::MaxChannels*sizeof(value_type);
472472
}
@@ -475,4 +475,4 @@ class CBlitImageFilter : public CImageFilter<CBlitImageFilter<Kernel> >, public
475475
} // end namespace asset
476476
} // end namespace irr
477477

478-
#endif
478+
#endif

0 commit comments

Comments
 (0)