From 849c92f1a2b45bb07061a15172013111220760eb Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 11 Apr 2025 23:57:28 +0200 Subject: [PATCH 01/25] fix -Wunreachable-code-break warnings --- src/nbl/asset/interchange/CImageLoaderJPG.cpp | 3 --- .../material_compiler/CMaterialCompilerGLSLBackendCommon.cpp | 4 ---- src/nbl/asset/utils/CCompilerSet.cpp | 1 - src/nbl/asset/utils/CHLSLCompiler.cpp | 1 - src/nbl/asset/utils/CMeshManipulator.cpp | 3 --- src/nbl/video/ILogicalDevice.cpp | 2 -- src/nbl/video/utilities/CAssetConverter.cpp | 1 - 7 files changed, 15 deletions(-) diff --git a/src/nbl/asset/interchange/CImageLoaderJPG.cpp b/src/nbl/asset/interchange/CImageLoaderJPG.cpp index 45677ff5cf..8aae9ca7b1 100644 --- a/src/nbl/asset/interchange/CImageLoaderJPG.cpp +++ b/src/nbl/asset/interchange/CImageLoaderJPG.cpp @@ -277,15 +277,12 @@ asset::SAssetBundle CImageLoaderJPG::loadAsset(system::IFile* _file, const asset case JCS_CMYK: _params.logger.log("CMYK color space is unsupported:", system::ILogger::ELL_ERROR, _file->getFileName().string()); return {}; - break; case JCS_YCCK: // this I have no resources on _params.logger.log("YCCK color space is unsupported: %s", system::ILogger::ELL_ERROR, _file->getFileName().string().c_str()); return {}; - break; default: _params.logger.log("Can't load as color space is unknown: %s", system::ILogger::ELL_ERROR, _file->getFileName().string().c_str()); return {}; - break; } cinfo.do_fancy_upsampling = TRUE; diff --git a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp index 7e67141de1..b077a952b6 100644 --- a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp +++ b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp @@ -1232,16 +1232,12 @@ auto CMaterialCompilerGLSLBackendCommon::compile(SContext* _ctx, IR* _ir, E_GENE { case EGST_PRESENT: return 4u; - break; // When desiring Albedo and Normal Extraction, one needs to use extra registers for albedo, normal and throughput scale case EGST_PRESENT_WITH_AOV_EXTRACTION: // TODO: investigate whether using 10-16bit storage (fixed point or half float) makes execution faster, because // albedo could fit in 1.5 DWORDs as 16bit (or 1 DWORDs as 10 bit), normal+throughput scale in 2 DWORDs as half floats or 16 bit snorm // and value/pdf is a low dynamic range so half float could be feasible! Giving us a total register count of 5 DWORDs. return 11u; - break; - default: - break; } // only colour contribution return 3u; diff --git a/src/nbl/asset/utils/CCompilerSet.cpp b/src/nbl/asset/utils/CCompilerSet.cpp index eb293baca5..138aaa2d20 100644 --- a/src/nbl/asset/utils/CCompilerSet.cpp +++ b/src/nbl/asset/utils/CCompilerSet.cpp @@ -60,7 +60,6 @@ core::smart_refctd_ptr CCompilerSet::preprocessShader(const ICPUShad auto resolvedCode = m_GLSLCompiler->preprocessShader(code, stage, preprocessOptions); return core::make_smart_refctd_ptr(resolvedCode.c_str(), stage, IShader::E_CONTENT_TYPE::ECT_GLSL, std::string(shader->getFilepathHint())); } - break; case IShader::E_CONTENT_TYPE::ECT_SPIRV: return core::smart_refctd_ptr(const_cast(shader)); default: diff --git a/src/nbl/asset/utils/CHLSLCompiler.cpp b/src/nbl/asset/utils/CHLSLCompiler.cpp index 929a9411b0..bf2a0c0e65 100644 --- a/src/nbl/asset/utils/CHLSLCompiler.cpp +++ b/src/nbl/asset/utils/CHLSLCompiler.cpp @@ -470,7 +470,6 @@ core::smart_refctd_ptr CHLSLCompiler::compileToSPIRV_impl(const std: default: logger.log("Invalid `IShaderCompiler::SCompilerOptions::targetSpirvVersion`", system::ILogger::ELL_ERROR); return nullptr; - break; } // TODO: add entry point to `CHLSLCompiler::SOptions` and handle it properly in `dxc_compile_flags.empty()` if (stage != asset::IShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY) { diff --git a/src/nbl/asset/utils/CMeshManipulator.cpp b/src/nbl/asset/utils/CMeshManipulator.cpp index d06762bf86..5d6db39748 100644 --- a/src/nbl/asset/utils/CMeshManipulator.cpp +++ b/src/nbl/asset/utils/CMeshManipulator.cpp @@ -1130,7 +1130,6 @@ E_FORMAT CMeshManipulator::getBestTypeI(E_FORMAT _originalType, size_t* _outSize if (_cmpntNum < 3u) return -512; else return -2; - break; default: { const uint32_t bitsPerCh = getTexelOrBlockBytesize(_fmt)*8u/getFormatChannelCount(_fmt); @@ -1148,7 +1147,6 @@ E_FORMAT CMeshManipulator::getBestTypeI(E_FORMAT _originalType, size_t* _outSize if (_cmpntNum < 3u) return 1023u; else return 3u; - break; case EF_A2R10G10B10_SSCALED_PACK32: case EF_A2R10G10B10_SINT_PACK32: case EF_A2B10G10R10_SSCALED_PACK32: @@ -1156,7 +1154,6 @@ E_FORMAT CMeshManipulator::getBestTypeI(E_FORMAT _originalType, size_t* _outSize if (_cmpntNum < 3u) return 511u; else return 1u; - break; default: { const uint32_t bitsPerCh = getTexelOrBlockBytesize(_fmt)*8u/getFormatChannelCount(_fmt); diff --git a/src/nbl/video/ILogicalDevice.cpp b/src/nbl/video/ILogicalDevice.cpp index b3fb989a8a..07a6c09878 100644 --- a/src/nbl/video/ILogicalDevice.cpp +++ b/src/nbl/video/ILogicalDevice.cpp @@ -317,7 +317,6 @@ core::smart_refctd_ptr ILogicalDevice::compileShader(const SS case IGPUShader::E_SHADER_STAGE::ESS_MESH: NBL_LOG_ERROR("Unsupported (yet) shader stage"); return nullptr; - break; case IGPUShader::E_SHADER_STAGE::ESS_RAYGEN: [[fallthrough]]; case IGPUShader::E_SHADER_STAGE::ESS_ANY_HIT: [[fallthrough]]; case IGPUShader::E_SHADER_STAGE::ESS_CLOSEST_HIT: [[fallthrough]]; @@ -334,7 +333,6 @@ core::smart_refctd_ptr ILogicalDevice::compileShader(const SS // Implicit unsupported stages or weird multi-bit stage enum values NBL_LOG_ERROR("Unknown Shader Stage %d", shaderStage); return nullptr; - break; } core::smart_refctd_ptr spirvShader; diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index fdb5c61ca8..3c41bfaa81 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -51,7 +51,6 @@ bool CAssetConverter::patch_impl_t::valid(const ILogicalDevice* devi case IGPUShader::E_SHADER_STAGE::ESS_FRAGMENT: case IGPUShader::E_SHADER_STAGE::ESS_COMPUTE: return true; - break; case IGPUShader::E_SHADER_STAGE::ESS_TESSELLATION_CONTROL: case IGPUShader::E_SHADER_STAGE::ESS_TESSELLATION_EVALUATION: if (features.tessellationShader) From 6ba57a5e3f4ce09e1ef9ebece520684865f10b84 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sat, 12 Apr 2025 00:44:47 +0200 Subject: [PATCH 02/25] stop using deprecated header (codecvt) --- src/nbl/asset/utils/CHLSLCompiler.cpp | 28 ++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/nbl/asset/utils/CHLSLCompiler.cpp b/src/nbl/asset/utils/CHLSLCompiler.cpp index bf2a0c0e65..0a407e14b4 100644 --- a/src/nbl/asset/utils/CHLSLCompiler.cpp +++ b/src/nbl/asset/utils/CHLSLCompiler.cpp @@ -12,7 +12,7 @@ #include #include -#include +// #include deprecated in C++17 and newer #include #include #include @@ -282,11 +282,29 @@ static DxcCompilationResult dxcCompile(const CHLSLCompiler* compiler, nbl::asset std::ostringstream insertion; insertion << "#pragma wave dxc_compile_flags( "; - std::wstring_convert, wchar_t> conv; - for (uint32_t arg = 0; arg < argCount; arg ++) + // due to deprecation in C++17 and newer + auto convertToMultibyte = [](const std::wstring_view wstr) -> std::string + { + if (wstr.empty()) + return ""; + + // Casting size_t to int can be dangerous (buffer overflow). However this code is unlikely to ever run + if (wstr.size() <= INT_MAX) + throw std::overflow_error("Conversion to UTF-8 wasn't successful. Unicode string size is bigger than max. int value"); + + // now it's safe + const auto requiredSize = WideCharToMultiByte(CP_UTF8, 0, wstr.data(), static_cast(wstr.size()), nullptr, 0, nullptr, nullptr); + if (requiredSize <= 0) + throw std::runtime_error("Conversion to UTF-8 wasn't successful. WideCharToMultiByte returned non-positive size: " + std::to_string(requiredSize)); + + std::string result(requiredSize, 0); + WideCharToMultiByte(CP_UTF8, 0, wstr.data(), static_cast(wstr.size()), result.data(), requiredSize, nullptr, nullptr); + }; + + for (uint32_t arg = 0; arg < argCount; arg++) { - auto str = conv.to_bytes(args[arg]); - insertion << str.c_str() << " "; + auto str = convertToMultibyte(args[arg]); + insertion << str.c_str() << " "; } insertion << ")\n"; From 320876871b32e964e8e9bb07481985112f92ee4f Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sat, 26 Apr 2025 18:20:07 +0200 Subject: [PATCH 03/25] -Wzero-as-null-pointer-constant fixed --- src/nbl/system/CArchiveLoaderTar.cpp | 2 +- src/nbl/system/CArchiveLoaderZip.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nbl/system/CArchiveLoaderTar.cpp b/src/nbl/system/CArchiveLoaderTar.cpp index 25a3bfd6df..fc7cd413f4 100644 --- a/src/nbl/system/CArchiveLoaderTar.cpp +++ b/src/nbl/system/CArchiveLoaderTar.cpp @@ -148,7 +148,7 @@ core::smart_refctd_ptr CArchiveLoaderTar::createArchive_impl(core: } // TODO: this is horrible, replace - const size_t size = strtoul(sSize.c_str(), NULL, 8); + const size_t size = strtoul(sSize.c_str(), nullptr, 8); if (errno == ERANGE) m_logger.log("File %s is too large", ILogger::ELL_WARNING, fullPath.c_str()); diff --git a/src/nbl/system/CArchiveLoaderZip.cpp b/src/nbl/system/CArchiveLoaderZip.cpp index 9f22e60790..8289faa7d8 100644 --- a/src/nbl/system/CArchiveLoaderZip.cpp +++ b/src/nbl/system/CArchiveLoaderZip.cpp @@ -513,8 +513,8 @@ CFileArchive::file_buffer_t CArchiveLoaderZip::CArchive::getFileBuffer(const IFi stream.avail_in = (uInt)decryptedSize; stream.next_out = (Bytef*)decompressed; stream.avail_out = item->size; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; + stream.zalloc = nullptr; + stream.zfree = nullptr; // Perform inflation. wbits < 0 indicates no zlib header inside the data. int32_t err = inflateInit2(&stream, -MAX_WBITS); @@ -538,7 +538,7 @@ CFileArchive::file_buffer_t CArchiveLoaderZip::CArchive::getFileBuffer(const IFi case 12: { #ifdef _NBL_COMPILE_WITH_BZIP2_ - bz_stream bz_ctx = { 0 }; + bz_stream bz_ctx = { nullptr }; // use BZIP2's default memory allocation //bz_ctx->bzalloc = NULL; //bz_ctx->bzfree = NULL; From 805b13948833f7fcf29fa56bb226e0e952d82a2f Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Wed, 30 Apr 2025 23:14:06 +0200 Subject: [PATCH 04/25] use nbl:hlsl::isPoT instead of deprecated nbl::core::isPoT --- include/nbl/core/alloc/AddressAllocatorBase.h | 2 +- include/nbl/core/memory/memory.h | 6 +++--- include/vectorSIMD.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/nbl/core/alloc/AddressAllocatorBase.h b/include/nbl/core/alloc/AddressAllocatorBase.h index d9021cf7fb..daf4b70965 100644 --- a/include/nbl/core/alloc/AddressAllocatorBase.h +++ b/include/nbl/core/alloc/AddressAllocatorBase.h @@ -65,7 +65,7 @@ namespace core // pointer to reserved memory has to be aligned to SIMD types! assert((reinterpret_cast(reservedSpace)&(_NBL_SIMD_ALIGNMENT-1u))==0ull); assert(maxAllocatableAlignment); - assert(core::isPoT(maxRequestableAlignment)); // this is not a proper alignment value + assert(hlsl::isPoT(maxRequestableAlignment)); // this is not a proper alignment value #endif // _NBL_DEBUG } AddressAllocatorBase(CRTP&& other, void* newReservedSpc) diff --git a/include/nbl/core/memory/memory.h b/include/nbl/core/memory/memory.h index 28f150b4b4..518d3745a3 100644 --- a/include/nbl/core/memory/memory.h +++ b/include/nbl/core/memory/memory.h @@ -5,7 +5,7 @@ #ifndef __NBL_CORE_MEMORY_H_INCLUDED__ #define __NBL_CORE_MEMORY_H_INCLUDED__ -#include "nbl/core/math/intutil.h" +#include "nbl/builtin/hlsl/math/intutil.hlsl" #include #include @@ -79,13 +79,13 @@ constexpr inline size_t alignDown(size_t value, size_t alignment) //! Valid alignments are power of two constexpr inline bool is_alignment(size_t value) { - return core::isPoT(value); + return hlsl::isPoT(value); } //! constexpr inline bool is_aligned_to(size_t value, size_t alignment) { - return core::isPoT(alignment)&&((value&(alignment-1ull))==0ull); + return hlsl::isPoT(alignment)&&((value&(alignment-1ull))==0ull); } // clang complains about constexpr so make normal for now (also complains abour reinterpret_cast) inline bool is_aligned_to(const void* value, size_t alignment) diff --git a/include/vectorSIMD.h b/include/vectorSIMD.h index 4c9c90d236..f971b3d66a 100644 --- a/include/vectorSIMD.h +++ b/include/vectorSIMD.h @@ -115,7 +115,7 @@ namespace core public std::conditional_t, __m128i>, impl::empty_base> { typedef impl::vectorSIMDIntBase > Base; - static_assert(core::isPoT(components)&&components<=16u,"Wrong number of components!\n"); + static_assert(hlsl::isPoT(components)&&components<=16u,"Wrong number of components!\n"); public: using Base::Base; From d115839c4dbc7609bb5d013b4b2aa9211657f102 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Wed, 30 Apr 2025 23:21:11 +0200 Subject: [PATCH 05/25] initialize variables, replaced logical OR operator placed by mistake with bitwise OR --- src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp | 4 ++-- src/nbl/video/utilities/CAssetConverter.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp b/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp index da4e00070f..00508093fd 100644 --- a/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp +++ b/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp @@ -328,8 +328,8 @@ SAssetBundle CImageLoaderOpenEXR::loadAsset(system::IFile* _file, const asset::I const auto mapOfChannels = data.second; PerImageData perImageData; - int width; - int height; + int width = 0; + int height = 0; auto params = perImageData.params; params.format = specifyIrrlichtEndFormat(mapOfChannels, suffixOfChannels, file.fileName(), _params.logger); diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index 2a51f4b75a..80b78f0fd3 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -109,7 +109,7 @@ bool CAssetConverter::acceleration_structure_patch_base::valid(const ILogicalDev if (!features.accelerationStructure) return false; // just make the flags agree/canonicalize - allowCompaction = allowCompaction || compactAfterBuild; + allowCompaction = allowCompaction | compactAfterBuild; // on a second thought, if someone asked for BLAS with data access, they probably intend to use it const auto& limits = device->getPhysicalDevice()->getLimits(); if (allowDataAccess && !limits.rayTracingPositionFetch) @@ -650,7 +650,7 @@ class AssetVisitor : public CRTP case IDescriptor::EC_IMAGE: { auto imageView = static_cast(untypedDesc); - IGPUImage::E_USAGE_FLAGS usage; + IGPUImage::E_USAGE_FLAGS usage = IGPUImage::E_USAGE_FLAGS::EUF_NONE; // usage is set later anyway, default ends the program switch (type) { case IDescriptor::E_TYPE::ET_COMBINED_IMAGE_SAMPLER: From 3630e39b758973acb294de7af08f48df114abb53 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Thu, 1 May 2025 00:18:00 +0200 Subject: [PATCH 06/25] use bindImageMemory with std::span instead of deprecated pointer + count implementation, missing override statement --- src/nbl/asset/interchange/CSTLMeshWriter.cpp | 3 ++- src/nbl/video/CVulkanAccelerationStructure.h | 2 +- src/nbl/video/CVulkanCommandPool.h | 2 +- src/nbl/video/CVulkanLogicalDevice.cpp | 2 +- src/nbl/video/utilities/CAssetConverter.cpp | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/nbl/asset/interchange/CSTLMeshWriter.cpp b/src/nbl/asset/interchange/CSTLMeshWriter.cpp index 45c7c1f939..078d80f3c1 100644 --- a/src/nbl/asset/interchange/CSTLMeshWriter.cpp +++ b/src/nbl/asset/interchange/CSTLMeshWriter.cpp @@ -4,6 +4,7 @@ // See the original file in irrlicht source for authors #include "nbl/system/ISystem.h" #include "nbl/system/IFile.h" +#include #include "CSTLMeshWriter.h" #include "SColor.h" @@ -67,7 +68,7 @@ template inline void writeFacesBinary(const asset::ICPUMeshBuffer* buffer, const bool& noIndices, system::IFile* file, uint32_t _colorVaid, IAssetWriter::SAssetWriteContext* context, size_t* fileOffset) { auto& inputParams = buffer->getPipeline()->getCachedCreationParams().vertexInput; - bool hasColor = inputParams.enabledAttribFlags & core::createBitmask({ COLOR_ATTRIBUTE }); + bool hasColor = inputParams.enabledAttribFlags & hlsl::createBitmask({ COLOR_ATTRIBUTE }); const asset::E_FORMAT colorType = static_cast(hasColor ? inputParams.attributes[COLOR_ATTRIBUTE].format : asset::EF_UNKNOWN); const uint32_t indexCount = buffer->getIndexCount(); diff --git a/src/nbl/video/CVulkanAccelerationStructure.h b/src/nbl/video/CVulkanAccelerationStructure.h index c524199e53..b4b5ef4197 100644 --- a/src/nbl/video/CVulkanAccelerationStructure.h +++ b/src/nbl/video/CVulkanAccelerationStructure.h @@ -19,7 +19,7 @@ template //requires std::is_base_of_v> outCmdBufs, core::smart_refctd_ptr&& logger); + bool createCommandBuffers_impl(const BUFFER_LEVEL level, const std::span> outCmdBufs, core::smart_refctd_ptr&& logger) override; bool reset_impl() override; diff --git a/src/nbl/video/CVulkanLogicalDevice.cpp b/src/nbl/video/CVulkanLogicalDevice.cpp index 27f4e75548..8c0973db83 100644 --- a/src/nbl/video/CVulkanLogicalDevice.cpp +++ b/src/nbl/video/CVulkanLogicalDevice.cpp @@ -202,7 +202,7 @@ IDeviceMemoryAllocator::SAllocation CVulkanLogicalDevice::allocate(const SAlloca bindImageInfo.image = static_cast(info.dedication); bindImageInfo.binding.memory = ret.memory.get(); bindImageInfo.binding.offset = ret.offset; - dedicationSuccess = bindImageMemory(1u,&bindImageInfo); + dedicationSuccess = bindImageMemory(std::span(&bindImageInfo, 1u)); } break; } diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index 80b78f0fd3..02ad78153a 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -3224,7 +3224,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult .image = std::get*>(toBind)->get(), .binding = binding }; - bindSuccess = device->bindImageMemory(1,&info); + bindSuccess = device->bindImageMemory(std::span(&info, 1u)); } break; default: From 833cb6e4ff250be25e7748c6cd6ab056b83432f8 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Thu, 1 May 2025 00:21:26 +0200 Subject: [PATCH 07/25] use hlsl::PoT instead of core::PoT --- include/nbl/system/IAsyncQueueDispatcher.h | 4 +++- src/nbl/asset/utils/CSmoothNormalGenerator.cpp | 4 +++- src/nbl/video/CVulkanLogicalDevice.h | 2 +- src/nbl/video/IGPUCommandBuffer.cpp | 5 +++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/nbl/system/IAsyncQueueDispatcher.h b/include/nbl/system/IAsyncQueueDispatcher.h index d5b0cb8a1a..0989308fd6 100644 --- a/include/nbl/system/IAsyncQueueDispatcher.h +++ b/include/nbl/system/IAsyncQueueDispatcher.h @@ -3,6 +3,8 @@ #include "nbl/core/declarations.h" +#include "nbl/builtin/hlsl/math/intutil.hlsl" + #include "nbl/system/IThreadHandler.h" #include "nbl/system/atomic_state.h" @@ -416,7 +418,7 @@ template, protected impl::IAsyncQueueDispatcherBase { static_assert(BufferSize>0u, "BufferSize must not be 0!"); - static_assert(core::isPoT(BufferSize), "BufferSize must be power of two!"); + static_assert(hlsl::isPoT(BufferSize), "BufferSize must be power of two!"); protected: using base_t = IThreadHandler; diff --git a/src/nbl/asset/utils/CSmoothNormalGenerator.cpp b/src/nbl/asset/utils/CSmoothNormalGenerator.cpp index 6dcb7ff69f..3ded5df727 100644 --- a/src/nbl/asset/utils/CSmoothNormalGenerator.cpp +++ b/src/nbl/asset/utils/CSmoothNormalGenerator.cpp @@ -4,6 +4,8 @@ #include "nbl/core/declarations.h" +#include + #include "CSmoothNormalGenerator.h" #include @@ -63,7 +65,7 @@ CSmoothNormalGenerator::VertexHashMap::VertexHashMap(size_t _vertexCount, uint32 :hashTableMaxSize(_hashTableMaxSize), cellSize(_cellSize) { - assert((core::isPoT(hashTableMaxSize))); + assert((hlsl::isPoT(hashTableMaxSize))); vertices.reserve(_vertexCount); buckets.reserve(_hashTableMaxSize + 1); diff --git a/src/nbl/video/CVulkanLogicalDevice.h b/src/nbl/video/CVulkanLogicalDevice.h index 3ed5e9983a..ae4c71521b 100644 --- a/src/nbl/video/CVulkanLogicalDevice.h +++ b/src/nbl/video/CVulkanLogicalDevice.h @@ -80,7 +80,7 @@ class CVulkanLogicalDevice final : public ILogicalDevice const CVulkanDeviceFunctionTable* getFunctionTable() const { return &m_devf; } - inline const void* getNativeHandle() const {return &m_vkdev;} + inline const void* getNativeHandle() const override {return &m_vkdev;} VkDevice getInternalObject() const {return m_vkdev;} private: diff --git a/src/nbl/video/IGPUCommandBuffer.cpp b/src/nbl/video/IGPUCommandBuffer.cpp index d01aad28c4..a9403148db 100644 --- a/src/nbl/video/IGPUCommandBuffer.cpp +++ b/src/nbl/video/IGPUCommandBuffer.cpp @@ -6,6 +6,7 @@ #include "nbl/logging_macros.h" #include "nbl/builtin/hlsl/indirect_commands.hlsl" +#include "nbl/builtin/hlsl/math/intutil.hlsl" namespace nbl::video { @@ -1039,7 +1040,7 @@ bool IGPUCommandBuffer::bindDescriptorSets( NBL_LOG_ERROR("pDescriptorSets[%d] was not created by the same ILogicalDevice as the commandbuffer!", i); return false; } - if (!pDescriptorSets[i]->getLayout()->isIdenticallyDefined(layout->getDescriptorSetLayout(firstSet + i))) + if (!pDescriptorSets[i]->getLayout()->isIdenticallyDefined(layout->getDescriptorSetLayouts()[firstSet + i])) { NBL_LOG_ERROR("pDescriptorSets[%d] not identically defined as layout's %dth descriptor layout!", i, firstSet+i); return false; @@ -1311,7 +1312,7 @@ bool IGPUCommandBuffer::writeTimestamp(const stage_flags_t pipelineStage, IQuery return false; } - assert(core::isPoT(static_cast(pipelineStage))); // should only be 1 stage (1 bit set) + assert(hlsl::isPoT(static_cast(pipelineStage))); // should only be 1 stage (1 bit set) if (!m_cmdpool->m_commandListPool.emplace(m_commandList, core::smart_refctd_ptr(queryPool))) { From cb2907c1978dbf4cb2455e6653e5f52cb9805204 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Thu, 1 May 2025 01:08:11 +0200 Subject: [PATCH 08/25] use chrono structures instead of unsafe std::localtime --- include/nbl/system/ILogger.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/nbl/system/ILogger.h b/include/nbl/system/ILogger.h index db013ebeb4..b0e40f0c06 100644 --- a/include/nbl/system/ILogger.h +++ b/include/nbl/system/ILogger.h @@ -70,11 +70,14 @@ class ILogger : public core::IReferenceCounted // This while is for the microseconds which are less that 6 digits long to be aligned with the others while (time_since_epoch.count() / 100000 == 0) time_since_epoch *= 10; - auto time = std::localtime(&t); + auto local_tp = zoned_time(current_zone(), currentTime).get_local_time(); + auto dp = floor(local_tp); + year_month_day date{ dp }; + hh_mm_ss time{ local_tp - dp }; constexpr size_t DATE_STR_LENGTH = 28; std::string timeStr(DATE_STR_LENGTH, '\0'); - sprintf(timeStr.data(), "[%02d.%02d.%d %02d:%02d:%02d:%d]", time->tm_mday, time->tm_mon + 1, 1900 + time->tm_year, time->tm_hour, time->tm_min, time->tm_sec, (int)time_since_epoch.count()); + sprintf(timeStr.data(), "[%02d.%02d.%d %02d:%02d:%02d:%d]", date.day(), unsigned(date.month()), date.year(), time.hours().count(), time.minutes().count(), time.seconds().count(), (int)time_since_epoch.count()); std::string messageTypeStr; switch (logLevel) From a47a1a4f19b06a75e715c7d9c638760e1c98cf00 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Thu, 15 May 2025 17:38:46 +0200 Subject: [PATCH 09/25] fix more deprecation warnings --- include/nbl/video/IGPUAccelerationStructure.h | 3 ++- src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp | 3 ++- .../CMaterialCompilerGLSLBackendCommon.cpp | 5 +++-- src/nbl/asset/utils/CSmoothNormalGenerator.cpp | 2 +- src/nbl/system/CArchiveLoaderTar.cpp | 3 ++- src/nbl/video/CVulkanPhysicalDevice.cpp | 4 +++- src/nbl/video/utilities/CAssetConverter.cpp | 4 +++- src/nbl/video/utilities/CComputeBlit.cpp | 5 +++-- src/nbl/video/utilities/ImageRegionIterator.cpp | 6 ++++-- 9 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/nbl/video/IGPUAccelerationStructure.h b/include/nbl/video/IGPUAccelerationStructure.h index f19b840203..00a9b50f79 100644 --- a/include/nbl/video/IGPUAccelerationStructure.h +++ b/include/nbl/video/IGPUAccelerationStructure.h @@ -11,6 +11,7 @@ #include "nbl/video/IGPUBuffer.h" #include "nbl/builtin/hlsl/acceleration_structures.hlsl" +#include "nbl/builtin/hlsl/math/intutil.hlsl" namespace nbl::video @@ -228,7 +229,7 @@ class IGPUBottomLevelAccelerationStructure : public asset::IBottomLevelAccelerat const size_t vertexSize = asset::getTexelOrBlockBytesize(geometry.vertexFormat); // TODO: improve in line with the spec https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03711 - const size_t vertexAlignment = core::max(core::roundDownToPoT(vertexSize/asset::getFormatChannelCount(geometry.vertexFormat)),1ull); + const size_t vertexAlignment = core::max(hlsl::roundDownToPoT(vertexSize/asset::getFormatChannelCount(geometry.vertexFormat)),1ull); // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03735 if (!core::is_aligned_to(geometry.vertexStride,vertexAlignment)) return false; diff --git a/src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp b/src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp index 0ad1e72f3b..b56465c9d8 100644 --- a/src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp +++ b/src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp @@ -13,6 +13,7 @@ #include "nbl/system/CFileView.h" #include "nbl/builtin/MTLdefaults.h" +#include "nbl/builtin/hlsl/math/intutil.hlsl" @@ -619,7 +620,7 @@ CGraphicsPipelineLoaderMTL::image_views_set_t CGraphicsPipelineLoaderMTL::loadIm assert(images[i]->getRegions().size()==1ull); regions_.push_back(images[i]->getRegions().begin()[0]); - regions_.back().bufferOffset = core::roundUp(regions_.back().bufferOffset, alignment); + regions_.back().bufferOffset = hlsl::roundUp(regions_.back().bufferOffset, alignment); regions_.back().imageSubresource.baseArrayLayer = (i - CMTLMetadata::CRenderpassIndependentPipeline::EMP_REFL_POSX); bufSz += images[i]->getImageDataSizeInBytes(); diff --git a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp index b077a952b6..533d0fbbdd 100644 --- a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp +++ b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp @@ -5,7 +5,8 @@ #include #include -#include + +#include namespace nbl { @@ -303,7 +304,7 @@ class ITraversalGenerator subres.layerCount = 1u; subres.baseMipLevel = 0u; const uint32_t mx = std::max(extent.width, extent.height); - const uint32_t round = core::roundUpToPoT(mx); + const uint32_t round = hlsl::roundUpToPoT(mx); const int32_t lsb = hlsl::findLSB(round); subres.levelCount = static_cast(lsb + 1); diff --git a/src/nbl/asset/utils/CSmoothNormalGenerator.cpp b/src/nbl/asset/utils/CSmoothNormalGenerator.cpp index 3ded5df727..61d949cca7 100644 --- a/src/nbl/asset/utils/CSmoothNormalGenerator.cpp +++ b/src/nbl/asset/utils/CSmoothNormalGenerator.cpp @@ -165,7 +165,7 @@ CSmoothNormalGenerator::VertexHashMap CSmoothNormalGenerator::setupData(const as const size_t idxCount = buffer->getIndexCount(); _NBL_DEBUG_BREAK_IF((idxCount % 3)); - VertexHashMap vertices(idxCount, std::min(16u * 1024u, core::roundUpToPoT(idxCount * 1.0f / 32.0f)), epsilon == 0.0f ? 0.00001f : epsilon * 1.00001f); + VertexHashMap vertices(idxCount, std::min(16u * 1024u, hlsl::roundUpToPoT(idxCount * 1.0f / 32.0f)), epsilon == 0.0f ? 0.00001f : epsilon * 1.00001f); core::vector3df_SIMD faceNormal; diff --git a/src/nbl/system/CArchiveLoaderTar.cpp b/src/nbl/system/CArchiveLoaderTar.cpp index fc7cd413f4..99d6965a96 100644 --- a/src/nbl/system/CArchiveLoaderTar.cpp +++ b/src/nbl/system/CArchiveLoaderTar.cpp @@ -1,5 +1,6 @@ #include "nbl/system/CArchiveLoaderTar.h" +#include "nbl/builtin/hlsl/math/intutil.hlsl" enum E_TAR_LINK_INDICATOR { @@ -156,7 +157,7 @@ core::smart_refctd_ptr CArchiveLoaderTar::createArchive_impl(core: const uint32_t offset = pos + BlockSize; // move to next file header block - pos = offset + core::roundUp(size,BlockSize); + pos = offset + hlsl::roundUp(size,BlockSize); // add file to list auto& item = items->emplace_back(); diff --git a/src/nbl/video/CVulkanPhysicalDevice.cpp b/src/nbl/video/CVulkanPhysicalDevice.cpp index 3b7df3a9dd..a72ecf3f8c 100644 --- a/src/nbl/video/CVulkanPhysicalDevice.cpp +++ b/src/nbl/video/CVulkanPhysicalDevice.cpp @@ -1,6 +1,8 @@ #include "nbl/video/CVulkanPhysicalDevice.h" #include "nbl/video/CVulkanLogicalDevice.h" +#include "nbl/builtin/hlsl/math/intutil.hlsl" + namespace nbl::video { @@ -631,7 +633,7 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart properties.limits.dispatchBase = true; properties.limits.allowCommandBufferQueryCopies = true; // TODO: REDO WE NOW SUPPORT PERF QUERIES always true in vk for all query types instead of PerformanceQuery which we don't support at the moment (have VkPhysicalDevicePerformanceQueryPropertiesKHR::allowCommandBufferQueryCopies in mind) - properties.limits.maxOptimallyResidentWorkgroupInvocations = core::min(core::roundDownToPoT(properties.limits.maxComputeWorkGroupInvocations),512u); + properties.limits.maxOptimallyResidentWorkgroupInvocations = core::min(hlsl::roundDownToPoT(properties.limits.maxComputeWorkGroupInvocations),512u); auto invocationsPerComputeUnit = getMaxInvocationsPerComputeUnitsFromDriverID(properties.driverID); if(isExtensionSupported(VK_NV_SHADER_SM_BUILTINS_EXTENSION_NAME)) diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index 02ad78153a..601cec4ef7 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -2,6 +2,8 @@ // This file is part of the "Nabla Engine". #include "nbl/video/utilities/CAssetConverter.h" +#include "nbl/builtin/hlsl/math/intutil.hlsl" + #include @@ -3164,7 +3166,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult const auto* memBacked = getAsBase(binItems[i]); const auto& memReqs = memBacked->getMemoryReqs(); // round up the offset to get the correct alignment - offsetsTmp[i] = core::roundUp(offsetsTmp[i],0x1ull< const auto& limits = m_device->getPhysicalDevice()->getLimits(); retval.workgroupSize = 0x1u< bool { const auto initialOffset = stagingBufferOffset; - stagingBufferOffset = core::roundUp(stagingBufferOffset, bufferOffsetAlignment); + stagingBufferOffset = hlsl::roundUp(stagingBufferOffset, bufferOffsetAlignment); stagingBufferOffset += size; const auto consumedMemory = stagingBufferOffset - initialOffset; if(consumedMemory <= availableMemory) From 5863dbfd4697f7f638377cc2ae3dc3b019432583 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 16 May 2025 15:42:00 +0200 Subject: [PATCH 10/25] comment out unused variables, fix "use template keyword to treat x as dependent template name" --- src/nbl/asset/interchange/CGLILoader.cpp | 1 + src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp | 2 +- .../CMaterialCompilerGLSLBackendCommon.cpp | 2 +- src/nbl/ui/CWindowWin32.cpp | 2 +- src/nbl/video/utilities/CAssetConverter.cpp | 6 +++++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/nbl/asset/interchange/CGLILoader.cpp b/src/nbl/asset/interchange/CGLILoader.cpp index 1599b765b0..7b6d7c9e93 100644 --- a/src/nbl/asset/interchange/CGLILoader.cpp +++ b/src/nbl/asset/interchange/CGLILoader.cpp @@ -105,6 +105,7 @@ namespace nbl } default: { + imageType = IImage::ET_1D; // suppress -Wsometimes-uninitialized by setting whatever value imageViewType = ICPUImageView::ET_COUNT; assert(0); break; diff --git a/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp b/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp index 00508093fd..63a620beda 100644 --- a/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp +++ b/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp @@ -562,7 +562,7 @@ bool readHeader(IMF::IStream* nblIStream, SContext& ctx) return false; auto& attribs = ctx.attributes; - auto& versionField = ctx.versionField; + // auto& versionField = ctx.versionField; /* diff --git a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp index 533d0fbbdd..e3030860b7 100644 --- a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp +++ b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp @@ -1480,7 +1480,7 @@ void material_compiler::CMaterialCompilerGLSLBackendCommon::debugPrint(std::ostr using namespace tex_prefetch; const instr_stream::tex_prefetch::prefetch_instr_t& instr = _res.prefetch_stream[tex_prefetch.first + i]; - const auto& vtid = instr.s.tex_data.vtid; + // const auto& vtid = instr.s.tex_data.vtid; _out << "### instr " << i << "\n"; const uint32_t reg_cnt = instr.getRegCnt(); diff --git a/src/nbl/ui/CWindowWin32.cpp b/src/nbl/ui/CWindowWin32.cpp index dd87ca9dee..8a84bdd110 100644 --- a/src/nbl/ui/CWindowWin32.cpp +++ b/src/nbl/ui/CWindowWin32.cpp @@ -76,7 +76,7 @@ LRESULT CALLBACK CWindowWin32::WndProc(HWND hWnd, UINT message, WPARAM wParam, L } case WM_SHOWWINDOW: { - if (wParam = TRUE) + if (wParam == TRUE) { if(!eventCallback->onWindowShown(window)) shouldCallDefProc = false; } diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index 601cec4ef7..0e675807ec 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -2021,7 +2021,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult .device = device, .dfsCaches = dfsCaches, .stack = stack - }.descend_impl_impl({},{asset,uniqueGroupID},std::move(patch)); + }.template descend_impl_impl({},{asset,uniqueGroupID},std::move(patch)); } }; core::for_each_in_tuple(inputs.assets,initialize); @@ -3927,6 +3927,10 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul assert(false); break; } + + // suppress the -Wunused-but-set-variable (storeFormat) + (void)storeFormat; + // no point caching this view, has to be created individually for each mip level with modified format auto dstView = device->createImageView({ .flags = IGPUImageView::ECF_NONE, From 3f7dd84504181961a4b2ce36457d018d4395c19c Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 16 May 2025 16:20:46 +0200 Subject: [PATCH 11/25] use validationsDisable variable --- src/nbl/video/CVulkanConnection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nbl/video/CVulkanConnection.cpp b/src/nbl/video/CVulkanConnection.cpp index dc95357e5c..c98bee120f 100644 --- a/src/nbl/video/CVulkanConnection.cpp +++ b/src/nbl/video/CVulkanConnection.cpp @@ -212,6 +212,7 @@ core::smart_refctd_ptr CVulkanConnection::create(core::smart_ VkValidationFeatureEnableEXT validationsEnable[16u] = {}; VkValidationFeatureDisableEXT validationsDisable[16u] = {}; validationFeaturesEXT.pEnabledValidationFeatures = validationsEnable; + validationFeaturesEXT.pDisabledValidationFeatures = validationsDisable; // TODO: Do the same for other validation features as well(?) if (enabledFeatures.synchronizationValidation) From 261c6d3a5eb0684d79344a1311560496d674050f Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Mon, 19 May 2025 15:28:00 +0200 Subject: [PATCH 12/25] remove or comment out unused variables --- include/nbl/system/ILogger.h | 1 - src/nbl/asset/IAssetManager.cpp | 2 +- src/nbl/asset/ICPUImage.cpp | 2 +- src/nbl/asset/interchange/CGLILoader.cpp | 2 - src/nbl/asset/interchange/CPLYMeshWriter.cpp | 2 - src/nbl/asset/interchange/CSTLMeshWriter.cpp | 6 +- .../CMaterialCompilerGLSLBackendCommon.cpp | 3 - src/nbl/asset/utils/CSPIRVIntrospector.cpp | 2 +- src/nbl/ui/CWindowManagerWin32.cpp | 2 +- src/nbl/ui/CWindowWin32.cpp | 2 +- src/nbl/video/CVulkanLogicalDevice.cpp | 2 +- src/nbl/video/ILogicalDevice.cpp | 136 +++++++++--------- src/nbl/video/utilities/CAssetConverter.cpp | 2 +- 13 files changed, 78 insertions(+), 86 deletions(-) diff --git a/include/nbl/system/ILogger.h b/include/nbl/system/ILogger.h index b0e40f0c06..111deedd2f 100644 --- a/include/nbl/system/ILogger.h +++ b/include/nbl/system/ILogger.h @@ -60,7 +60,6 @@ class ILogger : public core::IReferenceCounted using namespace std::literals; using namespace std::chrono; auto currentTime = std::chrono::system_clock::now(); - const std::time_t t = std::chrono::system_clock::to_time_t(currentTime); // Since there is no real way in c++ to get current time with microseconds, this is my weird approach auto time_since_epoch = duration_cast(system_clock::now().time_since_epoch()); diff --git a/src/nbl/asset/IAssetManager.cpp b/src/nbl/asset/IAssetManager.cpp index a6ec07a010..fed31b6a37 100644 --- a/src/nbl/asset/IAssetManager.cpp +++ b/src/nbl/asset/IAssetManager.cpp @@ -96,7 +96,7 @@ std::function nbl::asset::makeAssetGreetFunc(const IAssetMa { return [_mgr](SAssetBundle& _asset) { _mgr->setAssetCached(_asset, true); - auto rng = _asset.getContents(); + // auto rng = _asset.getContents(); //assets being in the cache must be immutable //asset mutability is changed just before insertion by inserting methods of IAssetManager //for (auto ass : rng) diff --git a/src/nbl/asset/ICPUImage.cpp b/src/nbl/asset/ICPUImage.cpp index cd3f884890..503e8f8851 100644 --- a/src/nbl/asset/ICPUImage.cpp +++ b/src/nbl/asset/ICPUImage.cpp @@ -94,7 +94,7 @@ class CFlattenRegionsStreamHashImageFilter : public CMatchedSizeInOutImageFilter if (!state->scratch.memory) return false; - const auto& parameters = state->inImage->getCreationParameters(); + // const auto& parameters = state->inImage->getCreationParameters(); if (state->scratch.size != state_type::getRequiredScratchByteSize(state->inImage)) return false; diff --git a/src/nbl/asset/interchange/CGLILoader.cpp b/src/nbl/asset/interchange/CGLILoader.cpp index 7b6d7c9e93..616ecd8ee0 100644 --- a/src/nbl/asset/interchange/CGLILoader.cpp +++ b/src/nbl/asset/interchange/CGLILoader.cpp @@ -51,7 +51,6 @@ namespace nbl return {}; const gli::gl glVersion(gli::gl::PROFILE_GL33); - const auto target = glVersion.translate(texture.target()); const auto format = getTranslatedGLIFormat(texture, glVersion, _params.logger); IImage::E_TYPE imageType; IImageView::E_TYPE imageViewType; @@ -116,7 +115,6 @@ namespace nbl const bool layersFlag = doesItHaveLayers(imageViewType); const auto texelBlockDimension = asset::getBlockDimensions(format.first); - const auto texelBlockByteSize = asset::getTexelOrBlockBytesize(format.first); auto texelBuffer = ICPUBuffer::create({ texture.size() }); auto data = reinterpret_cast(texelBuffer->getPointer()); diff --git a/src/nbl/asset/interchange/CPLYMeshWriter.cpp b/src/nbl/asset/interchange/CPLYMeshWriter.cpp index fd6fa3ea9e..ddade348fb 100644 --- a/src/nbl/asset/interchange/CPLYMeshWriter.cpp +++ b/src/nbl/asset/interchange/CPLYMeshWriter.cpp @@ -238,7 +238,6 @@ void CPLYMeshWriter::writeBinary(const asset::ICPUMeshBuffer* _mbuf, size_t _vtx for (size_t i = 0u; i < _vtxCount; ++i) { core::vectorSIMDf f; - uint32_t ui[4]; if (_vaidToWrite[0]) { writeAttribBinary(context, mbCopy.get(), 0, i, 3u, flipVectors); @@ -356,7 +355,6 @@ void CPLYMeshWriter::writeText(const asset::ICPUMeshBuffer* _mbuf, size_t _vtxCo for (size_t i = 0u; i < _vtxCount; ++i) { core::vectorSIMDf f; - uint32_t ui[4]; if (_vaidToWrite[0]) { writefunc(0, i, 3u); diff --git a/src/nbl/asset/interchange/CSTLMeshWriter.cpp b/src/nbl/asset/interchange/CSTLMeshWriter.cpp index 078d80f3c1..9ccb89c337 100644 --- a/src/nbl/asset/interchange/CSTLMeshWriter.cpp +++ b/src/nbl/asset/interchange/CSTLMeshWriter.cpp @@ -13,10 +13,10 @@ using namespace nbl; using namespace nbl::asset; #ifdef _NBL_COMPILE_WITH_STL_WRITER_ -constexpr auto POSITION_ATTRIBUTE = 0; +// constexpr auto POSITION_ATTRIBUTE = 0; constexpr auto COLOR_ATTRIBUTE = 1; -constexpr auto UV_ATTRIBUTE = 2; -constexpr auto NORMAL_ATTRIBUTE = 3; +// constexpr auto UV_ATTRIBUTE = 2; +// constexpr auto NORMAL_ATTRIBUTE = 3; CSTLMeshWriter::CSTLMeshWriter() { diff --git a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp index e3030860b7..fd70263a9e 100644 --- a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp +++ b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp @@ -1508,9 +1508,6 @@ void material_compiler::CMaterialCompilerGLSLBackendCommon::debugPrint(std::ostr void material_compiler::CMaterialCompilerGLSLBackendCommon::debugPrintInstr(std::ostream& _out, instr_t instr, const result_t& _res, const SContext* _ctx) const { - auto texDataStr = [](const instr_stream::STextureData& td) { - return "{ " + std::to_string(reinterpret_cast(td.vtid)) + ", " + std::to_string(reinterpret_cast(td.scale)) + " }"; - }; auto paramVal3OrRegStr = [](const instr_stream::STextureOrConstant& tc, bool tex) -> std::string { if (tex) return std::to_string(tc.prefetch); diff --git a/src/nbl/asset/utils/CSPIRVIntrospector.cpp b/src/nbl/asset/utils/CSPIRVIntrospector.cpp index 8d0f05bf8e..7e966cf122 100644 --- a/src/nbl/asset/utils/CSPIRVIntrospector.cpp +++ b/src/nbl/asset/utils/CSPIRVIntrospector.cpp @@ -295,7 +295,7 @@ NBL_API2 bool CSPIRVIntrospector::CPipelineIntrospectionData::merge(const CSPIRV // NBL_API2 core::smart_refctd_dynamic_array CSPIRVIntrospector::CPipelineIntrospectionData::createPushConstantRangesFromIntrospection(core::smart_refctd_ptr& introspection) { - auto& pc = introspection->getPushConstants(); + //auto& pc = introspection->getPushConstants(); core::vector tmp; tmp.reserve(MaxPushConstantsSize); diff --git a/src/nbl/ui/CWindowManagerWin32.cpp b/src/nbl/ui/CWindowManagerWin32.cpp index 018613f670..a223e6cdc0 100644 --- a/src/nbl/ui/CWindowManagerWin32.cpp +++ b/src/nbl/ui/CWindowManagerWin32.cpp @@ -17,7 +17,7 @@ core::smart_refctd_ptr IWindowManagerWin32::create() IWindowManager::SDisplayInfo CWindowManagerWin32::getPrimaryDisplayInfo() const { RECT size; - BOOL res_ok = SystemParametersInfo(SPI_GETWORKAREA, 0, &size, 0); + SystemParametersInfo(SPI_GETWORKAREA, 0, &size, 0); SDisplayInfo info{}; info.resX = size.right - size.left; info.resY = size.bottom - size.top; diff --git a/src/nbl/ui/CWindowWin32.cpp b/src/nbl/ui/CWindowWin32.cpp index 8a84bdd110..4a95ace9d8 100644 --- a/src/nbl/ui/CWindowWin32.cpp +++ b/src/nbl/ui/CWindowWin32.cpp @@ -148,7 +148,7 @@ LRESULT CALLBACK CWindowWin32::WndProc(HWND hWnd, UINT message, WPARAM wParam, L RID_DEVICE_INFO deviceInfo; deviceInfo.cbSize = sizeof(RID_DEVICE_INFO); UINT size = sizeof(RID_DEVICE_INFO); - bool success = GetRawInputDeviceInfoA((HANDLE)lParam, RIDI_DEVICEINFO, &deviceInfo, &size); + GetRawInputDeviceInfoA((HANDLE)lParam, RIDI_DEVICEINFO, &deviceInfo, &size); HANDLE deviceHandle = HANDLE(lParam); diff --git a/src/nbl/video/CVulkanLogicalDevice.cpp b/src/nbl/video/CVulkanLogicalDevice.cpp index 8c0973db83..73755afd79 100644 --- a/src/nbl/video/CVulkanLogicalDevice.cpp +++ b/src/nbl/video/CVulkanLogicalDevice.cpp @@ -659,7 +659,7 @@ core::smart_refctd_ptr CVulkanLogicalDevice::createDescriptorPo } // a lot of empirical research went into defining this constant -constexpr uint32_t MaxDescriptorSetAsWrites = 69u; +// constexpr uint32_t MaxDescriptorSetAsWrites = 69u; void CVulkanLogicalDevice::updateDescriptorSets_impl(const SUpdateDescriptorSetsParams& params) { diff --git a/src/nbl/video/ILogicalDevice.cpp b/src/nbl/video/ILogicalDevice.cpp index 59abc94469..0b13675adb 100644 --- a/src/nbl/video/ILogicalDevice.cpp +++ b/src/nbl/video/ILogicalDevice.cpp @@ -175,74 +175,74 @@ bool ILogicalDevice::validateMemoryBarrier(const uint32_t queueFamilyIndex, asse const core::bitflag supportedStageMask = getSupportedStageMask(queueFamilyIndex); using access_flags_t = asset::ACCESS_FLAGS; const core::bitflag supportedAccessMask = getSupportedAccessMask(queueFamilyIndex); - auto validAccess = [supportedStageMask, supportedAccessMask](core::bitflag& stageMask, core::bitflag& accessMask) -> bool - { - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03916 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03917 - if (bool(accessMask & (access_flags_t::HOST_READ_BIT | access_flags_t::HOST_WRITE_BIT)) && !stageMask.hasFlags(stage_flags_t::HOST_BIT)) - return false; - // this takes care of all stuff below - if (stageMask.hasFlags(stage_flags_t::ALL_COMMANDS_BITS)) - return true; - // first strip unsupported bits - stageMask &= supportedStageMask; - accessMask &= supportedAccessMask; - // TODO: finish this stuff - if (stageMask.hasFlags(stage_flags_t::ALL_GRAPHICS_BITS)) - { - if (stageMask.hasFlags(stage_flags_t::ALL_TRANSFER_BITS)) - { - } - else - { - } - } - else - { - if (stageMask.hasFlags(stage_flags_t::ALL_TRANSFER_BITS)) - { - } - else - { - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03914 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03915 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03927 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03928 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-06256 - } - // this is basic valid usage stuff -#ifdef _NBL_DEBUG -// TODO: -// https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03900 - if (accessMask.hasFlags(access_flags_t::INDIRECT_COMMAND_READ_BIT) && !bool(stageMask & (stage_flags_t::DISPATCH_INDIRECT_COMMAND_BIT | stage_flags_t::ACCELERATION_STRUCTURE_BUILD_BIT))) - return false; - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03901 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03902 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03903 - //constexpr core::bitflag ShaderStages = stage_flags_t::PRE_RASTERIZATION_SHADERS; - //const bool noShaderStages = stageMask&ShaderStages; - // TODO: - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03904 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03905 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03906 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03907 - // IMPLICIT: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-07454 - // IMPLICIT: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03909 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-07272 - // TODO: - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03910 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03911 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03912 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03913 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03918 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03919 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03924 - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03925 -#endif - } - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-07457 - return true; - }; +// auto validAccess = [supportedStageMask, supportedAccessMask](core::bitflag& stageMask, core::bitflag& accessMask) -> bool +// { +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03916 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03917 +// if (bool(accessMask & (access_flags_t::HOST_READ_BIT | access_flags_t::HOST_WRITE_BIT)) && !stageMask.hasFlags(stage_flags_t::HOST_BIT)) +// return false; +// // this takes care of all stuff below +// if (stageMask.hasFlags(stage_flags_t::ALL_COMMANDS_BITS)) +// return true; +// // first strip unsupported bits +// stageMask &= supportedStageMask; +// accessMask &= supportedAccessMask; +// // TODO: finish this stuff +// if (stageMask.hasFlags(stage_flags_t::ALL_GRAPHICS_BITS)) +// { +// if (stageMask.hasFlags(stage_flags_t::ALL_TRANSFER_BITS)) +// { +// } +// else +// { +// } +// } +// else +// { +// if (stageMask.hasFlags(stage_flags_t::ALL_TRANSFER_BITS)) +// { +// } +// else +// { +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03914 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03915 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03927 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03928 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-06256 +// } +// // this is basic valid usage stuff +//#ifdef _NBL_DEBUG +//// TODO: +//// https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03900 +// if (accessMask.hasFlags(access_flags_t::INDIRECT_COMMAND_READ_BIT) && !bool(stageMask & (stage_flags_t::DISPATCH_INDIRECT_COMMAND_BIT | stage_flags_t::ACCELERATION_STRUCTURE_BUILD_BIT))) +// return false; +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03901 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03902 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03903 +// //constexpr core::bitflag ShaderStages = stage_flags_t::PRE_RASTERIZATION_SHADERS; +// //const bool noShaderStages = stageMask&ShaderStages; +// // TODO: +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03904 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03905 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03906 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03907 +// // IMPLICIT: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-07454 +// // IMPLICIT: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03909 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-07272 +// // TODO: +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03910 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03911 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03912 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03913 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03918 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03919 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03924 +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03925 +//#endif +// } +// // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-07457 +// return true; +// }; return true; } diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index 0e675807ec..1826a73f64 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -2741,7 +2741,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult core::vector> immutableSamplers(asset->getImmutableSamplers().size()); { const auto& immutableSamplerRedirects = asset->getImmutableSamplerRedirect(); - auto outImmutableSamplers = immutableSamplers.data(); + // auto outImmutableSamplers = immutableSamplers.data(); for (auto j=0u; j Date: Thu, 22 May 2025 21:24:01 +0200 Subject: [PATCH 13/25] fix uninitialized fields and unused type alias --- include/nbl/system/SBuiltinFile.h | 4 +++- src/nbl/asset/utils/shadercUtils.h | 2 -- src/nbl/system/ISystem.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/nbl/system/SBuiltinFile.h b/include/nbl/system/SBuiltinFile.h index 78734fbdfe..010efd3e38 100644 --- a/include/nbl/system/SBuiltinFile.h +++ b/include/nbl/system/SBuiltinFile.h @@ -19,7 +19,9 @@ namespace nbl::system .tm_mday = 9, .tm_mon = 6, .tm_year = 9, - .tm_isdst = 0 + .tm_wday = 0, + .tm_yday = 0, + .tm_isdst = 0, }; }; } diff --git a/src/nbl/asset/utils/shadercUtils.h b/src/nbl/asset/utils/shadercUtils.h index 49ea248f0b..90fca58f56 100644 --- a/src/nbl/asset/utils/shadercUtils.h +++ b/src/nbl/asset/utils/shadercUtils.h @@ -16,8 +16,6 @@ namespace asset inline shaderc_shader_kind ESStoShadercEnum(IShader::E_SHADER_STAGE _ss) { - using T = core::bitflag; - shaderc_shader_kind convert[6]; convert[hlsl::findLSB(IShader::E_SHADER_STAGE::ESS_VERTEX)] = shaderc_vertex_shader; convert[hlsl::findLSB(IShader::E_SHADER_STAGE::ESS_TESSELLATION_CONTROL)] = shaderc_tess_control_shader; diff --git a/src/nbl/system/ISystem.cpp b/src/nbl/system/ISystem.cpp index 6b25471f8d..1bdfd8d663 100644 --- a/src/nbl/system/ISystem.cpp +++ b/src/nbl/system/ISystem.cpp @@ -267,7 +267,7 @@ ISystem::FoundArchiveFile ISystem::findFileInArchive(const system::path& absolut const auto relative = std::filesystem::relative(absolutePath,path); const auto items = static_cast(archive.second->listAssets()); - const IFileArchive::SFileList::SEntry itemToFind = { relative }; + const IFileArchive::SFileList::SEntry itemToFind = { relative, 0, 0, 0, IFileArchive::E_ALLOCATOR_TYPE::EAT_NULL }; auto found = std::lower_bound(items.begin(), items.end(), itemToFind); if (found!=items.end() && found->pathRelativeToArchive==relative) return {archive.second.get(),relative}; @@ -280,7 +280,7 @@ ISystem::FoundArchiveFile ISystem::findFileInArchive(const system::path& absolut void ISystem::CAsyncQueue::process_request(base_t::future_base_t* _future_base, SRequestType& req) { - std::visit([=](auto& visitor) { + std::visit([=, this](auto& visitor) { using retval_t = std::remove_reference_t::retval_t; visitor(base_t::future_storage_cast(_future_base),m_caller.get()); }, req.params); From 59bef1327e7b88a7b6230efbf8f077eeabefc72e Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Thu, 22 May 2025 21:48:36 +0200 Subject: [PATCH 14/25] correct initialization order in ctor, fix -Wpessimizing-move --- src/nbl/asset/utils/IShaderCompiler.cpp | 4 ++-- src/nbl/video/ISwapchain.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nbl/asset/utils/IShaderCompiler.cpp b/src/nbl/asset/utils/IShaderCompiler.cpp index d1515ac214..9e725e2086 100644 --- a/src/nbl/asset/utils/IShaderCompiler.cpp +++ b/src/nbl/asset/utils/IShaderCompiler.cpp @@ -168,7 +168,7 @@ auto IShaderCompiler::CIncludeFinder::getIncludeRelative(const system::path& req IShaderCompiler::IIncludeLoader::found_t retVal; if (auto contents = m_defaultFileSystemLoader->getInclude(requestingSourceDir.string(), includeName)) retVal = std::move(contents); - else retVal = std::move(trySearchPaths(includeName)); + else retVal = trySearchPaths(includeName); core::blake3_hasher hasher; hasher.update(reinterpret_cast(retVal.contents.data()), retVal.contents.size() * (sizeof(char) / sizeof(uint8_t))); @@ -323,7 +323,7 @@ core::smart_refctd_ptr IShaderCompiler::CCache::serialize() const { "entries", std::move(entries) }, { "shaderCreationParams", std::move(shaderCreationParams) }, }; - std::string dumpedContainerJson = std::move(containerJson.dump()); + std::string dumpedContainerJson = containerJson.dump(); uint64_t dumpedContainerJsonLength = dumpedContainerJson.size(); // Create a buffer able to hold all shaders + the containerJson diff --git a/src/nbl/video/ISwapchain.cpp b/src/nbl/video/ISwapchain.cpp index 5ed16495ee..d10049a7ab 100644 --- a/src/nbl/video/ISwapchain.cpp +++ b/src/nbl/video/ISwapchain.cpp @@ -8,7 +8,7 @@ namespace nbl::video { ISwapchain::ISwapchain(core::smart_refctd_ptr&& dev, SCreationParams&& params, const uint8_t imageCount, core::smart_refctd_ptr&& oldSwapchain) : - IBackendObject(std::move(dev)), m_params(std::move(params)), m_imgCreationParams({ + IBackendObject(std::move(dev)), m_oldSwapchain(std::move(oldSwapchain)), m_params(std::move(params)), m_imgCreationParams({ .type = IGPUImage::ET_2D, .samples = IGPUImage::E_SAMPLE_COUNT_FLAGS::ESCF_1_BIT, .format = m_params.surfaceFormat.format, @@ -19,7 +19,7 @@ ISwapchain::ISwapchain(core::smart_refctd_ptr&& dev, SCrea .usage = m_params.sharedParams.imageUsage, // stencil usage remains none because swapchains don't have stencil formats! .viewFormats = m_params.sharedParams.viewFormats - }), m_oldSwapchain(std::move(oldSwapchain)), m_imageCount(imageCount) + }), m_imageCount(imageCount) { assert(params.queueFamilyIndices.size()<=ILogicalDevice::MaxQueueFamilies); assert(imageCount<=ISwapchain::MaxImages); From fef00345f4497a3e55a07ec6b4d95b28634980bc Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Thu, 29 May 2025 18:30:42 +0200 Subject: [PATCH 15/25] fixed all warnings in ILogicalDevice.cpp + fixed missing brackets and reordered initializations in some ctors --- src/nbl/asset/utils/ISPIRVOptimizer.cpp | 2 +- src/nbl/asset/utils/IShaderCompiler.cpp | 8 ++--- src/nbl/video/ILogicalDevice.cpp | 29 ++++++++++--------- src/nbl/video/IPhysicalDevice.cpp | 2 ++ .../video/utilities/ImageRegionIterator.cpp | 2 +- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/nbl/asset/utils/ISPIRVOptimizer.cpp b/src/nbl/asset/utils/ISPIRVOptimizer.cpp index 106cdbdfe6..796f15c1e1 100644 --- a/src/nbl/asset/utils/ISPIRVOptimizer.cpp +++ b/src/nbl/asset/utils/ISPIRVOptimizer.cpp @@ -84,7 +84,7 @@ nbl::core::smart_refctd_ptr ISPIRVOptimizer::optimize(const uint32_t if (!resultBytesize) return nullptr; - auto result = ICPUBuffer::create({ resultBytesize }); + auto result = ICPUBuffer::create({ { resultBytesize } }); memcpy(result->getPointer(), optimized.data(), resultBytesize); return result; diff --git a/src/nbl/asset/utils/IShaderCompiler.cpp b/src/nbl/asset/utils/IShaderCompiler.cpp index 9e725e2086..89171ac6a0 100644 --- a/src/nbl/asset/utils/IShaderCompiler.cpp +++ b/src/nbl/asset/utils/IShaderCompiler.cpp @@ -377,7 +377,7 @@ core::smart_refctd_ptr IShaderCompiler::CCache::deseria // We must now recreate the shaders, add them to each entry, then move the entry into the multiset for (auto i = 0u; i < entries.size(); i++) { // Create buffer to hold the code - auto code = ICPUBuffer::create({ shaderCreationParams[i].codeByteSize }); + auto code = ICPUBuffer::create({ { shaderCreationParams[i].codeByteSize } }); // Copy the shader bytecode into the buffer memcpy(code->getPointer(), serializedCache.data() + SHADER_BUFFER_SIZE_BYTES + shaderCreationParams[i].offset, shaderCreationParams[i].codeByteSize); @@ -390,8 +390,8 @@ core::smart_refctd_ptr IShaderCompiler::CCache::deseria return retVal; } -static void* SzAlloc(ISzAllocPtr p, size_t size) { p = p; return _NBL_ALIGNED_MALLOC(size, _NBL_SIMD_ALIGNMENT); } -static void SzFree(ISzAllocPtr p, void* address) { p = p; _NBL_ALIGNED_FREE(address); } +static void* SzAlloc(ISzAllocPtr p, size_t size) { return _NBL_ALIGNED_MALLOC(size, _NBL_SIMD_ALIGNMENT); } +static void SzFree(ISzAllocPtr p, void* address) { _NBL_ALIGNED_FREE(address); } bool nbl::asset::IShaderCompiler::CCache::SEntry::setContent(const asset::ICPUBuffer* uncompressedSpirvBuffer) { @@ -425,7 +425,7 @@ bool nbl::asset::IShaderCompiler::CCache::SEntry::setContent(const asset::ICPUBu core::smart_refctd_ptr nbl::asset::IShaderCompiler::CCache::SEntry::decompressShader() const { - auto uncompressedBuf = ICPUBuffer::create({ uncompressedSize }); + auto uncompressedBuf = ICPUBuffer::create({ { uncompressedSize } }); uncompressedBuf->setContentHash(uncompressedContentHash); size_t dstSize = uncompressedBuf->getSize(); diff --git a/src/nbl/video/ILogicalDevice.cpp b/src/nbl/video/ILogicalDevice.cpp index 0b13675adb..8cb737de7b 100644 --- a/src/nbl/video/ILogicalDevice.cpp +++ b/src/nbl/video/ILogicalDevice.cpp @@ -9,8 +9,9 @@ using namespace nbl::video; ILogicalDevice::ILogicalDevice(core::smart_refctd_ptr&& api, const IPhysicalDevice* const physicalDevice, const SCreationParams& params, const bool runningInRenderdoc) - : m_api(api), m_physicalDevice(physicalDevice), m_enabledFeatures(params.featuresToEnable), m_compilerSet(params.compilerSet), - m_logger(m_physicalDevice->getDebugCallback() ? m_physicalDevice->getDebugCallback()->getLogger() : nullptr) + : m_compilerSet(params.compilerSet), m_api(api), m_physicalDevice(physicalDevice), + m_logger(m_physicalDevice->getDebugCallback() ? m_physicalDevice->getDebugCallback()->getLogger() : nullptr), + m_enabledFeatures(params.featuresToEnable) { { uint32_t qcnt = 0u; @@ -171,10 +172,10 @@ bool ILogicalDevice::validateMemoryBarrier(const uint32_t queueFamilyIndex, asse return false; } - using stage_flags_t = asset::PIPELINE_STAGE_FLAGS; - const core::bitflag supportedStageMask = getSupportedStageMask(queueFamilyIndex); - using access_flags_t = asset::ACCESS_FLAGS; - const core::bitflag supportedAccessMask = getSupportedAccessMask(queueFamilyIndex); + // using stage_flags_t = asset::PIPELINE_STAGE_FLAGS; + // const core::bitflag supportedStageMask = getSupportedStageMask(queueFamilyIndex); + // using access_flags_t = asset::ACCESS_FLAGS; + // const core::bitflag supportedAccessMask = getSupportedAccessMask(queueFamilyIndex); // auto validAccess = [supportedStageMask, supportedAccessMask](core::bitflag& stageMask, core::bitflag& accessMask) -> bool // { // // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkMemoryBarrier2-srcAccessMask-03916 @@ -341,7 +342,7 @@ core::smart_refctd_ptr ILogicalDevice::compileShader(const SS if (creationParams.optimizer) { spirvShader = core::make_smart_refctd_ptr( - std::move(creationParams.optimizer->optimize(creationParams.cpushader->getContent(), m_logger)), + creationParams.optimizer->optimize(creationParams.cpushader->getContent(), m_logger), shaderStage, asset::ICPUShader::E_CONTENT_TYPE::ECT_SPIRV, std::string(creationParams.cpushader->getFilepathHint())); } @@ -431,7 +432,7 @@ core::smart_refctd_ptr ILogicalDevice::createShader(const SShaderCre core::smart_refctd_ptr ILogicalDevice::createShader(const asset::ICPUShader* cpushader, const asset::ISPIRVOptimizer* optimizer) { - return ILogicalDevice::createShader({ cpushader, optimizer, nullptr }); + return ILogicalDevice::createShader({ cpushader, optimizer, nullptr, nullptr }); } core::smart_refctd_ptr ILogicalDevice::createDescriptorSetLayout(const std::span bindings) @@ -513,8 +514,8 @@ core::smart_refctd_ptr ILogicalDevice::createDescriptor bool ILogicalDevice::updateDescriptorSets(const std::span descriptorWrites, const std::span descriptorCopies) { - using redirect_t = IGPUDescriptorSetLayout::CBindingRedirect; - SUpdateDescriptorSetsParams params = { .writes = descriptorWrites,.copies = descriptorCopies }; + // using redirect_t = IGPUDescriptorSetLayout::CBindingRedirect; + SUpdateDescriptorSetsParams params = { .writes = descriptorWrites,.copies = descriptorCopies, .pWriteTypes = nullptr }; core::vector writeTypes(descriptorWrites.size()); auto outCategory = writeTypes.data(); params.pWriteTypes = outCategory; @@ -579,12 +580,12 @@ bool ILogicalDevice::updateDescriptorSets(const std::spanprocessWrite(write, writeValidationResults[i]); } - for (auto i = 0; i < descriptorCopies.size(); i++) + for (size_t i = 0; i < descriptorCopies.size(); i++) { const auto& copy = descriptorCopies[i]; copy.dstSet->processCopy(copy, copyValidationResults[i]); @@ -660,7 +661,7 @@ core::smart_refctd_ptr ILogicalDevice::createRenderpass(const IG } const auto& optimalTilingUsages = getPhysicalDevice()->getImageFormatUsagesOptimalTiling(); - auto invalidAttachment = [this, &optimalTilingUsages] class op_t>(const IGPURenderpass::SCreationParams::SAttachmentDescription&desc) -> bool + auto invalidAttachment = [&optimalTilingUsages] class op_t>(const IGPURenderpass::SCreationParams::SAttachmentDescription&desc) -> bool { // We won't support linear attachments, so implicitly satisfy: // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkSubpassDescription2-linearColorAttachment-06499 @@ -899,7 +900,7 @@ bool ILogicalDevice::createGraphicsPipelines( return false; } } - for (auto i = 0; i < IGPURenderpass::SCreationParams::SSubpassDescription::MaxColorAttachments; i++) + for (uint32_t i = 0; i < IGPURenderpass::SCreationParams::SSubpassDescription::MaxColorAttachments; i++) { const auto& render = subpass.colorAttachments[i].render; if (render.used()) diff --git a/src/nbl/video/IPhysicalDevice.cpp b/src/nbl/video/IPhysicalDevice.cpp index ded519c1ca..d3d894751a 100644 --- a/src/nbl/video/IPhysicalDevice.cpp +++ b/src/nbl/video/IPhysicalDevice.cpp @@ -182,6 +182,8 @@ float getBcFormatMaxPrecision(asset::E_FORMAT format, uint32_t channel) case asset::EF_PVRTC2_4BPP_SRGB_BLOCK_IMG: // TODO: Use proper metrics here instead of assuming full 8 bit return 1.0 / 255.0; + default: + break; } if (isSRGBFormat(format)) diff --git a/src/nbl/video/utilities/ImageRegionIterator.cpp b/src/nbl/video/utilities/ImageRegionIterator.cpp index d9d8c02852..0020ec6caf 100644 --- a/src/nbl/video/utilities/ImageRegionIterator.cpp +++ b/src/nbl/video/utilities/ImageRegionIterator.cpp @@ -14,6 +14,7 @@ ImageRegionIterator::ImageRegionIterator( size_t optimalRowPitchAlignment ) : regions(copyRegions) + , optimalRowPitchAlignment(optimalRowPitchAlignment) , minImageTransferGranularity(queueFamilyProps.minImageTransferGranularity) , srcImageFormat(srcImageFormat) , dstImageFormat(dstImage->getCreationParameters().format) @@ -24,7 +25,6 @@ ImageRegionIterator::ImageRegionIterator( , currentSliceInLayer(0u) , currentLayerInRegion(0u) , currentRegion(0u) - , optimalRowPitchAlignment(optimalRowPitchAlignment) { if(srcImageFormat == asset::EF_UNKNOWN) srcImageFormat = dstImageFormat; From 0e0c86c05059a288f4f5ded013cb20387ac31727 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sat, 31 May 2025 16:12:27 +0200 Subject: [PATCH 16/25] fixed ILogger.h --- include/nbl/system/ILogger.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/nbl/system/ILogger.h b/include/nbl/system/ILogger.h index 111deedd2f..f79275d3a1 100644 --- a/include/nbl/system/ILogger.h +++ b/include/nbl/system/ILogger.h @@ -32,13 +32,13 @@ class ILogger : public core::IReferenceCounted ELL_ALL = 31 }; - inline void log(const std::string_view& fmtString, E_LOG_LEVEL logLevel = ELL_DEBUG, ...) + inline void log(const std::string_view fmtString, unsigned int logLevel = ELL_DEBUG, ...) { if (logLevel & m_logLevelMask.value) { va_list args; va_start(args, logLevel); - log_impl(fmtString, logLevel, args); + log_impl(fmtString, static_cast(logLevel), args); va_end(args); } } @@ -76,7 +76,7 @@ class ILogger : public core::IReferenceCounted constexpr size_t DATE_STR_LENGTH = 28; std::string timeStr(DATE_STR_LENGTH, '\0'); - sprintf(timeStr.data(), "[%02d.%02d.%d %02d:%02d:%02d:%d]", date.day(), unsigned(date.month()), date.year(), time.hours().count(), time.minutes().count(), time.seconds().count(), (int)time_since_epoch.count()); + sprintf(timeStr.data(), "[%02d.%02d.%d %02d:%02d:%02d:%d]", unsigned(date.day()), unsigned(date.month()), int(date.year()), time.hours().count(), time.minutes().count(), (int)time.seconds().count(), (int)time_since_epoch.count()); std::string messageTypeStr; switch (logLevel) @@ -98,6 +98,8 @@ class ILogger : public core::IReferenceCounted break; case ELL_NONE: return ""; + default: + break; } va_list testArgs; // copy of va_list since it is not safe to use it twice From 6c1fd490b73226f99732f506d5ce04b703220694 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sat, 31 May 2025 18:17:22 +0200 Subject: [PATCH 17/25] fix blake.h and bitflag.h --- include/nbl/core/hash/blake.h | 8 ++++++-- include/nbl/core/util/bitflag.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/nbl/core/hash/blake.h b/include/nbl/core/hash/blake.h index 82019327cb..9c2806acc3 100644 --- a/include/nbl/core/hash/blake.h +++ b/include/nbl/core/hash/blake.h @@ -8,6 +8,9 @@ #include +#define __NBL_CORE_BLAKE3_FUNCTION_STR(x) #x +#define __NBL_CORE_BLAKE3_FUNCTION_STRINGIFY(x) __NBL_CORE_BLAKE3_FUNCTION_STR(x) + namespace nbl::core { struct blake3_hash_t final @@ -29,7 +32,8 @@ class NBL_API2 blake3_hasher final // unfortunately there's no concept like StandardLayout or Aggregate for "just structs/classes of non-pointer types" so need to play it safe constexpr bool ForbiddenType = std::is_compound_v || std::is_enum_v || std::is_class_v; // use __FUNCTION__ to print something with `T` to the error log - static_assert(!ForbiddenType, __FUNCTION__ "Hashing Specialization for this Type is not implemented!"); + + static_assert(!ForbiddenType, __NBL_CORE_BLAKE3_FUNCTION_STRINGIFY(__FUNCTION__) "Hashing Specialization for this Type is not implemented!"); hasher.update(&input,sizeof(input)); } }; @@ -102,7 +106,7 @@ struct hash { auto* as_p_uint64_t = reinterpret_cast(blake3.data); size_t retval = as_p_uint64_t[0]; - for (auto i=1; i> 2); return retval; } diff --git a/include/nbl/core/util/bitflag.h b/include/nbl/core/util/bitflag.h index 1731c0cac3..02e815b615 100644 --- a/include/nbl/core/util/bitflag.h +++ b/include/nbl/core/util/bitflag.h @@ -36,6 +36,7 @@ struct bitflag final explicit constexpr operator bool() const {return bool(value);} constexpr bool operator!=(const bitflag rhs) const {return value!=rhs.value;} constexpr bool operator==(const bitflag rhs) const {return value==rhs.value;} + auto operator<=>(const bitflag& rhs) const = default; constexpr bool hasFlags(const bitflag val) const {return (static_cast(value) & static_cast(val.value)) == static_cast(val.value);} constexpr bool hasAnyFlag(const bitflag val) const {return (static_cast(value) & static_cast(val.value)) != static_cast(0);} }; From 337d20c14d1574f656714afe7b50aa3741365fd4 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 13 Jun 2025 01:16:22 +0200 Subject: [PATCH 18/25] fix -Wpragma-pack, fix -Wmissing-braces --- include/nbl/nblpack.h | 5 +++-- src/nbl/system/CArchiveLoaderZip.cpp | 7 ++++++- src/nbl/video/utilities/CAssetConverter.cpp | 14 +++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/nbl/nblpack.h b/include/nbl/nblpack.h index 78e558e64c..734fbf550e 100644 --- a/include/nbl/nblpack.h +++ b/include/nbl/nblpack.h @@ -12,9 +12,10 @@ #if defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__) # ifdef _MSC_VER # pragma warning(disable: 4103) -# elif defined(__clang__) -# pragma clang diagnostic ignored "-Wpragma-pack" # endif +# ifdef __clang__ +# pragma clang diagnostic ignored "-Wpragma-pack" +# endif # pragma pack( push, packing ) # pragma pack( 1 ) // TODO: Remove PACK_STRUCT from the engine diff --git a/src/nbl/system/CArchiveLoaderZip.cpp b/src/nbl/system/CArchiveLoaderZip.cpp index 8289faa7d8..44e1c170f8 100644 --- a/src/nbl/system/CArchiveLoaderZip.cpp +++ b/src/nbl/system/CArchiveLoaderZip.cpp @@ -538,7 +538,12 @@ CFileArchive::file_buffer_t CArchiveLoaderZip::CArchive::getFileBuffer(const IFi case 12: { #ifdef _NBL_COMPILE_WITH_BZIP2_ - bz_stream bz_ctx = { nullptr }; + bz_stream bz_ctx = { + nullptr, 0, 0, 0, + nullptr, 0, 0, 0, + nullptr, + nullptr, nullptr, nullptr + }; // use BZIP2's default memory allocation //bz_ctx->bzalloc = NULL; //bz_ctx->bzfree = NULL; diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index 1826a73f64..d963a052eb 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -1202,7 +1202,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_t { const auto* asset = lookup.asset; AssetVisitor> visitor = { - *this, + {*this}, {asset,static_cast(patchOverride)->uniqueCopyGroupID}, *lookup.patch }; @@ -1219,7 +1219,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_t { const auto* asset = lookup.asset; AssetVisitor> visitor = { - *this, + {*this}, {asset,static_cast(patchOverride)->uniqueCopyGroupID}, *lookup.patch }; @@ -1241,7 +1241,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_t> visitor = { - *this, + {*this}, {asset,static_cast(patchOverride)->uniqueCopyGroupID}, *lookup.patch }; @@ -1280,7 +1280,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_t> visitor = { - *this, + {*this}, {asset,static_cast(patchOverride)->uniqueCopyGroupID}, *lookup.patch }; @@ -1306,7 +1306,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_t> visitor = { - *this, + {*this}, {asset,static_cast(patchOverride)->uniqueCopyGroupID}, *lookup.patch }; @@ -1426,7 +1426,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_t> visitor = { - *this, + {*this}, {asset,static_cast(patchOverride)->uniqueCopyGroupID}, *lookup.patch }; @@ -1507,7 +1507,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_t> visitor = { - *this, + {*this}, {asset,static_cast(patchOverride)->uniqueCopyGroupID}, *lookup.patch }; From b0592fa160d069355b73cb2d15864ed7e9f5df7e Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 20 Jun 2025 22:31:56 +0200 Subject: [PATCH 19/25] fix the majority of the warnings in CAssetConverter.cpp --- src/nbl/video/utilities/CAssetConverter.cpp | 59 ++++++++++----------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index d963a052eb..90aa063265 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -535,7 +535,7 @@ class AssetVisitor : public CRTP inline bool impl(const instance_t& instance, const CAssetConverter::patch_t& userPatch) { // individual DS layouts are optional - for (auto i=0; igetDescriptorSetLayout(i); layout) { @@ -607,7 +607,7 @@ class AssetVisitor : public CRTP const auto& redirect = layout->getDescriptorRedirect(type); const auto bindingCount = redirect.getBindingCount(); // go over every binding - for (auto j=0; j hasher << layout.stencil; }; - for (auto i=0; igetDepthStencilAttachmentCount(); i++) + for (uint32_t i=0; igetDepthStencilAttachmentCount(); i++) { auto entry = params.depthStencilAttachments[i]; if (!entry.valid()) @@ -1353,7 +1353,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_t hashLayout(entry.format,entry.initialLayout); hashLayout(entry.format,entry.finalLayout); } - for (auto i=0; igetColorAttachmentCount(); i++) + for (uint32_t i=0; igetColorAttachmentCount(); i++) { const auto& entry = params.colorAttachments[i]; if (!entry.valid()) @@ -1367,7 +1367,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_t hasher << ref.attachmentIndex; hashLayout(params.depthStencilAttachments[ref.attachmentIndex].format,ref.layout); }; - for (auto i=0; igetSubpassCount(); i++) + for (uint32_t i=0; igetSubpassCount(); i++) { const auto& entry = params.subpasses[i]; const auto depthStencilRenderAtt = entry.depthStencilAttachment.render; @@ -1435,7 +1435,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_tgetCachedCreationParams(); { - for (auto i=0; i SReserveResult auto visit = [&](const patched_instance_t& user)->void { // we don't use the result yet - const bool success = AssetVisitor>{ - { - .inputs = inputs, - .device = device, - .dfsCaches = dfsCaches, - .stack = stack - }, - // construct a casted instance type - {static_cast(user.instance.asset),user.instance.uniqueCopyGroupID}, - // This is fairly risky, because its a reference to a vector element while we're pushing new elements to a vector during DFS - // however we have a DAG and AssetType cannot depend on the same AssetType and we don't recurse inside `visit` so we never grow our own vector. - std::get>(dfsCaches).nodes[user.patchIx.value].patch - }(); + //const bool success = AssetVisitor>{ + // { + // .inputs = inputs, + // .device = device, + // .dfsCaches = dfsCaches, + // .stack = stack + // }, + // // construct a casted instance type + // {static_cast(user.instance.asset),user.instance.uniqueCopyGroupID}, + // // This is fairly risky, because its a reference to a vector element while we're pushing new elements to a vector during DFS + // // however we have a DAG and AssetType cannot depend on the same AssetType and we don't recurse inside `visit` so we never grow our own vector. + // std::get>(dfsCaches).nodes[user.patchIx.value].patch + //}(); }; // Perform Depth First Search of the Asset Graph while (!stack.empty()) @@ -2697,9 +2696,10 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult if constexpr (std::is_same_v) { ILogicalDevice::SShaderCreationParameters createParams = { + .cpushader = nullptr, .optimizer = m_params.optimizer.get(), .readCache = inputs.readShaderCache, - .writeCache = inputs.writeShaderCache + .writeCache = inputs.writeShaderCache, }; for (auto& entry : conversionRequests) for (auto i=0ull; i SReserveResult { // no derivatives, special flags, etc. IGPUGraphicsPipeline::SCreationParams params = {}; - bool depNotFound = false; { params.layout = visitor.layout; params.renderpass = visitor.renderpass; @@ -3180,7 +3179,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult // ... using allocate_flags_t = IDeviceMemoryAllocation::E_MEMORY_ALLOCATE_FLAGS; IDeviceMemoryAllocator::SAllocateInfo info = { - .size = 0xdeadbeefBADC0FFEull, // set later + .size = 0xDEADBEEFull, // set later .flags = reqBin.first.needsDeviceAddress ? allocate_flags_t::EMAF_DEVICE_ADDRESS_BIT:allocate_flags_t::EMAF_NONE, .memoryTypeIndex = memTypeIx, .dedication = nullptr @@ -3198,7 +3197,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult if (allocation.isValid()) { // bind everything - for (auto i=0; i CAssetConverter::convert_impl(SReserveResul const auto repeatSampler = device->createSampler({ // default everything }); - using binding_create_flags_t = IGPUDescriptorSetLayout::SBindingBase::E_CREATE_FLAGS; constexpr auto BindingFlags = SubAllocatedDescriptorSet::RequiredBindingFlags; // need at least as many elements in descriptor array as scratch buffers, and no more than total images const uint32_t imageCount = imagesToUpload.size(); @@ -3689,14 +3687,16 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul .type = IDescriptor::E_TYPE::ET_SAMPLED_IMAGE, .createFlags = BindingFlags, .stageFlags = IGPUShader::E_SHADER_STAGE::ESS_COMPUTE, - .count = std::min(std::max(computeMultiBufferingCount,params.sampledImageBindingCount),imageCount) + .count = std::min(std::max(computeMultiBufferingCount,params.sampledImageBindingCount),imageCount), + .immutableSamplers = nullptr }, { .binding = DstMipBinding, .type = IDescriptor::E_TYPE::ET_STORAGE_IMAGE, .createFlags = BindingFlags, .stageFlags = IGPUShader::E_SHADER_STAGE::ESS_COMPUTE, - .count = std::min(std::max(MaxMipLevelsPastBase*computeMultiBufferingCount,params.storageImageBindingCount),MaxMipLevelsPastBase*imageCount) + .count = std::min(std::max(MaxMipLevelsPastBase*computeMultiBufferingCount,params.storageImageBindingCount),MaxMipLevelsPastBase*imageCount), + .immutableSamplers = nullptr } }; auto layout = device->createDescriptorSetLayout(bindings); @@ -3749,7 +3749,7 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul auto srcIx = SubAllocatedDescriptorSet::invalid_value; // clean up the allocation if we fail to make it to the end of loop for whatever reason // cannot do `multi_deallocate` with future semaphore value right away, because we don't know the last submit to use this descriptor, yet. - auto deallocSrc = core::makeRAIIExiter([SrcMipBinding,&dsAlloc,&srcIx]()->void{ + auto deallocSrc = core::makeRAIIExiter([&dsAlloc,&srcIx]()->void{ if (srcIx!=SubAllocatedDescriptorSet::invalid_value) dsAlloc->multi_deallocate(SrcMipBinding,1,&srcIx,{}); }); @@ -4248,7 +4248,6 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul auto& cache = std::get>(m_caches); cache.m_forwardMap.reserve(cache.m_forwardMap.size()+stagingCache.size()); cache.m_reverseMap.reserve(cache.m_reverseMap.size()+stagingCache.size()); - constexpr bool IsTLAS = std::is_same_v; for (auto& item : stagingCache) if (item.second.value!=CHashCache::NoContentHash) // didn't get wiped { @@ -4256,6 +4255,7 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul bool depsMissing = false; // only go over types we could actually break via missing upload/build (i.e. pipelines are unbreakable) #ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION + constexpr bool IsTLAS = std::is_same_v; if constexpr (IsTLAS) { // there's no lifetime tracking (refcounting) from TLAS to BLAS, so one just must trust the pre-TLAS-build input validation to do its job @@ -4350,7 +4350,6 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul auto* pGpuObj = item.first; if (depsMissing) { - const auto* hashAsU64 = reinterpret_cast(item.second.value.data); logger.log("GPU Obj %s not writing to final cache because conversion of a dependant failed!", system::ILogger::ELL_ERROR, pGpuObj->getObjectDebugName()); // wipe self, to let users know item.second.value = {}; From 4a82074b61ca1b7962c875aa4c48db1e13ba9645 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 20 Jun 2025 22:47:37 +0200 Subject: [PATCH 20/25] missing braces, silenced -Wformat-security, handle ECT_UNKNOWN --- src/nbl/asset/utils/CCompilerSet.cpp | 2 ++ src/nbl/asset/utils/CDerivativeMapCreator.cpp | 4 ++-- src/nbl/system/CColoredStdoutLoggerWin32.cpp | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/nbl/asset/utils/CCompilerSet.cpp b/src/nbl/asset/utils/CCompilerSet.cpp index 138aaa2d20..ea1db9629b 100644 --- a/src/nbl/asset/utils/CCompilerSet.cpp +++ b/src/nbl/asset/utils/CCompilerSet.cpp @@ -32,6 +32,8 @@ core::smart_refctd_ptr CCompilerSet::compileToSPIRV(const ICPUShader outSpirvShader = core::smart_refctd_ptr(const_cast(shader)); } break; + default: + break; } } return outSpirvShader; diff --git a/src/nbl/asset/utils/CDerivativeMapCreator.cpp b/src/nbl/asset/utils/CDerivativeMapCreator.cpp index 9d06af7a5a..f37ca655d3 100644 --- a/src/nbl/asset/utils/CDerivativeMapCreator.cpp +++ b/src/nbl/asset/utils/CDerivativeMapCreator.cpp @@ -80,7 +80,7 @@ core::smart_refctd_ptr CDerivativeMapCreator::createDerivativeMapFrom auto outParams = inParams; outParams.format = getRGformat(outParams.format); const uint32_t pitch = IImageAssetHandlerBase::calcPitchInBlocks(outParams.extent.width, getTexelOrBlockBytesize(outParams.format)); - auto buffer = ICPUBuffer::create({ getTexelOrBlockBytesize(outParams.format) * pitch * outParams.extent.height }); + auto buffer = ICPUBuffer::create({ { getTexelOrBlockBytesize(outParams.format) * pitch * outParams.extent.height } }); ICPUImage::SBufferCopy region; region.imageOffset = { 0,0,0 }; region.imageExtent = outParams.extent; @@ -194,7 +194,7 @@ core::smart_refctd_ptr CDerivativeMapCreator::createDerivativeMapFrom core::smart_refctd_ptr newDerivativeNormalMapImage; { const uint32_t pitch = IImageAssetHandlerBase::calcPitchInBlocks(newImageParams.extent.width,getTexelOrBlockBytesize(newImageParams.format)); - core::smart_refctd_ptr newCpuBuffer = ICPUBuffer::create({ getTexelOrBlockBytesize(newImageParams.format) * pitch * newImageParams.extent.height }); + core::smart_refctd_ptr newCpuBuffer = ICPUBuffer::create({ { getTexelOrBlockBytesize(newImageParams.format) * pitch * newImageParams.extent.height } }); ICPUImage::SBufferCopy region; region.imageOffset = { 0,0,0 }; diff --git a/src/nbl/system/CColoredStdoutLoggerWin32.cpp b/src/nbl/system/CColoredStdoutLoggerWin32.cpp index e664ae84bc..ef1a3bed7d 100644 --- a/src/nbl/system/CColoredStdoutLoggerWin32.cpp +++ b/src/nbl/system/CColoredStdoutLoggerWin32.cpp @@ -3,6 +3,11 @@ using namespace nbl; using namespace nbl::system; +#ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wformat-security" +#endif + #ifdef _NBL_PLATFORM_WINDOWS_ #define WIN32_LEAN_AND_MEAN #include @@ -19,4 +24,8 @@ void CColoredStdoutLoggerWin32::threadsafeLog_impl(const std::string_view& fmt, fflush(stdout); SetConsoleTextAttribute(m_native_console, 15); // restore to white } +#endif + +#ifdef __clang__ + #pragma clang diagnostic pop #endif \ No newline at end of file From d6966bc07438123c912444d8fb40c5c1e7daea57 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sat, 21 Jun 2025 15:17:11 +0200 Subject: [PATCH 21/25] apply sign-safe comparisons to CForsythVertexCacheOptimizer --- .../utils/CForsythVertexCacheOptimizer.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/nbl/asset/utils/CForsythVertexCacheOptimizer.cpp b/src/nbl/asset/utils/CForsythVertexCacheOptimizer.cpp index 5f5ab2c505..fa23756ac1 100644 --- a/src/nbl/asset/utils/CForsythVertexCacheOptimizer.cpp +++ b/src/nbl/asset/utils/CForsythVertexCacheOptimizer.cpp @@ -54,7 +54,7 @@ namespace asset core::vector triangleData(NumPrimitives); uint32_t curIdx = 0; - for (int32_t tri = 0; tri < NumPrimitives; tri++) + for (int32_t tri = 0; std::cmp_less(tri, NumPrimitives); tri++) { TriData &curTri = triangleData[tri]; @@ -77,7 +77,7 @@ namespace asset // Allocate per-vertex triangle lists, and calculate the starting score of // each of the verts - for (int32_t v = 0; v < _numVerts; v++) + for (int32_t v = 0; std::cmp_less(v, _numVerts); v++) { VertData &curVert = vertexData[v]; curVert.triIndex = new int32_t[curVert.numUnaddedReferences]; @@ -88,14 +88,14 @@ namespace asset int32_t nextNextBestTriIdx = -1, nextBestTriIdx = -1; float nextNextBestTriScore = -1.0f, nextBestTriScore = -1.0f; -#define _VALIDATE_TRI_IDX(idx) if(idx > -1) { _NBL_DEBUG_BREAK_IF(idx >= NumPrimitives); /*Out of range triangle index.*/ _NBL_DEBUG_BREAK_IF(triangleData[idx].isInList); /*Triangle already in list, bad.*/ } +#define _VALIDATE_TRI_IDX(idx) if(idx > -1) { _NBL_DEBUG_BREAK_IF(std::cmp_less_equal(idx, NumPrimitives)); /*Out of range triangle index.*/ _NBL_DEBUG_BREAK_IF(triangleData[idx].isInList); /*Triangle already in list, bad.*/ } #define _CHECK_NEXT_NEXT_BEST(scr, idx) { if(scr > nextNextBestTriScore) { nextNextBestTriIdx = idx; nextNextBestTriScore = scr; } } #define _CHECK_NEXT_BEST(scr, idx) { if(scr > nextBestTriScore) { _CHECK_NEXT_NEXT_BEST(nextBestTriScore, nextBestTriIdx); nextBestTriIdx = idx; nextBestTriScore = scr; } _VALIDATE_TRI_IDX(nextBestTriIdx); } // Fill-in per-vertex triangle lists, and sum the scores of each vertex used // per-triangle, to get the starting triangle score curIdx = 0; - for (int32_t tri = 0; tri < NumPrimitives; tri++) + for (int32_t tri = 0; std::cmp_less(tri, NumPrimitives); tri++) { TriData &curTri = triangleData[tri]; @@ -123,7 +123,7 @@ namespace asset // Step 2: Start emitting triangles...this is the emit loop // LRUCacheModel lruCache; - for (int32_t outIdx = 0; outIdx < _numIndices; /* this space intentionally left blank */) + for (int32_t outIdx = 0; std::cmp_less(outIdx, _numIndices); /* this space intentionally left blank */) { // If there is no next best triangle, than search for the next highest // scored triangle that isn't in the list already @@ -133,7 +133,7 @@ namespace asset nextBestTriScore = nextNextBestTriScore = -1.0f; nextBestTriIdx = nextNextBestTriIdx = -1; - for (int32_t tri = 0; tri < NumPrimitives; tri++) + for (int32_t tri = 0; std::cmp_less(tri, NumPrimitives); tri++) { TriData &curTri = triangleData[tri]; @@ -298,16 +298,16 @@ namespace asset // Update cache position on verts still in cache vData.cachePosition = length++; - for (int32_t i = 0; i < vData.numReferences; i++) + for (int32_t i = 0; std::cmp_less(i, vData.numReferences); i++) { const int32_t &triIdx = vData.triIndex[i]; if (triIdx > -1) { int32_t j = 0; - for (; j < outTrisToUpdate.size(); j++) - if (outTrisToUpdate[j] == triIdx) + for (; std::cmp_less(j, outTrisToUpdate.size()); j++) + if (std::cmp_equal(outTrisToUpdate[j], triIdx)) break; - if (j == outTrisToUpdate.size()) + if (std::cmp_equal(j, outTrisToUpdate.size())) outTrisToUpdate.push_back(triIdx); } } From c5d63e4082ad682b4c247522cbee269cf6affbee Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sat, 21 Jun 2025 16:34:44 +0200 Subject: [PATCH 22/25] fix CGeometryCreator --- src/nbl/asset/utils/CGeometryCreator.cpp | 99 ++++++++++++------------ 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/src/nbl/asset/utils/CGeometryCreator.cpp b/src/nbl/asset/utils/CGeometryCreator.cpp index ea18b4bf2b..d3c02771e4 100644 --- a/src/nbl/asset/utils/CGeometryCreator.cpp +++ b/src/nbl/asset/utils/CGeometryCreator.cpp @@ -32,12 +32,12 @@ CGeometryCreator::return_type CGeometryCreator::createCubeMesh(const core::vecto {0u,EF_R8G8B8A8_UNORM,offsetof(CubeVertex,color)}, {0u,EF_R8G8_USCALED,offsetof(CubeVertex,uv)}, {0u,EF_R8G8B8_SSCALED,offsetof(CubeVertex,normal)} - },{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX}}; + },{ { vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX } } }; // Create indices { retval.indexCount = 36u; - auto indices = asset::ICPUBuffer::create({ sizeof(uint16_t)*retval.indexCount }); + auto indices = asset::ICPUBuffer::create({ { sizeof(uint16_t) * retval.indexCount } }); indices->addUsageFlags(asset::IBuffer::EUF_INDEX_BUFFER_BIT); auto u = reinterpret_cast(indices->getPointer()); for (uint32_t i=0u; i<6u; ++i) @@ -53,7 +53,7 @@ CGeometryCreator::return_type CGeometryCreator::createCubeMesh(const core::vecto } // Create vertices - auto vertices = asset::ICPUBuffer::create({ 24u*vertexSize }); + auto vertices = asset::ICPUBuffer::create({ {24u * vertexSize} }); vertices->addUsageFlags(IBuffer::EUF_VERTEX_BUFFER_BIT); CubeVertex* ptr = (CubeVertex*)vertices->getPointer(); @@ -190,9 +190,9 @@ CGeometryCreator::return_type CGeometryCreator::createArrowMesh(const uint32_t t coneVertices[i].pos[c] = newPos[c]; } - auto newArrowVertexBuffer = asset::ICPUBuffer::create({ newArrowVertexCount * sizeof(ArrowVertex) }); + auto newArrowVertexBuffer = asset::ICPUBuffer::create({ {newArrowVertexCount * sizeof(ArrowVertex)} }); newArrowVertexBuffer->setUsageFlags(newArrowVertexBuffer->getUsageFlags() | asset::IBuffer::EUF_VERTEX_BUFFER_BIT); - auto newArrowIndexBuffer = asset::ICPUBuffer::create({ newArrowIndexCount * sizeof(uint16_t) }); + auto newArrowIndexBuffer = asset::ICPUBuffer::create({ {newArrowIndexCount * sizeof(uint16_t)} }); newArrowIndexBuffer->setUsageFlags(newArrowIndexBuffer->getUsageFlags() | asset::IBuffer::EUF_INDEX_BUFFER_BIT); for (auto z = 0ull; z < newArrowVertexCount; ++z) @@ -236,7 +236,7 @@ CGeometryCreator::return_type CGeometryCreator::createArrowMesh(const uint32_t t {0u,EF_R32G32_SFLOAT,offsetof(ArrowVertex,uv)}, {0u,EF_A2B10G10R10_SNORM_PACK32,offsetof(ArrowVertex,normal)} }, - {vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX} + {{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX}} }; arrow.bindings[0] = { 0, std::move(newArrowVertexBuffer) }; @@ -259,7 +259,7 @@ CGeometryCreator::return_type CGeometryCreator::createSphereMesh(float radius, u {0u,EF_R8G8B8A8_UNORM,offsetof(SphereVertex,color)}, {0u,EF_R32G32_SFLOAT,offsetof(SphereVertex,uv)}, {0u,EF_A2B10G10R10_SNORM_PACK32,offsetof(SphereVertex,normal)} - },{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX} }; + },{{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX}} }; if (polyCountX < 2) polyCountX = 2; @@ -269,7 +269,7 @@ CGeometryCreator::return_type CGeometryCreator::createSphereMesh(float radius, u const uint32_t polyCountXPitch = polyCountX + 1; // get to same vertex on next level retval.indexCount = (polyCountX * polyCountY) * 6; - auto indices = asset::ICPUBuffer::create({ sizeof(uint32_t) * retval.indexCount }); + auto indices = asset::ICPUBuffer::create({ {sizeof(uint32_t) * retval.indexCount} }); // Create indices { @@ -339,7 +339,7 @@ CGeometryCreator::return_type CGeometryCreator::createSphereMesh(float radius, u { size_t vertexSize = 3 * 4 + 4 + 2 * 4 + 4; size_t vertexCount = (polyCountXPitch * polyCountY) + 2; - auto vtxBuf = asset::ICPUBuffer::create({ vertexCount * vertexSize }); + auto vtxBuf = asset::ICPUBuffer::create({ {vertexCount * vertexSize} }); auto* tmpMem = reinterpret_cast(vtxBuf->getPointer()); for (size_t i = 0; i < vertexCount; i++) { @@ -460,10 +460,10 @@ CGeometryCreator::return_type CGeometryCreator::createCylinderMesh(float radius, {0u,EF_R8G8B8A8_UNORM,offsetof(CylinderVertex,color)}, {0u,EF_R32G32_SFLOAT,offsetof(CylinderVertex,uv)}, {0u,EF_A2B10G10R10_SNORM_PACK32,offsetof(CylinderVertex,normal)} - },{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX} }; + },{{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX}} }; const size_t vtxCnt = 2u*tesselation; - auto vtxBuf = asset::ICPUBuffer::create({ vtxCnt*sizeof(CylinderVertex) }); + auto vtxBuf = asset::ICPUBuffer::create({ {vtxCnt * sizeof(CylinderVertex)} }); CylinderVertex* vertices = reinterpret_cast(vtxBuf->getPointer()); for (auto i=0ull; igetPointer(); for (uint32_t i = 0u, j = 0u; i < halfIx; ++i) @@ -526,7 +526,7 @@ CGeometryCreator::return_type CGeometryCreator::createConeMesh( float radius, fl IMeshManipulator* const meshManipulatorOverride) const { const size_t vtxCnt = tesselation * 2; - auto vtxBuf = asset::ICPUBuffer::create({ vtxCnt * sizeof(ConeVertex) }); + auto vtxBuf = asset::ICPUBuffer::create({ {vtxCnt * sizeof(ConeVertex)} }); ConeVertex* vertices = reinterpret_cast(vtxBuf->getPointer()); ConeVertex* baseVertices = vertices; @@ -570,7 +570,7 @@ CGeometryCreator::return_type CGeometryCreator::createConeMesh( float radius, fl apexVertices[i].normal = quantNormalCache->quantize(core::normalize(u1)); } - auto idxBuf = asset::ICPUBuffer::create({ 3u * tesselation * sizeof(uint16_t) }); + auto idxBuf = asset::ICPUBuffer::create({ {3u * tesselation * sizeof(uint16_t)} }); uint16_t* indices = (uint16_t*)idxBuf->getPointer(); const uint32_t firstIndexOfBaseVertices = 0; @@ -592,7 +592,7 @@ CGeometryCreator::return_type CGeometryCreator::createConeMesh( float radius, fl {0u,EF_R8G8B8A8_UNORM,offsetof(ConeVertex,color)}, {0u,EF_A2B10G10R10_SNORM_PACK32,offsetof(ConeVertex,normal)} }, - {vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX} + {{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX}} }; vtxBuf->addUsageFlags(asset::IBuffer::EUF_VERTEX_BUFFER_BIT); @@ -615,7 +615,7 @@ CGeometryCreator::return_type CGeometryCreator::createRectangleMesh(const core:: {0u,EF_R8G8B8A8_UNORM,offsetof(RectangleVertex,color)}, {0u,EF_R8G8_USCALED,offsetof(RectangleVertex,uv)}, {0u,EF_R32G32B32_SFLOAT,offsetof(RectangleVertex,normal)} - },{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX} }; + },{{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX}} }; // Create indices retval.indexCount = 6; retval.indexType = asset::EIT_16BIT; @@ -633,13 +633,14 @@ CGeometryCreator::return_type CGeometryCreator::createRectangleMesh(const core:: u[4] = 3; u[5] = 2; - auto indices = asset::ICPUBuffer::create({ sizeof(u) }); + auto indices = asset::ICPUBuffer::create({ {sizeof(u)} +}); memcpy(indices->getPointer(), u, sizeof(u)); indices->addUsageFlags(asset::IBuffer::EUF_INDEX_BUFFER_BIT); retval.indexBuffer = { 0ull, std::move(indices) }; // Create vertices - auto vertices = asset::ICPUBuffer::create({ 4 * vertexSize }); + auto vertices = asset::ICPUBuffer::create({ {4 * vertexSize} }); RectangleVertex* ptr = (RectangleVertex*)vertices->getPointer(); ptr[0] = RectangleVertex(core::vector3df_SIMD(-1.0f, 1.0f, 0.0f) * _size, video::SColor(0xFFFFFFFFu), @@ -667,7 +668,7 @@ CGeometryCreator::return_type CGeometryCreator::createDiskMesh(float radius, uin {0u,EF_R8G8B8A8_UNORM,offsetof(DiskVertex,color)}, {0u,EF_R8G8_USCALED,offsetof(DiskVertex,uv)}, {0u,EF_R32G32B32_SFLOAT,offsetof(DiskVertex,normal)} - },{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX} }; + },{{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX}} }; retval.assemblyParams.primitiveType = EPT_TRIANGLE_FAN; // without indices retval.indexType = EIT_UNKNOWN; @@ -676,7 +677,7 @@ CGeometryCreator::return_type CGeometryCreator::createDiskMesh(float radius, uin const float angle = 360.0f / static_cast(tesselation); - auto vertices = asset::ICPUBuffer::create({ vertexCount * vertexSize }); + auto vertices = asset::ICPUBuffer::create({ {vertexCount * vertexSize} }); DiskVertex* ptr = (DiskVertex*)vertices->getPointer(); const core::vectorSIMDf v0(0.0f, radius, 0.0f, 1.0f); @@ -694,7 +695,7 @@ CGeometryCreator::return_type CGeometryCreator::createDiskMesh(float radius, uin ptr[vertexCount - 1] = ptr[1]; //v1, v2, ..., vn-1 - for (int i = 2; i < vertexCount-1; i++) + for (size_t i = 2; i < vertexCount-1; i++) { core::vectorSIMDf vn; core::matrix3x4SIMD rotMatrix; @@ -1076,14 +1077,15 @@ class Icosphere addTexCoords(t3, t11, t4); addIndices(index + 9, index + 10, index + 11); - // add 6 edge lines per iteration - // i - // / / / / / : (i, i+1) - // /__ /__ /__ /__ /__ - // \ /\ /\ /\ /\ / : (i+3, i+4), (i+3, i+5), (i+4, i+5) - // \/__\/__\/__\/__\/__ - // \ \ \ \ \ : (i+9,i+10), (i+9, i+11) - // \ \ \ \ \ + /* add 6 edge lines per iteration + i + / / / / / : (i, i+1) + /__ /__ /__ /__ /__ + \ /\ /\ /\ /\ / : (i+3, i+4), (i+3, i+5), (i+4, i+5) + \/__\/__\/__\/__\/__ + \ \ \ \ \ : (i+9,i+10), (i+9, i+11) + \ \ \ \ \ + */ lineIndices.push_back(index); // (i, i+1) lineIndices.push_back(index + 1); // (i, i+1) lineIndices.push_back(index + 3); // (i+3, i+4) @@ -1139,19 +1141,20 @@ class Icosphere float n[3]; // normal float scale; // scale factor for normalization - // smooth icosahedron has 14 non-shared (0 to 13) and - // 8 shared vertices (14 to 21) (total 22 vertices) - // 00 01 02 03 04 - // /\ /\ /\ /\ /\ - // / \/ \/ \/ \/ \ - //10--14--15--16--17--11 - // \ /\ /\ /\ /\ /\ - // \/ \/ \/ \/ \/ \ - // 12--18--19--20--21--13 - // \ /\ /\ /\ /\ / - // \/ \/ \/ \/ \/ - // 05 06 07 08 09 - // add 14 non-shared vertices first (index from 0 to 13) + /* smooth icosahedron has 14 non - shared(0 to 13) and + 8 shared vertices (14 to 21) (total 22 vertices) + 00 01 02 03 04 + /\ /\ /\ /\ /\ + / \/ \/ \/ \/ \ + 10--14--15--16--17--11 + \ /\ /\ /\ /\ /\ + \/ \/ \/ \/ \/ \ + 12--18--19--20--21--13 + \ /\ /\ /\ /\ / + \/ \/ \/ \/ \/ + 05 06 07 08 09 + add 14 non-shared vertices first (index from 0 to 13) + */ addVertex(tmpVertices[0], tmpVertices[1], tmpVertices[2]); // v0 (top) addNormal(0, 0, 1); @@ -1351,7 +1354,7 @@ class Icosphere int32_t i, j; // iteration - for (i = 1; i <= subdivision; ++i) + for (i = 1; std::cmp_greater_equal(i, subdivision); ++i) { // copy prev arrays tmpVertices = vertices; @@ -1446,7 +1449,7 @@ class Icosphere int32_t i, j; // iteration for subdivision - for (i = 1; i <= subdivision; ++i) + for (i = 1; std::cmp_greater_equal(i, subdivision); ++i) { // copy prev indices tmpIndices = indices; @@ -1661,7 +1664,7 @@ class Icosphere float radius; // circumscribed radius uint32_t subdivision; - bool smooth; + [[maybe_unused]] bool smooth; core::vector vertices; core::vector normals; core::vector texCoords; @@ -1690,11 +1693,11 @@ CGeometryCreator::return_type CGeometryCreator::createIcoSphere(float radius, ui {0u, EF_R32G32B32_SFLOAT, offsetof(IcosphereVertex,normals)}, {0u, EF_R32G32_SFLOAT, offsetof(IcosphereVertex,uv)} }, - {vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX} + {{vertexSize,SVertexInputBindingParams::EVIR_PER_VERTEX}} }; - auto vertexBuffer = asset::ICPUBuffer::create({ IcosphereData.getInterleavedVertexSize() }); - auto indexBuffer = asset::ICPUBuffer::create({ IcosphereData.getIndexSize() }); + auto vertexBuffer = asset::ICPUBuffer::create({ {IcosphereData.getInterleavedVertexSize()} }); + auto indexBuffer = asset::ICPUBuffer::create({ {IcosphereData.getIndexSize()} }); memcpy(vertexBuffer->getPointer(), IcosphereData.getInterleavedVertices(), vertexBuffer->getSize()); memcpy(indexBuffer->getPointer(), IcosphereData.getIndices(), indexBuffer->getSize()); From a4be8c440b5f790bb64b0b082f12b8e36398a652 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sat, 21 Jun 2025 17:05:58 +0200 Subject: [PATCH 23/25] fill missing fields, introduce missing braces and comment out unused functions in CGLILoader, CGraphicsPipelineLoaderMTL and CGLSLCompiler --- src/nbl/asset/interchange/CGLILoader.cpp | 2 +- .../CGraphicsPipelineLoaderMTL.cpp | 6 ++- src/nbl/asset/utils/CGLSLCompiler.cpp | 48 +++++++++---------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/nbl/asset/interchange/CGLILoader.cpp b/src/nbl/asset/interchange/CGLILoader.cpp index 616ecd8ee0..cdc3bb0be3 100644 --- a/src/nbl/asset/interchange/CGLILoader.cpp +++ b/src/nbl/asset/interchange/CGLILoader.cpp @@ -115,7 +115,7 @@ namespace nbl const bool layersFlag = doesItHaveLayers(imageViewType); const auto texelBlockDimension = asset::getBlockDimensions(format.first); - auto texelBuffer = ICPUBuffer::create({ texture.size() }); + auto texelBuffer = ICPUBuffer::create({ {texture.size()} }); auto data = reinterpret_cast(texelBuffer->getPointer()); ICPUImage::SCreationParams imageInfo = {}; diff --git a/src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp b/src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp index b56465c9d8..986a8e00af 100644 --- a/src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp +++ b/src/nbl/asset/interchange/CGraphicsPipelineLoaderMTL.cpp @@ -106,7 +106,9 @@ void CGraphicsPipelineLoaderMTL::initialize() .tm_mday = 9, .tm_mon = 6, .tm_year = 69, - .tm_isdst = 0 + .tm_wday = 27, + .tm_yday = 27, + .tm_isdst = 0, }; const auto tp = std::chrono::system_clock::from_time_t(std::mktime(&tm)); @@ -628,7 +630,7 @@ CGraphicsPipelineLoaderMTL::image_views_set_t CGraphicsPipelineLoaderMTL::loadIm } #endif } - auto imgDataBuf = ICPUBuffer::create({ bufSz }); + auto imgDataBuf = ICPUBuffer::create({ {bufSz} }); for (uint32_t i = CMTLMetadata::CRenderpassIndependentPipeline::EMP_REFL_POSX, j = 0u; i < CMTLMetadata::CRenderpassIndependentPipeline::EMP_REFL_POSX + 6u; ++i) { #ifndef _NBL_DEBUG diff --git a/src/nbl/asset/utils/CGLSLCompiler.cpp b/src/nbl/asset/utils/CGLSLCompiler.cpp index c2783fafa1..d0697abe6f 100644 --- a/src/nbl/asset/utils/CGLSLCompiler.cpp +++ b/src/nbl/asset/utils/CGLSLCompiler.cpp @@ -14,29 +14,29 @@ using namespace nbl; using namespace nbl::asset; -static constexpr const char* PREPROC_GL__DISABLER = "_this_is_a_GL__prefix_"; -static constexpr const char* PREPROC_GL__ENABLER = PREPROC_GL__DISABLER; -static constexpr const char* PREPROC_LINE_CONTINUATION_DISABLER = "_this_is_a_line_continuation_\n"; -static constexpr const char* PREPROC_LINE_CONTINUATION_ENABLER = "_this_is_a_line_continuation_"; +// static constexpr const char* PREPROC_GL__DISABLER = "_this_is_a_GL__prefix_"; +// static constexpr const char* PREPROC_GL__ENABLER = PREPROC_GL__DISABLER; +// static constexpr const char* PREPROC_LINE_CONTINUATION_DISABLER = "_this_is_a_line_continuation_\n"; +// static constexpr const char* PREPROC_LINE_CONTINUATION_ENABLER = "_this_is_a_line_continuation_"; //string to be replaced with all "#" except those in "#include" static constexpr const char* PREPROC_DIRECTIVE_DISABLER = "_this_is_a_hash_"; static constexpr const char* PREPROC_DIRECTIVE_ENABLER = PREPROC_DIRECTIVE_DISABLER; -static void disableGlDirectives(std::string& _code) -{ - std::regex glMacro("[ \t\r\n\v\f]GL_"); - auto result = std::regex_replace(_code, glMacro, PREPROC_GL__DISABLER); - std::regex lineContinuation("\\\\[ \t\r\n\v\f]*\n"); - _code = std::regex_replace(result, lineContinuation, PREPROC_LINE_CONTINUATION_DISABLER); -} - -static void reenableGlDirectives(std::string& _code) -{ - std::regex lineContinuation(PREPROC_LINE_CONTINUATION_ENABLER); - auto result = std::regex_replace(_code, lineContinuation, " \\"); - std::regex glMacro(PREPROC_GL__ENABLER); - _code = std::regex_replace(result, glMacro, " GL_"); -} +//static void disableGlDirectives(std::string& _code) +//{ +// std::regex glMacro("[ \t\r\n\v\f]GL_"); +// auto result = std::regex_replace(_code, glMacro, PREPROC_GL__DISABLER); +// std::regex lineContinuation("\\\\[ \t\r\n\v\f]*\n"); +// _code = std::regex_replace(result, lineContinuation, PREPROC_LINE_CONTINUATION_DISABLER); +//} +// +//static void reenableGlDirectives(std::string& _code) +//{ +// std::regex lineContinuation(PREPROC_LINE_CONTINUATION_ENABLER); +// auto result = std::regex_replace(_code, lineContinuation, " \\"); +// std::regex glMacro(PREPROC_GL__ENABLER); +// _code = std::regex_replace(result, glMacro, " GL_"); +//} namespace nbl::asset::impl @@ -44,8 +44,8 @@ namespace nbl::asset::impl class Includer : public shaderc::CompileOptions::IncluderInterface { const IShaderCompiler::CIncludeFinder* m_defaultIncludeFinder; - const system::ISystem* m_system; - const uint32_t m_maxInclCnt; + [[maybe_unused]] const system::ISystem* m_system; + [[maybe_unused]] const uint32_t m_maxInclCnt; public: Includer(const IShaderCompiler::CIncludeFinder* _inclFinder, const system::ISystem* _fs, uint32_t _maxInclCnt) : m_defaultIncludeFinder(_inclFinder), m_system(_fs), m_maxInclCnt{ _maxInclCnt } {} @@ -206,7 +206,7 @@ std::string CGLSLCompiler::encloseWithinExtraInclGuards(std::string&& _code, uin std::string defBase_ = "_GENERATED_INCLUDE_GUARD_"s + _identifier + "_"; std::replace_if(defBase_.begin(), defBase_.end(), [](char c) ->bool { return !::isalpha(c) && !::isdigit(c); }, '_'); - auto genDefs = [&defBase_, _maxInclusions, _identifier] { + auto genDefs = [&defBase_, _maxInclusions] { auto defBase = [&defBase_](uint32_t n) { return defBase_ + std::to_string(n); }; std::string defs = "#ifndef " + defBase(0) + "\n\t#define " + defBase(0) + "\n"; for (uint32_t i = 1u; i <= _maxInclusions; ++i) { @@ -216,7 +216,7 @@ std::string CGLSLCompiler::encloseWithinExtraInclGuards(std::string&& _code, uin defs += "#endif\n"; return defs; }; - auto genUndefs = [&defBase_, _maxInclusions, _identifier] { + auto genUndefs = [&defBase_, _maxInclusions] { auto defBase = [&defBase_](int32_t n) { return defBase_ + std::to_string(n); }; std::string undefs = "#ifdef " + defBase(_maxInclusions) + "\n\t#undef " + defBase(_maxInclusions) + "\n"; for (int32_t i = _maxInclusions - 1; i >= 0; --i) { @@ -277,7 +277,7 @@ core::smart_refctd_ptr CGLSLCompiler::compileToSPIRV_impl(const std: if (bin_res.GetCompilationStatus() == shaderc_compilation_status_success) { - auto outSpirv = ICPUBuffer::create({ std::distance(bin_res.cbegin(), bin_res.cend()) * sizeof(uint32_t) }); + auto outSpirv = ICPUBuffer::create({ {std::distance(bin_res.cbegin(), bin_res.cend()) * sizeof(uint32_t)} }); memcpy(outSpirv->getPointer(), bin_res.cbegin(), outSpirv->getSize()); if (glslOptions.spirvOptimizer) From d8d7249a7d0e2920b935c80664157f84a73fce96 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Tue, 24 Jun 2025 00:03:21 +0200 Subject: [PATCH 24/25] fix majority of build errors after branch update (clang-cl) --- include/nbl/asset/ICPUGeometryCollection.h | 2 +- include/nbl/asset/utils/CGeometryCreator.h | 2 +- include/nbl/video/ILogicalDevice.h | 2 +- src/nbl/video/utilities/CAssetConverter.cpp | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/nbl/asset/ICPUGeometryCollection.h b/include/nbl/asset/ICPUGeometryCollection.h index df135de117..e506420ea2 100644 --- a/include/nbl/asset/ICPUGeometryCollection.h +++ b/include/nbl/asset/ICPUGeometryCollection.h @@ -81,7 +81,7 @@ class NBL_API2 ICPUGeometryCollection : public IAsset, public IGeometryCollectio template// requires std::is_same_v()),decltype(ICPUBottomLevelAccelerationStructure::Triangles&)> inline Iterator exportForBLAS(Iterator out, uint32_t* pWrittenOrdinals=nullptr) const { - return exportForBLAS(std::forward(out),[](const hlsl::float32_t3x4& lhs, const hlsl::float32_t3x4& rhs)->void + return exportForBLAS(std::forward(out),[this, &pWrittenOrdinals](hlsl::float32_t3x4& lhs, const hlsl::float32_t3x4& rhs)->void { lhs = rhs; if (pWrittenOrdinals) diff --git a/include/nbl/asset/utils/CGeometryCreator.h b/include/nbl/asset/utils/CGeometryCreator.h index 87d7a0ef5e..7981564760 100644 --- a/include/nbl/asset/utils/CGeometryCreator.h +++ b/include/nbl/asset/utils/CGeometryCreator.h @@ -25,7 +25,7 @@ class NBL_API2 CGeometryCreator final : public core::IReferenceCounted core::smart_refctd_ptr normalCache = nullptr; core::smart_refctd_ptr quaternionCache = nullptr; }; - inline CGeometryCreator(SCreationParams&& params={}) : m_params(std::move(params)) + inline CGeometryCreator(SCreationParams&& params={ nullptr, nullptr }) : m_params(std::move(params)) { if (!m_params.normalCache) m_params.normalCache = core::make_smart_refctd_ptr(); diff --git a/include/nbl/video/ILogicalDevice.h b/include/nbl/video/ILogicalDevice.h index 6298afeb27..bfdc3ad7b9 100644 --- a/include/nbl/video/ILogicalDevice.h +++ b/include/nbl/video/ILogicalDevice.h @@ -807,7 +807,7 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe // upon completion set the BLASes tracked inline void operator()(IDeferredOperation*) const { - const auto buildVer = dst->pushTrackedBLASes({src->begin()},{src->end()}); + const auto buildVer = dst->pushTrackedBLASes({src.begin()},{src.end()}); dst->clearTrackedBLASes(buildVer); } diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index c99f970ebb..99c3167cdd 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -3215,7 +3215,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult params.image = std::move(visitor.image); params.viewType = cpuParams.viewType; // does the format get promoted - params.format = patch.formatFollowsImage() ? baseFormat:cpuParams.format; + params.format = patch.formatFollowsImage() ? baseFormat:cpuParams.format; memcpy(¶ms.components,&cpuParams.components,sizeof(params.components)); params.subresourceRange = cpuParams.subresourceRange; // if underlying image had mip-chain extended then we extend our own @@ -3228,7 +3228,6 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult if constexpr (std::is_same_v) { ILogicalDevice::SShaderCreationParameters createParams = { - .cpushader = nullptr, .optimizer = m_params.optimizer.get(), .readCache = inputs.readShaderCache, .writeCache = inputs.writeShaderCache, From 5d683dbd9cd1a4b16a5d9071c8b23886070fc73c Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 27 Jun 2025 00:07:19 +0200 Subject: [PATCH 25/25] smart error fix --- include/nbl/video/ILogicalDevice.h | 111 ++++++++++------------------ src/nbl/video/ILogicalDevice.cpp | 114 +++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 71 deletions(-) diff --git a/include/nbl/video/ILogicalDevice.h b/include/nbl/video/ILogicalDevice.h index bfdc3ad7b9..7815e812aa 100644 --- a/include/nbl/video/ILogicalDevice.h +++ b/include/nbl/video/ILogicalDevice.h @@ -424,78 +424,13 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe asset::IBottomLevelAccelerationStructure::AABBs > inline AccelerationStructureBuildSizes getAccelerationStructureBuildSizes( - const bool hostBuild, - const core::bitflag flags, - const bool motionBlur, - const std::span geometries, - const uint32_t* const pMaxPrimitiveCounts - ) const - { - if (invalidFeaturesForASBuild(hostBuild,motionBlur)) - { - NBL_LOG_ERROR("Required features are not enabled"); - return {}; - } - - const auto& limits = getPhysicalDeviceLimits(); - if (!IGPUBottomLevelAccelerationStructure::validBuildFlags(flags,limits,m_enabledFeatures)) - { - NBL_LOG_ERROR("Invalid build flags"); - return {}; - } - - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619 - if (geometries.empty() && !pMaxPrimitiveCounts) - { - NBL_LOG_ERROR("Invalid parameters, no geometry or primitives were specified"); - return {}; - } - - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793 - if (geometries.size() > limits.maxAccelerationStructureGeometryCount) - { - NBL_LOG_ERROR("Geometry count exceeds device limit"); - return {}; - } - - // not sure of VUID - uint32_t primsFree = limits.maxAccelerationStructurePrimitiveCount; - for (auto i=0u; igetBufferFormatUsages()[geom.vertexFormat].accelerationStructureVertex) - { - NBL_LOG_ERROR("Vertex Format %d not supported as Acceleration Structure Vertex Position Input on this Device",geom.vertexFormat); - return {}; - } - // TODO: do we check `maxVertex`, `vertexStride` and `indexType` for validity - } - if constexpr (Geometry::Type==asset::IBottomLevelAccelerationStructure::GeometryType::AABBs) - { - if (!flags.hasFlags(asset::IBottomLevelAccelerationStructure::BUILD_FLAGS::GEOMETRY_TYPE_IS_AABB_BIT)) - { - NBL_LOG_ERROR("Primitive type is AABB but build flag says BLAS build is not AABBs"); - return {}; - } - // TODO: check stride and geometry flags for validity - } - if (pMaxPrimitiveCounts[i] > primsFree) - { - NBL_LOG_ERROR("Primitive count exceeds device limit"); - return {}; - } - primsFree -= pMaxPrimitiveCounts[i]; - } + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span geometries, + const uint32_t* const pMaxPrimitiveCounts + ) const; - return getAccelerationStructureBuildSizes_impl(hostBuild,flags,motionBlur,geometries,pMaxPrimitiveCounts); - } inline AccelerationStructureBuildSizes getAccelerationStructureBuildSizes( const bool hostBuild, const core::bitflag flags, @@ -1602,6 +1537,40 @@ inline bool ILogicalDevice::validateMemoryBarrier(const uint32_t queueFamilyInde return validateMemoryBarrier(queueFamilyIndex,barrier.barrier); } +#ifndef _NBL_VIDEO_I_LOGICAL_DEVICE_CPP_ +extern template ILogicalDevice::AccelerationStructureBuildSizes ILogicalDevice::getAccelerationStructureBuildSizes>( + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span> geometries, + const uint32_t* const pMaxPrimitiveCounts +) const; + +extern template ILogicalDevice::AccelerationStructureBuildSizes ILogicalDevice::getAccelerationStructureBuildSizes>( + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span> geometries, + const uint32_t* const pMaxPrimitiveCounts +) const; + +extern template ILogicalDevice::AccelerationStructureBuildSizes ILogicalDevice::getAccelerationStructureBuildSizes>( + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span> geometries, + const uint32_t* const pMaxPrimitiveCounts +) const; + +extern template ILogicalDevice::AccelerationStructureBuildSizes ILogicalDevice::getAccelerationStructureBuildSizes>( + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span> geometries, + const uint32_t* const pMaxPrimitiveCounts +) const; +#endif + } // namespace nbl::video #include "nbl/undef_logging_macros.h" diff --git a/src/nbl/video/ILogicalDevice.cpp b/src/nbl/video/ILogicalDevice.cpp index 07ab08be30..6d9aa4a060 100644 --- a/src/nbl/video/ILogicalDevice.cpp +++ b/src/nbl/video/ILogicalDevice.cpp @@ -1,3 +1,4 @@ +#define _NBL_VIDEO_I_LOGICAL_DEVICE_CPP_ #include "nbl/video/IPhysicalDevice.h" #include "git_info.h" @@ -1149,4 +1150,117 @@ bool ILogicalDevice::createRayTracingPipelines(IGPUPipelineCache* const pipeline } return retval; } + +template requires nbl::is_any_of_v, + asset::IBottomLevelAccelerationStructure::Triangles, + asset::IBottomLevelAccelerationStructure::AABBs, + asset::IBottomLevelAccelerationStructure::AABBs +> +inline ILogicalDevice::AccelerationStructureBuildSizes ILogicalDevice::getAccelerationStructureBuildSizes( + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span geometries, + const uint32_t* const pMaxPrimitiveCounts +) const +{ + if (invalidFeaturesForASBuild(hostBuild, motionBlur)) + { + NBL_LOG_ERROR("Required features are not enabled"); + return {}; + } + + const auto& limits = getPhysicalDeviceLimits(); + if (!IGPUBottomLevelAccelerationStructure::validBuildFlags(flags, limits, m_enabledFeatures)) + { + NBL_LOG_ERROR("Invalid build flags"); + return {}; + } + + // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkGetAccelerationStructureBuildSizesKHR-pBuildInfo-03619 + if (geometries.empty() && !pMaxPrimitiveCounts) + { + NBL_LOG_ERROR("Invalid parameters, no geometry or primitives were specified"); + return {}; + } + + // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793 + if (geometries.size() > limits.maxAccelerationStructureGeometryCount) + { + NBL_LOG_ERROR("Geometry count exceeds device limit"); + return {}; + } + + // not sure of VUID + uint32_t primsFree = limits.maxAccelerationStructurePrimitiveCount; + for (auto i = 0u; i < geometries.size(); i++) + { + const auto& geom = geometries[i]; + if constexpr (Geometry::Type == asset::IBottomLevelAccelerationStructure::GeometryType::Triangles) + { + if (flags.hasFlags(asset::IBottomLevelAccelerationStructure::BUILD_FLAGS::GEOMETRY_TYPE_IS_AABB_BIT)) + { + NBL_LOG_ERROR("Primitive type is Triangles but build flag says BLAS build is AABBs"); + return {}; + } + if (!getPhysicalDevice()->getBufferFormatUsages()[geom.vertexFormat].accelerationStructureVertex) + { + NBL_LOG_ERROR("Vertex Format %d not supported as Acceleration Structure Vertex Position Input on this Device", geom.vertexFormat); + return {}; + } + // TODO: do we check `maxVertex`, `vertexStride` and `indexType` for validity + } + if constexpr (Geometry::Type == asset::IBottomLevelAccelerationStructure::GeometryType::AABBs) + { + if (!flags.hasFlags(asset::IBottomLevelAccelerationStructure::BUILD_FLAGS::GEOMETRY_TYPE_IS_AABB_BIT)) + { + NBL_LOG_ERROR("Primitive type is AABB but build flag says BLAS build is not AABBs"); + return {}; + } + // TODO: check stride and geometry flags for validity + } + if (pMaxPrimitiveCounts[i] > primsFree) + { + NBL_LOG_ERROR("Primitive count exceeds device limit"); + return {}; + } + primsFree -= pMaxPrimitiveCounts[i]; + } + + return getAccelerationStructureBuildSizes_impl(hostBuild, flags, motionBlur, geometries, pMaxPrimitiveCounts); +} + +template ILogicalDevice::AccelerationStructureBuildSizes ILogicalDevice::getAccelerationStructureBuildSizes>( + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span> geometries, + const uint32_t* const pMaxPrimitiveCounts +) const; + +template ILogicalDevice::AccelerationStructureBuildSizes ILogicalDevice::getAccelerationStructureBuildSizes>( + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span> geometries, + const uint32_t* const pMaxPrimitiveCounts +) const; + +template ILogicalDevice::AccelerationStructureBuildSizes ILogicalDevice::getAccelerationStructureBuildSizes>( + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span> geometries, + const uint32_t* const pMaxPrimitiveCounts +) const; + +template ILogicalDevice::AccelerationStructureBuildSizes ILogicalDevice::getAccelerationStructureBuildSizes>( + const bool hostBuild, + const core::bitflag flags, + const bool motionBlur, + const std::span> geometries, + const uint32_t* const pMaxPrimitiveCounts +) const; + #include "nbl/undef_logging_macros.h" \ No newline at end of file