diff --git a/3rdparty/nbl_spirv_cross b/3rdparty/nbl_spirv_cross index f4accc2a4b..a81d0b62c3 160000 --- a/3rdparty/nbl_spirv_cross +++ b/3rdparty/nbl_spirv_cross @@ -1 +1 @@ -Subproject commit f4accc2a4b478c42038c920aa0e43a8aab7d135c +Subproject commit a81d0b62c3a19be54d567302398dc3c2fc067c74 diff --git a/include/nbl/asset/IAnimationLibrary.h b/include/nbl/asset/IAnimationLibrary.h index 3ab87e5d32..9805ce6370 100644 --- a/include/nbl/asset/IAnimationLibrary.h +++ b/include/nbl/asset/IAnimationLibrary.h @@ -32,7 +32,7 @@ class IAnimationLibrary : public virtual core::IReferenceCounted Keyframe() : scale(0ull) // TODO: initialize scale to 1.f { translation[2] = translation[1] = translation[0] = 0.f; - quat = core::vectorSIMDu32(128u,128u,128u,255u); // should be (0,0,0,1) encoded + quat = hlsl::uint32_t4(128u,128u,128u,255u); // should be (0,0,0,1) encoded } Keyframe(const core::vectorSIMDf& _scale, const hlsl::math::quaternion& _quat, const CQuantQuaternionCache* quantCache, const core::vectorSIMDf& _translation) { @@ -155,7 +155,7 @@ class IAnimationLibrary : public virtual core::IReferenceCounted } template - friend struct IAnimationLibrary; + friend class IAnimationLibrary; // map must contain one `const char*` per bone template diff --git a/include/nbl/asset/IAsset.h b/include/nbl/asset/IAsset.h index b7142713bf..3b2be37483 100644 --- a/include/nbl/asset/IAsset.h +++ b/include/nbl/asset/IAsset.h @@ -169,7 +169,7 @@ class IAsset : virtual public core::IReferenceCounted inline void visitDependents(std::function visit) { assert(isMutable()); - visitDependents([&](const IAsset* dependent) -> bool + static_cast(this)->visitDependents([&](const IAsset* dependent) -> bool { return visit(const_cast(dependent)); }); diff --git a/include/nbl/asset/IAssetManager.h b/include/nbl/asset/IAssetManager.h index d9995526bc..af809a7608 100644 --- a/include/nbl/asset/IAssetManager.h +++ b/include/nbl/asset/IAssetManager.h @@ -121,8 +121,8 @@ class NBL_API2 IAssetManager : public core::IReferenceCounted //! Constructor explicit IAssetManager(core::smart_refctd_ptr&& system, core::smart_refctd_ptr&& compilerSet = nullptr) : m_system(std::move(system)), - m_compilerSet(std::move(compilerSet)), - m_defaultLoaderOverride(this) + m_defaultLoaderOverride(this), + m_compilerSet(std::move(compilerSet)) { assert(IPreHashed::INVALID_HASH == static_cast(core::blake3_hasher{})); initializeMeshTools(); diff --git a/include/nbl/asset/IBufferView.h b/include/nbl/asset/IBufferView.h index 70e54f7585..496459659a 100644 --- a/include/nbl/asset/IBufferView.h +++ b/include/nbl/asset/IBufferView.h @@ -25,7 +25,7 @@ class IBufferView : public IDescriptor size_t getByteSize() const { return m_size; } protected: - IBufferView(const SBufferRange& underlying, E_FORMAT _format) : m_size(underlying.size), m_offset(underlying.offset), m_buffer(underlying.buffer), m_format(_format) + IBufferView(const SBufferRange& underlying, E_FORMAT _format) : m_offset(underlying.offset), m_size(underlying.size), m_buffer(underlying.buffer), m_format(_format) { if (m_size==asset::SBufferRange::WholeBuffer) m_size = m_buffer->getSize()-m_offset; diff --git a/include/nbl/asset/ICPUAccelerationStructure.h b/include/nbl/asset/ICPUAccelerationStructure.h index 4973d7c433..6a8e6d2926 100644 --- a/include/nbl/asset/ICPUAccelerationStructure.h +++ b/include/nbl/asset/ICPUAccelerationStructure.h @@ -199,7 +199,7 @@ class ICPUBottomLevelAccelerationStructure final : public IPreHashed, public IBo verticesB = reinterpret_cast(triangles.vertexData[1].buffer->getPointer())+triangles.vertexData[1].offset; auto hashIndices = [&]() -> void { - for (auto i=0; i) @@ -228,7 +228,7 @@ class ICPUBottomLevelAccelerationStructure final : public IPreHashed, public IBo inline bool missingContent() const override { - return !m_geometryPrimitiveCount || !m_triangleGeoms && !m_AABBGeoms; + return !m_geometryPrimitiveCount || (!m_triangleGeoms && !m_AABBGeoms); } inline bool valid() const override @@ -351,7 +351,7 @@ class ICPUTopLevelAccelerationStructure final : public IAsset, public ITopLevelA inline bool usesMotion() const override { for (const auto& instance : *m_instances) - if (instance.getType()!=INSTANCE_TYPE::STATIC || instance.getBase().blas && instance.getBase().blas->usesMotion()) + if (instance.getType()!=INSTANCE_TYPE::STATIC || (instance.getBase().blas && instance.getBase().blas->usesMotion())) return true; return false; } diff --git a/include/nbl/asset/ICPUDescriptorSet.h b/include/nbl/asset/ICPUDescriptorSet.h index 4247283c0e..75f622c278 100644 --- a/include/nbl/asset/ICPUDescriptorSet.h +++ b/include/nbl/asset/ICPUDescriptorSet.h @@ -88,14 +88,14 @@ class NBL_API2 ICPUDescriptorSet final : public IDescriptorSetsize() != descriptorRedirect.getTotalCount()) return false; - auto offset = 0; - for (auto binding_i = 0; binding_i < descriptorRedirect.getBindingCount(); binding_i++) + uint32_t offset = 0; + for (uint32_t binding_i = 0; binding_i < descriptorRedirect.getBindingCount(); binding_i++) { const auto storageIndex = IDescriptorSetLayoutBase::CBindingRedirect::storage_range_index_t(binding_i); const auto descriptorCount = descriptorRedirect.getCount(storageIndex); const auto createFlags = descriptorRedirect.getCreateFlags(storageIndex); const auto isPartiallyBound = !createFlags.hasFlags(IDescriptorSetLayoutBase::SBindingBase::E_CREATE_FLAGS::ECF_PARTIALLY_BOUND_BIT); - for (auto descriptor_i = 0; descriptor_i < descriptorCount; descriptor_i++) + for (uint32_t descriptor_i = 0; descriptor_i < descriptorCount; descriptor_i++) { const auto& descriptorInfo = descriptorInfoArr->operator[](offset); diff --git a/include/nbl/asset/ICPUGeometryCollection.h b/include/nbl/asset/ICPUGeometryCollection.h index d231f1df00..734018e76a 100644 --- a/include/nbl/asset/ICPUGeometryCollection.h +++ b/include/nbl/asset/ICPUGeometryCollection.h @@ -36,7 +36,7 @@ class NBL_API2 ICPUGeometryCollection : public IAsset, public IGeometryCollectio return true; } - inline core::smart_refctd_ptr clone(uint32_t _depth=~0u) const + inline core::smart_refctd_ptr clone(uint32_t _depth=~0u) const override { const auto nextDepth = _depth ? (_depth-1):0; auto retval = core::smart_refctd_ptr(); @@ -55,7 +55,7 @@ class NBL_API2 ICPUGeometryCollection : public IAsset, public IGeometryCollectio } // - inline bool setAABB(const decltype(base_t::m_aabb)& aabb) + inline bool setAABB(const hlsl::shapes::AABB<3,hlsl::float64_t>& aabb) { if (isMutable()) { @@ -87,7 +87,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/ICPUImage.h b/include/nbl/asset/ICPUImage.h index fdbf640557..5b21db0fcb 100644 --- a/include/nbl/asset/ICPUImage.h +++ b/include/nbl/asset/ICPUImage.h @@ -53,6 +53,7 @@ class NBL_API2 ICPUImage final : public IImage, public IPreHashed return regions && !regions->empty() && (!buffer || buffer->missingContent()); } + using IImage::validateCopies; virtual bool validateCopies(const SImageCopy* pRegionsBegin, const SImageCopy* pRegionsEnd, const ICPUImage* src) const { return validateCopies_template(pRegionsBegin, pRegionsEnd, src); diff --git a/include/nbl/asset/ICPUMorphTargets.h b/include/nbl/asset/ICPUMorphTargets.h index 29924f9727..906510dad1 100644 --- a/include/nbl/asset/ICPUMorphTargets.h +++ b/include/nbl/asset/ICPUMorphTargets.h @@ -31,7 +31,7 @@ class NBL_API2 ICPUMorphTargets : public IAsset, public IMorphTargets clone(uint32_t _depth=~0u) const + inline core::smart_refctd_ptr clone(uint32_t _depth=~0u) const override { const auto nextDepth = _depth ? (_depth-1):0; auto retval = core::smart_refctd_ptr(); diff --git a/include/nbl/asset/ICPUPipeline.h b/include/nbl/asset/ICPUPipeline.h index e9442e0b8c..006cbf72fe 100644 --- a/include/nbl/asset/ICPUPipeline.h +++ b/include/nbl/asset/ICPUPipeline.h @@ -132,6 +132,7 @@ class ICPUPipeline : public IAsset, public PipelineNonAssetBase, public ICPUPipe } // Note(kevinyu): For some reason overload resolution cannot find this function when I name id getSpecInfos. It always use the const variant. Will check on it later. + using ICPUPipelineBase::getSpecInfos; inline std::span getSpecInfos(const hlsl::ShaderStage stage) { if (!isMutable()) return {}; diff --git a/include/nbl/asset/ICPUPipelineLayout.h b/include/nbl/asset/ICPUPipelineLayout.h index b30ecc3e10..9b6f6e3878 100644 --- a/include/nbl/asset/ICPUPipelineLayout.h +++ b/include/nbl/asset/ICPUPipelineLayout.h @@ -68,7 +68,7 @@ class ICPUPipelineLayout : public IAsset, public IPipelineLayoutvalid()) return false; @@ -81,7 +81,7 @@ class ICPUPipelineLayout : public IAsset, public IPipelineLayout visit) const override { - for (auto i = 0; i < m_descSetLayouts.size(); i++) + for (size_t i = 0; i < m_descSetLayouts.size(); i++) { if (!m_descSetLayouts[i]) continue; if (!visit(m_descSetLayouts[i].get())) return; diff --git a/include/nbl/asset/ICPURayTracingPipeline.h b/include/nbl/asset/ICPURayTracingPipeline.h index e882b4b4cb..d86dcdd3d3 100644 --- a/include/nbl/asset/ICPURayTracingPipeline.h +++ b/include/nbl/asset/ICPURayTracingPipeline.h @@ -36,7 +36,7 @@ class ICPURayTracingPipeline final : public ICPUPipeline getSpecInfos(const hlsl::ShaderStage stage) const override { - switch (stage) + switch (stage) { case hlsl::ShaderStage::ESS_RAYGEN: return { &m_raygen, 1 }; @@ -50,7 +50,8 @@ class ICPURayTracingPipeline final : public ICPUPipeline* getSpecInfoVector(const hlsl::ShaderStage stage) { if (!isMutable()) return nullptr; - switch (stage) + switch (stage) { // raygen is not stored as vector so we can't return it here. Use getSpecInfo case hlsl::ShaderStage::ESS_MISS: @@ -76,7 +77,8 @@ class ICPURayTracingPipeline final : public ICPUPipelinevalid()) return false; - const auto geoCount = targets->getGeometryExclusiveCount({}); + [[maybe_unused]] const auto geoCount = targets->getGeometryExclusiveCount({}); // TODO: check if `materialTableOffset+geoCount` can be contained in `materialTable` // TODO: check every material is either null or belongs in `m_materialPool` } return true; } - inline core::smart_refctd_ptr clone(uint32_t _depth=~0u) const + inline core::smart_refctd_ptr clone(uint32_t _depth=~0u) const override { const auto nextDepth = _depth ? (_depth-1):0; // TODO: copy the material_table state/contents! diff --git a/include/nbl/asset/IFramebuffer.h b/include/nbl/asset/IFramebuffer.h index 4f4abb89da..166eb28822 100644 --- a/include/nbl/asset/IFramebuffer.h +++ b/include/nbl/asset/IFramebuffer.h @@ -110,7 +110,7 @@ class IFramebuffer const auto& subresourceRange = viewParams.subresourceRange; const int32_t layerCount = static_cast(subresourceRange.layerCount!=ImageViewType::remaining_array_layers ? subresourceRange.layerCount:imgParams.arrayLayers); // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkFramebufferCreateInfo.html#VUID-VkFramebufferCreateInfo-flags-04535 - if (layerCount(layerCount)(depthStencilCount+colorCount); m_params.depthStencilAttachments = m_attachments->data(); m_params.colorAttachments = m_params.depthStencilAttachments+depthStencilCount; - for (auto i=0; i(params.depthStencilAttachments[i]); - for (auto i=0; i(params.colorAttachments[i]); } virtual ~IFramebuffer() = default; diff --git a/include/nbl/asset/IGeometry.h b/include/nbl/asset/IGeometry.h index 2e76e4bde7..da7b7a6db3 100644 --- a/include/nbl/asset/IGeometry.h +++ b/include/nbl/asset/IGeometry.h @@ -176,7 +176,7 @@ class IGeometryBase : public virtual core::IReferenceCounted struct SDataViewBase { // mostly checking validity of the format - inline operator bool() const {return format==EF_UNKNOWN || !isBlockCompressionFormat(format) && !isDepthOrStencilFormat(format);} + inline operator bool() const {return format==EF_UNKNOWN || (!isBlockCompressionFormat(format) && !isDepthOrStencilFormat(format));} // inline bool isFormatted() const {return format!=EF_UNKNOWN && bool(*this);} @@ -366,10 +366,10 @@ class IGeometry : public std::conditional_t(elIx); if (!out) - return false; + return; using traits = hlsl::vector_traits; using code_t = std::conditional_t,hlsl::float64_t,std::conditional_t,int64_t,uint64_t>>; code_t tmp[traits::Dimension]; @@ -382,9 +382,7 @@ class IGeometry : public std::conditional_t(composed.format,out,tmp)) - return true; - return false; + encodePixels(composed.format,out,tmp); } // @@ -417,14 +415,14 @@ class IGeometry : public std::conditional_tgetPointer(elIx); + return _this->template getPointer(elIx); return nullptr; } template requires hlsl::concepts::Vector inline void encodeElement(const Index elIx, const V& v) { if (_this) - _this->encodeElement(elIx,v); + _this->template encodeElement(elIx,v); } }; // @@ -501,7 +499,7 @@ class IIndexableGeometry : public IGeometry template requires (std::is_same_v<_B,BufferType> && std::is_same_v<_B,ICPUBuffer>) inline base_t::template MutableElementAccessor<_B> getIndexElementAccessor() {return base_t::template createElementAccessor<_B>(m_indexView);} - inline const uint64_t getIndexCount() const + inline uint64_t getIndexCount() const { return m_indexView.getElementCount(); } diff --git a/include/nbl/asset/IGeometryCollection.h b/include/nbl/asset/IGeometryCollection.h index 1fac15ec17..3d62ad53cf 100644 --- a/include/nbl/asset/IGeometryCollection.h +++ b/include/nbl/asset/IGeometryCollection.h @@ -34,8 +34,7 @@ class NBL_API2 IGeometryCollection : public virtual core::IReferenceCounted if (jointRedirectView.getElementCount()getJointCount()) return false; } - else - return true; + return true; } inline bool hasTransform() const {return !core::isnan(transform[0][0]);} diff --git a/include/nbl/asset/IImage.h b/include/nbl/asset/IImage.h index 748a609bbe..2582718819 100644 --- a/include/nbl/asset/IImage.h +++ b/include/nbl/asset/IImage.h @@ -207,7 +207,6 @@ class IImage : public virtual core::IReferenceCounted VkOffset3D imageOffset = {0u,0u,0u}; VkExtent3D imageExtent = {0u,0u,0u}; - auto operator<=>(const SBufferCopy&) const = default; }; struct SImageCopy { @@ -297,7 +296,7 @@ class IImage : public virtual core::IReferenceCounted default: break; } - const uint32_t round = core::roundUpToPoT(maxSideLen); + const uint32_t round = hlsl::roundUpToPoT(maxSideLen); return hlsl::findLSB(round); } inline static uint32_t calculateFullMipPyramidLevelCount(const VkExtent3D& extent, E_TYPE type) @@ -398,7 +397,7 @@ class IImage : public virtual core::IReferenceCounted bool actuallyMutable = false; // if only there existed a nice iterator that would let me iterate over set bits 64 faster if (_params.viewFormats.any()) - for (auto fmt=0; fmt<_params.viewFormats.size(); fmt++) + for (size_t fmt=0; fmt<_params.viewFormats.size(); fmt++) if (_params.viewFormats.test(fmt)) { const auto format = static_cast(fmt); @@ -697,7 +696,7 @@ class IImage : public virtual core::IReferenceCounted //if (!formatHasAspects(m_creationParams.format,subresource.aspectMask)) //return false; // The aspectMask member of imageSubresource must only have a single bit set - if (!hlsl::bitCount(subresource.aspectMask.value) == 1u) + if (!(hlsl::bitCount(subresource.aspectMask.value) == 1u)) return false; if (subresource.mipLevel >= m_creationParams.mipLevels) return false; diff --git a/include/nbl/asset/IPipelineLayout.h b/include/nbl/asset/IPipelineLayout.h index 0244aaaa06..f3c1a0190f 100644 --- a/include/nbl/asset/IPipelineLayout.h +++ b/include/nbl/asset/IPipelineLayout.h @@ -134,7 +134,7 @@ class IPipelineLayout for (; i <=_setNum; i++) { const DescLayoutType* lhs = m_descSetLayouts[i].get(); - const DescLayoutType* rhs = _other->getDescriptorSetLayout(i); + const DescLayoutType* rhs = _other->getDescriptorSetLayouts()[i]; const bool compatible = (lhs == rhs) || (lhs && lhs->isIdenticallyDefined(rhs)); if (!compatible) diff --git a/include/nbl/asset/IRenderpass.h b/include/nbl/asset/IRenderpass.h index ce41e35573..28383883a3 100644 --- a/include/nbl/asset/IRenderpass.h +++ b/include/nbl/asset/IRenderpass.h @@ -221,7 +221,7 @@ class NBL_API2 IRenderpass }; // The arrays pointed to by this array must be terminated by `PreserveAttachmentsEnd` value, which implicitly satisfies: // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubpassDescription2.html#VUID-VkSubpassDescription2-attachment-03073 - constexpr static inline SPreserveAttachmentRef PreserveAttachmentsEnd = {0,AttachmentUnused}; + constexpr static inline SPreserveAttachmentRef PreserveAttachmentsEnd = {0,AttachmentUnused&0x7FFFFFFFu}; const SPreserveAttachmentRef* preserveAttachments = &PreserveAttachmentsEnd; // TODO: redesign // TODO: shading rate attachment @@ -508,7 +508,7 @@ inline IRenderpass::SCreationParamValidationResult IRenderpass::validateCreation retval.viewMaskMSB = hlsl::findMSB(params.subpasses[0].viewMask); // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkRenderPassCreateInfo2-viewMask-03057 if (!retval.hasViewMasks()) - for (auto i=0; ibool + core::visit_token_terminated_array(params.depthStencilAttachments,SCreationParams::DepthStencilAttachmentsEnd,[setRetvalFalse,&retval](const SCreationParams::SDepthStencilAttachmentDescription& attachment)->bool { if (!attachment.valid()) return setRetvalFalse(); @@ -527,7 +527,7 @@ inline IRenderpass::SCreationParamValidationResult IRenderpass::validateCreation }); if (!retval) return retval; - core::visit_token_terminated_array(params.colorAttachments,SCreationParams::ColorAttachmentsEnd,[¶ms,setRetvalFalse,&retval](const SCreationParams::SColorAttachmentDescription& attachment)->bool + core::visit_token_terminated_array(params.colorAttachments,SCreationParams::ColorAttachmentsEnd,[setRetvalFalse,&retval](const SCreationParams::SColorAttachmentDescription& attachment)->bool { if (!attachment.valid()) return setRetvalFalse(); diff --git a/include/nbl/asset/IShader.h b/include/nbl/asset/IShader.h index d553dddf62..d88717935e 100644 --- a/include/nbl/asset/IShader.h +++ b/include/nbl/asset/IShader.h @@ -42,7 +42,7 @@ class IShader final : public IAsset inline IShader(core::smart_refctd_ptr&& code, const E_CONTENT_TYPE contentType, std::string&& filepathHint) : m_filepathHint(std::move(filepathHint)), m_code(std::move(code)), m_contentType(contentType) {} inline IShader(const char* code, const E_CONTENT_TYPE contentType, std::string&& filepathHint) : - m_filepathHint(std::move(filepathHint)), m_code(ICPUBuffer::create({strlen(code)+1u})), m_contentType(contentType) + m_filepathHint(std::move(filepathHint)), m_code(ICPUBuffer::create({{strlen(code)+1u}})), m_contentType(contentType) { assert(contentType!=E_CONTENT_TYPE::ECT_SPIRV); // because using strlen needs `code` to be null-terminated memcpy(m_code->getPointer(),code,m_code->getSize()); diff --git a/include/nbl/asset/ISkeleton.h b/include/nbl/asset/ISkeleton.h index 03ba3af4ea..27b85bf800 100644 --- a/include/nbl/asset/ISkeleton.h +++ b/include/nbl/asset/ISkeleton.h @@ -55,8 +55,8 @@ class ISkeleton : public virtual core::IReferenceCounted protected: ISkeleton(SBufferBinding&& _parentJointIDsBinding, SBufferBinding&& _defaultTransforms, const joint_id_t _jointCount = 0u) - : m_nameToJointID(), m_stringPoolSize(0ull), m_stringPool(nullptr), m_jointCount(_jointCount), - m_parentJointIDs(std::move(_parentJointIDsBinding)), m_defaultTransforms(std::move(_defaultTransforms)) + : m_nameToJointID(), m_stringPoolSize(0ull), m_stringPool(nullptr), + m_parentJointIDs(std::move(_parentJointIDsBinding)), m_defaultTransforms(std::move(_defaultTransforms)), m_jointCount(_jointCount) { if (m_jointCount==0u) return; diff --git a/include/nbl/asset/filters/CBlitImageFilter.h b/include/nbl/asset/filters/CBlitImageFilter.h index f228fea325..7350f5fd94 100644 --- a/include/nbl/asset/filters/CBlitImageFilter.h +++ b/include/nbl/asset/filters/CBlitImageFilter.h @@ -149,7 +149,7 @@ class CBlitImageFilter : return false; const size_t offset = getScratchOffset(this,ESU_SCALED_KERNEL_PHASED_LUT); const auto inType = inImage->getCreationParameters().type; - const size_t size = blit_utils_t::getScaledKernelPhasedLUTSize(inExtentLayerCount.xyz,outExtentLayerCount.xyz,inType,kernels); + [[maybe_unused]] const size_t size = blit_utils_t::getScaledKernelPhasedLUTSize(inExtentLayerCount.xyz,outExtentLayerCount.xyz,inType,kernels); auto* lut = base_t::CStateBase::scratchMemory+offset; return blit_utils_t::computeScaledKernelPhasedLUT(lut,inExtentLayerCount.xyz,outExtentLayerCount.xyz,inType, kernels); } @@ -224,7 +224,7 @@ class CBlitImageFilter : const auto kAlphaHistogramSize = state->alphaBinCount * sizeof(uint32_t); - uint32_t retval = 0; + [[maybe_unused]] uint32_t retval = 0; switch (usage) { case ESU_SCALED_KERNEL_PHASED_LUT: @@ -315,7 +315,7 @@ class CBlitImageFilter : const auto outFormat = outParams.format; const auto inBlockDims = asset::getBlockDimensions(inFormat); const auto outBlockDims = asset::getBlockDimensions(outFormat); - const auto* const inData = reinterpret_cast(inImg->getBuffer()->getPointer()); + [[maybe_unused]] const auto* const inData = reinterpret_cast(inImg->getBuffer()->getPointer()); auto* const outData = reinterpret_cast(outImg->getBuffer()->getPointer()); const auto inMipLevel = state->inMipLevel; @@ -411,9 +411,9 @@ class CBlitImageFilter : }); uint32_t* mergedHistogram = histograms; - for (auto hi = 1; hi < m_maxParallelism; ++hi) + for (uint32_t hi = 1; hi < m_maxParallelism; ++hi) { - for (auto bi = 0; bi < state->alphaBinCount; ++bi) + for (uint32_t bi = 0; bi < state->alphaBinCount; ++bi) histograms[bi] += histograms[hi * state->alphaBinCount + bi]; } @@ -476,7 +476,14 @@ class CBlitImageFilter : const hlsl::uint32_t4 outOffsetLayer(outOffsetBaseLayer.xyz,outOffsetBaseLayer.w+layer); // reset coverage counter constexpr bool is_seq_policy_v = std::is_same_v,core::execution::sequenced_policy>; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-local-typedef" +#endif using cond_atomic_int32_t = std::conditional_t; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif using cond_atomic_uint32_t = std::conditional_t; cond_atomic_uint32_t cvg_num(0u); cond_atomic_uint32_t cvg_den(0u); @@ -539,7 +546,7 @@ class CBlitImageFilter : auto sample = lineBuffer+i*ChannelCount; - base_t::template onDecode(inFormat, state, srcPix, sample, blockLocalTexelCoord.x, blockLocalTexelCoord.y, ChannelCount); + base_t::onDecode(inFormat, state, srcPix, sample, blockLocalTexelCoord.x, blockLocalTexelCoord.y, ChannelCount); if (nonPremultBlendSemantic) { @@ -610,7 +617,7 @@ class CBlitImageFilter : // we'll only get here if we have to do coverage adjustment if (needsNormalization && lastPass) { - state->normalization.finalize(); + state->normalization.template finalize(); storeToImage(core::rational(cvg_num,cvg_den),axis,outOffsetLayer); } }; diff --git a/include/nbl/asset/filters/CBlitUtilities.h b/include/nbl/asset/filters/CBlitUtilities.h index 51669662ba..c61c3efe50 100644 --- a/include/nbl/asset/filters/CBlitUtilities.h +++ b/include/nbl/asset/filters/CBlitUtilities.h @@ -91,8 +91,8 @@ class CBlitUtilities : public IBlitUtilities using convolution_kernel_y_t = std::tuple_element_t<1, convolution_kernels_t>; using convolution_kernel_z_t = std::tuple_element_t<2, convolution_kernels_t>; - using value_type = convolution_kernel_x_t::value_t; - static_assert(std::is_same_v && std::is_same_v); + using value_type = typename convolution_kernel_x_t::value_t; + static_assert(std::is_same_v && std::is_same_v); using lut_value_type = LutDataType; static_assert(std::is_same_v || std::is_same_v, "Invalid LUT data type."); diff --git a/include/nbl/asset/filters/CCopyImageFilter.h b/include/nbl/asset/filters/CCopyImageFilter.h index cbc133cfe4..a54dc8fced 100644 --- a/include/nbl/asset/filters/CCopyImageFilter.h +++ b/include/nbl/asset/filters/CCopyImageFilter.h @@ -62,7 +62,7 @@ class CCopyImageFilter : public CImageFilter, public CMatchedS assert(getTexelOrBlockBytesize(commonExecuteData.inFormat)==getTexelOrBlockBytesize(commonExecuteData.outFormat)); // if this asserts the API got broken during an update or something const auto blockDims = asset::getBlockDimensions(commonExecuteData.inFormat); - auto copy = [&commonExecuteData,&blockDims](uint32_t readBlockArrayOffset, core::vectorSIMDu32 readBlockPos) -> void + auto copy = [&commonExecuteData](uint32_t readBlockArrayOffset, core::vectorSIMDu32 readBlockPos) -> void { const auto localOutPos = readBlockPos+commonExecuteData.offsetDifferenceInBlocks; const auto writeOffset = commonExecuteData.oit->getByteOffset(localOutPos,commonExecuteData.outByteStrides); diff --git a/include/nbl/asset/filters/CFlattenRegionsImageFilter.h b/include/nbl/asset/filters/CFlattenRegionsImageFilter.h index 0eeba246e2..d9b6d1a25f 100644 --- a/include/nbl/asset/filters/CFlattenRegionsImageFilter.h +++ b/include/nbl/asset/filters/CFlattenRegionsImageFilter.h @@ -89,7 +89,7 @@ class CFlattenRegionsImageFilter : public CImageFilteroutImage->setBufferAndRegions(std::move(buffer),std::move(regions)); }; diff --git a/include/nbl/asset/filters/CMatchedSizeInOutImageFilterCommon.h b/include/nbl/asset/filters/CMatchedSizeInOutImageFilterCommon.h index c0f522c9cc..9ebc0129d5 100644 --- a/include/nbl/asset/filters/CMatchedSizeInOutImageFilterCommon.h +++ b/include/nbl/asset/filters/CMatchedSizeInOutImageFilterCommon.h @@ -198,7 +198,7 @@ class CMatchedSizeInOutImageFilterCommon : public CBasicImageFilterCommon reinterpret_cast(outImg->getBuffer()->getPointer()), inRegions, outRegions, - outRegions.data(), {}, {} + outRegions.data(), {}, {}, {} }; const asset::TexelBlockInfo srcImageTexelBlockInfo(commonExecuteData.inFormat); diff --git a/include/nbl/asset/filters/CRegionBlockFunctorFilter.h b/include/nbl/asset/filters/CRegionBlockFunctorFilter.h index 774bf2a24d..31d293611a 100644 --- a/include/nbl/asset/filters/CRegionBlockFunctorFilter.h +++ b/include/nbl/asset/filters/CRegionBlockFunctorFilter.h @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in nabla.h #ifndef __NBL_ASSET_C_REGION_BLOCK_FUNCTOR_FILTER_H_INCLUDED__ -#define __NBL_ASSET_C_REGION_BLOCK_FUNCTOR_H_INCLUDED__ +#define __NBL_ASSET_C_REGION_BLOCK_FUNCTOR_FILTER_H_INCLUDED__ #include "nbl/core/declarations.h" diff --git a/include/nbl/asset/filters/CSummedAreaTableImageFilter.h b/include/nbl/asset/filters/CSummedAreaTableImageFilter.h index 94eb7519f9..a76222b3e1 100644 --- a/include/nbl/asset/filters/CSummedAreaTableImageFilter.h +++ b/include/nbl/asset/filters/CSummedAreaTableImageFilter.h @@ -133,8 +133,8 @@ class CSummedAreaTableImageFilter : public CMatchedSizeInOutImageFilterCommon, p { const asset::E_FORMAT inFormat = state->inImage->getCreationParameters().format; const asset::E_FORMAT outFormat = state->outImage->getCreationParameters().format; - const auto inTexelByteSize = asset::getTexelOrBlockBytesize(inFormat); - const auto outTexelByteSize = asset::getTexelOrBlockBytesize(outFormat); + [[maybe_unused]] const auto inTexelByteSize = asset::getTexelOrBlockBytesize(inFormat); + [[maybe_unused]] const auto outTexelByteSize = asset::getTexelOrBlockBytesize(outFormat); const auto currentChannelCount = asset::getFormatChannelCount(inFormat); const auto arrayLayers = state->inImage->getCreationParameters().arrayLayers; static constexpr auto maxChannels = 4u; diff --git a/include/nbl/asset/filters/CSwizzleAndConvertImageFilter.h b/include/nbl/asset/filters/CSwizzleAndConvertImageFilter.h index 70a569aac9..7827bead1b 100644 --- a/include/nbl/asset/filters/CSwizzleAndConvertImageFilter.h +++ b/include/nbl/asset/filters/CSwizzleAndConvertImageFilter.h @@ -82,7 +82,7 @@ class CSwizzleAndConvertImageFilterBase : public CSwizzleableAndDitherableFilter return true; }; CMatchedSizeInOutImageFilterCommon::commonExecute(state,perOutputRegion); - state->normalization.finalize(); + state->normalization.template finalize(); } } }; @@ -216,8 +216,8 @@ class CSwizzleAndConvertImageFilter(state, dstPix, decodeBuffer, localOutPos, blockX, blockY, outChannelsAmount); } }; @@ -366,7 +366,7 @@ class CSwizzleAndConvertImageFilter(state, srcPix, decodeBuffer, blockX, blockY, maxChannels); - base_t::template onEncode(outFormat, state, dstPix, decodeBuffer, localOutPos, blockX, blockY, outChannelsAmount); + base_t::onEncode(outFormat, state, dstPix, decodeBuffer, localOutPos, blockX, blockY, outChannelsAmount); } }; CBasicImageFilterCommon::executePerRegion(policy, commonExecuteData.inImg, swizzle, commonExecuteData.inRegions, clip); diff --git a/include/nbl/asset/filters/NormalizationStates.h b/include/nbl/asset/filters/NormalizationStates.h index 2d9f016413..ff0bd93a5c 100644 --- a/include/nbl/asset/filters/NormalizationStates.h +++ b/include/nbl/asset/filters/NormalizationStates.h @@ -78,7 +78,7 @@ class CGlobalNormalizationState void operator()(E_FORMAT format, Tenc* encodeBuffer, const core::vectorSIMDu32& position, uint32_t blockX, uint32_t blockY, uint8_t channels) const { #ifdef _NBL_DEBUG - bool status = isFloatingPointFormat(format)||isNormalizedFormat(format); + [[maybe_unused]] bool status = isFloatingPointFormat(format)||isNormalizedFormat(format); assert(status); #endif // _NBL_DEBUG if (isSignedFormat(format)) @@ -167,7 +167,7 @@ class CDerivativeMapNormalizationStateBase { assert(channels>=kChannels); #ifdef _NBL_DEBUG - bool status = isFloatingPointFormat(format)||isNormalizedFormat(format); + [[maybe_unused]] bool status = isFloatingPointFormat(format)||isNormalizedFormat(format); assert(status); #endif // _NBL_DEBUG diff --git a/include/nbl/asset/filters/dithering/CDither.h b/include/nbl/asset/filters/dithering/CDither.h index 168244b058..8e9a2ee7a7 100644 --- a/include/nbl/asset/filters/dithering/CDither.h +++ b/include/nbl/asset/filters/dithering/CDither.h @@ -50,7 +50,7 @@ namespace nbl const auto& return_value = static_cast(this)->get(static_cast(state), pixelCoord, channel); #ifdef _NBL_DEBUG - bool status = return_value >= 0 && return_value <= 1; + [[maybe_unused]] bool status = return_value >= 0 && return_value <= 1; assert(status); #endif // _NBL_DEBUG diff --git a/include/nbl/asset/filters/kernels/CConvolutionWeightFunction.h b/include/nbl/asset/filters/kernels/CConvolutionWeightFunction.h index 84eb757cd1..382d7d8d41 100644 --- a/include/nbl/asset/filters/kernels/CConvolutionWeightFunction.h +++ b/include/nbl/asset/filters/kernels/CConvolutionWeightFunction.h @@ -21,13 +21,13 @@ namespace nbl::asset template class CConvolutionWeightFunction1D final : public impl::IWeightFunction1D { - static_assert(std::is_same_v, "Both functions must use the same Value Type!"); + static_assert(std::is_same_v, "Both functions must use the same Value Type!"); public: - using value_t = WeightFunction1DA::value_t; + using value_t = typename WeightFunction1DA::value_t; constexpr static inline uint32_t k_smoothness = WeightFunction1DA::k_smoothness + WeightFunction1DB::k_smoothness; inline CConvolutionWeightFunction1D(WeightFunction1DA&& funcA, WeightFunction1DB&& funcB) - : impl::IWeightFunction1D(funcA.getMinSupport()+funcB.getMinSupport(), funcA.getMaxSupport()+funcB.getMaxSupport()), m_funcA(std::move(funcA)), m_funcB(std::move(funcB)) + : impl::IWeightFunction1D(funcA.getMinSupport()+funcB.getMinSupport(), funcA.getMaxSupport()+funcB.getMaxSupport()), m_funcA(std::move(funcA)), m_funcB(std::move(funcB)) { } @@ -45,9 +45,9 @@ class CConvolutionWeightFunction1D final : public impl::IWeightFunction1DgetInvStretch(); - if constexpr (std::is_same_v && WeightFunction1DB::k_derivative==0) + if constexpr (std::is_same_v && WeightFunction1DB::k_derivative==0) retval = m_funcA.weight(x); - else if (std::is_same_v && WeightFunction1DA::k_derivative==0) + else if (std::is_same_v && WeightFunction1DA::k_derivative==0) retval = m_funcB.weight(x); else { diff --git a/include/nbl/asset/filters/kernels/WeightFunctions.h b/include/nbl/asset/filters/kernels/WeightFunctions.h index af2782dfac..8b4e2a7925 100644 --- a/include/nbl/asset/filters/kernels/WeightFunctions.h +++ b/include/nbl/asset/filters/kernels/WeightFunctions.h @@ -4,6 +4,11 @@ #include #include +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnan-infinity-disabled" +#endif + // move later if its useful for anything else namespace nbl::core::impl { @@ -389,3 +394,7 @@ concept SimpleWeightFunction1D = requires(T t) } // end namespace nbl::asset #endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/include/nbl/asset/format/EFormat.h b/include/nbl/asset/format/EFormat.h index 62ce71555e..e06897a177 100644 --- a/include/nbl/asset/format/EFormat.h +++ b/include/nbl/asset/format/EFormat.h @@ -1775,7 +1775,7 @@ inline value_type getFormatMaxValue(E_FORMAT format, uint32_t channel) case 1u: return SCHAR_MAX; case 2u: return SHRT_MAX; case 4u: return INT_MAX; - case 8u: return LLONG_MAX; + case 8u: return static_cast(LLONG_MAX); default: break; } } @@ -1786,7 +1786,7 @@ inline value_type getFormatMaxValue(E_FORMAT format, uint32_t channel) case 1u: return UCHAR_MAX; case 2u: return USHRT_MAX; case 4u: return UINT_MAX; - case 8u: return ULLONG_MAX; + case 8u: return static_cast(ULLONG_MAX); default: break; } } @@ -1818,8 +1818,8 @@ inline value_type getFormatMaxValue(E_FORMAT format, uint32_t channel) switch (bytesPerChannel) { case 2u: return 65504; - case 4u: return FLT_MAX; - case 8u: return DBL_MAX; + case 4u: return static_cast(FLT_MAX); + case 8u: return static_cast(DBL_MAX); default: break; } } diff --git a/include/nbl/asset/format/encodePixels.h b/include/nbl/asset/format/encodePixels.h index 1c4b6aac9d..3127de87cb 100644 --- a/include/nbl/asset/format/encodePixels.h +++ b/include/nbl/asset/format/encodePixels.h @@ -46,10 +46,10 @@ namespace asset constexpr float epsilon = 0.4f; constexpr float epsilonToAddToMin = (min < 0 ? -epsilon : epsilon); - if (nbl::asset::isNormalizedFormat(format)) - variableToAssignClampingTo = static_cast(core::clamp(variableToClamp * static_cast(max), min + epsilonToAddToMin, max + epsilon)); + if (nbl::asset::isNormalizedFormat(format)) + variableToAssignClampingTo = static_cast(core::clamp(variableToClamp * static_cast(max), static_cast(min) + epsilonToAddToMin, static_cast(max) + epsilon)); else - variableToAssignClampingTo = static_cast(core::clamp(variableToClamp, min + epsilonToAddToMin, max + epsilon)); + variableToAssignClampingTo = static_cast(core::clamp(variableToClamp, static_cast(min) + epsilonToAddToMin, static_cast(max) + epsilon)); } template diff --git a/include/nbl/asset/interchange/IAssetLoader.h b/include/nbl/asset/interchange/IAssetLoader.h index a194f0e13e..e4f78852d0 100644 --- a/include/nbl/asset/interchange/IAssetLoader.h +++ b/include/nbl/asset/interchange/IAssetLoader.h @@ -100,7 +100,7 @@ class NBL_API2 IAssetLoader : public virtual core::IReferenceCounted const system::logger_opt_ptr _logger = nullptr, const std::filesystem::path& cwd = "") : decryptionKeyLen(_decryptionKeyLen), decryptionKey(_decryptionKey), cacheFlags(_cacheFlags), loaderFlags(_loaderFlags), - logger(std::move(_logger)), workingDirectory(cwd) + workingDirectory(cwd), logger(std::move(_logger)) { } @@ -109,8 +109,8 @@ class NBL_API2 IAssetLoader : public virtual core::IReferenceCounted decryptionKey(rhs.decryptionKey), cacheFlags(rhs.cacheFlags), loaderFlags(rhs.loaderFlags), - logger(rhs.logger), - workingDirectory(rhs.workingDirectory) + workingDirectory(rhs.workingDirectory), + logger(rhs.logger) { } @@ -193,7 +193,7 @@ class NBL_API2 IAssetLoader : public virtual core::IReferenceCounted //! inline virtual std::pair,const IAssetMetadata*> findDefaultAsset(const std::string& inSearchKey, const IAsset::E_TYPE assetType, const SAssetLoadContext& ctx, const uint32_t hierarchyLevel) { - size_t storageSz = 1ull; + [[maybe_unused]] size_t storageSz = 1ull; const IAsset::E_TYPE types[]{ assetType, static_cast(0u) }; auto bundle = findCachedAsset(inSearchKey,types,ctx,hierarchyLevel); diff --git a/include/nbl/asset/interchange/IGeometryLoader.h b/include/nbl/asset/interchange/IGeometryLoader.h index 6e6c7c4e26..78d9061ce7 100644 --- a/include/nbl/asset/interchange/IGeometryLoader.h +++ b/include/nbl/asset/interchange/IGeometryLoader.h @@ -60,11 +60,12 @@ class IGeometryLoader : public IAssetLoader inline void* allocate(std::size_t bytes, std::size_t alignment) override { assert(false); // should never be called + return nullptr; } inline void deallocate(void* p, std::size_t bytes, std::size_t alignment) override { assert(m_file); - auto* const basePtr = reinterpret_cast(m_file->getMappedPointer()); + [[maybe_unused]] auto* const basePtr = reinterpret_cast(m_file->getMappedPointer()); assert(basePtr && basePtr<=p && p<=basePtr+m_file->getSize()); } @@ -73,7 +74,7 @@ class IGeometryLoader : public IAssetLoader }; static inline IGeometry::SDataView createView(const E_FORMAT format, const size_t elementCount, core::smart_refctd_ptr&& file, const size_t offsetInFile) { - if (auto* const basePtr=reinterpret_cast(file->getMappedPointer()); basePtr) + if ([[maybe_unused]] auto* const basePtr=reinterpret_cast(file->getMappedPointer()); basePtr) { auto resource = core::make_smart_refctd_ptr(std::move(file)); auto* const data = basePtr+offsetInFile; diff --git a/include/nbl/asset/interchange/IImageAssetHandlerBase.h b/include/nbl/asset/interchange/IImageAssetHandlerBase.h index b39ae2a8be..bebdc11a60 100644 --- a/include/nbl/asset/interchange/IImageAssetHandlerBase.h +++ b/include/nbl/asset/interchange/IImageAssetHandlerBase.h @@ -88,7 +88,7 @@ class IImageAssetHandlerBase : public virtual core::IReferenceCounted size_t bufferSize = 0u; const TexelBlockInfo info(newImageParams.format); const core::rational bytesPerPixel = asset::getBytesPerPixel(newImageParams.format); - for (auto i = 0; i < newMipCount; i++) + for (uint32_t i = 0; i < newMipCount; i++) { auto& region = newRegions->operator[](i); region.bufferOffset = bufferSize; @@ -110,7 +110,7 @@ class IImageAssetHandlerBase : public virtual core::IReferenceCounted bufferSize += memsize.getIntegerApprox(); } - auto texelBuffer = ICPUBuffer::create({ bufferSize }); + auto texelBuffer = ICPUBuffer::create({{ bufferSize, {} }}); newImage->setBufferAndRegions(std::move(texelBuffer), newRegions); newImage->setContentHash(IPreHashed::INVALID_HASH); } @@ -125,7 +125,7 @@ class IImageAssetHandlerBase : public virtual core::IReferenceCounted identityTransform = identityTransform && (mapping == (decltype(mapping)::ES_R + i) || mapping == (decltype(mapping)::ES_IDENTITY)); } - for (auto i = 0; i < newMipCount; i++) + for (uint32_t i = 0; i < newMipCount; i++) { auto fillCommonState = [&](auto& state) { @@ -178,7 +178,7 @@ class IImageAssetHandlerBase : public virtual core::IReferenceCounted static inline void performImageFlip(core::smart_refctd_ptr image) { - bool status = image->getBuffer() && image->getRegions().data(); + [[maybe_unused]] bool status = image->getBuffer() && image->getRegions().data(); assert(status);// , "An image doesn't have a texel buffer and regions attached!"); auto format = image->getCreationParameters().format; diff --git a/include/nbl/asset/interchange/SAssetBundle.h b/include/nbl/asset/interchange/SAssetBundle.h index 56762fb05b..721712b42a 100644 --- a/include/nbl/asset/interchange/SAssetBundle.h +++ b/include/nbl/asset/interchange/SAssetBundle.h @@ -93,7 +93,7 @@ class SAssetBundle //! Overloaded operator checking if both collections of Assets\b aren't\b the same arrays in memory inline bool operator!=(const SAssetBundle& _other) const { - return !((*this) != _other); + return !((*this) == _other); } private: diff --git a/include/nbl/asset/material_compiler3/CFrontendIR.h b/include/nbl/asset/material_compiler3/CFrontendIR.h index c866763bd6..70dc8f12e5 100644 --- a/include/nbl/asset/material_compiler3/CFrontendIR.h +++ b/include/nbl/asset/material_compiler3/CFrontendIR.h @@ -111,7 +111,14 @@ class CFrontendIR : public CNodePool { inline operator bool() const { - return abs(scale)::infinity() && (!view || viewChannelgetCreationParameters().format)); + #ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnan-infinity-disabled" +#endif + return abs(scale)::infinity() && (!view || viewChannelgetCreationParameters().format)); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } inline bool operator!=(const SParameter& other) const { @@ -129,7 +136,14 @@ class CFrontendIR : public CNodePool NBL_API void printDot(std::ostringstream& sstr, const core::string& selfID) const; // at this stage we store the multipliers in highest precision +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnan-infinity-disabled" +#endif float scale = std::numeric_limits::infinity(); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif // rest are ignored if the view is null uint8_t viewChannel : 2 = 0; uint8_t padding[3] = {0,0,0}; @@ -395,7 +409,7 @@ class CFrontendIR : public CNodePool return sizeof(CSpectralVariable)+sizeof(SCreationParams<1>)+(getKnotCount()-1)*sizeof(SParameter); } - inline operator bool() const {return !invalid(SInvalidCheckArgs{.pool=nullptr,.logger=nullptr});} + inline operator bool() const {return !invalid(SInvalidCheckArgs{.pool=nullptr,.logger=nullptr,.isBTDF=false});} protected: inline ~CSpectralVariable() @@ -882,7 +896,7 @@ inline bool CFrontendIR::valid(const TypedHandle rootHandle, syste const auto* node = entry.node; const auto nodeType = node->getType(); const bool nodeIsMul = nodeType==IExprNode::Type::Mul; - const bool nodeIsAdd = nodeType==IExprNode::Type::Add; + [[maybe_unused]] const bool nodeIsAdd = nodeType==IExprNode::Type::Add; const auto childCount = node->getChildCount(); bool takeOverContribSlot = true; // first add child can do this for (auto childIx=0; childIx rootHandle, syste const auto childHandle = node->getChildHandle(childIx); if (const auto child=deref(childHandle); child) { - const bool noContribBelow = entry.contribState==SubtreeContributorState::Forbidden || childIx!=0 && nodeIsMul; - StackEntry newEntry = {.node=child,.handle=childHandle}; + const bool noContribBelow = entry.contribState==SubtreeContributorState::Forbidden || (childIx!=0 && nodeIsMul); + StackEntry newEntry = {.node=child,.handle=childHandle,.contribSlot={}}; if (noContribBelow) { if (child->getType()==IExprNode::Type::Contributor) diff --git a/include/nbl/asset/material_compiler3/CNodePool.h b/include/nbl/asset/material_compiler3/CNodePool.h index e0d35f0f82..4e3d5f12c0 100644 --- a/include/nbl/asset/material_compiler3/CNodePool.h +++ b/include/nbl/asset/material_compiler3/CNodePool.h @@ -52,7 +52,7 @@ class CNodePool : public core::IReferenceCounted { public: inline const std::string_view getTypeName() const override {return "nbl::CNodePool::CDebugInfo";} - inline uint32_t getSize() const {return calc_size(nullptr,m_size);} + inline uint32_t getSize() const override {return calc_size(nullptr,m_size);} static inline uint32_t calc_size(const void* data, const uint32_t size) { @@ -65,7 +65,16 @@ class CNodePool : public core::IReferenceCounted inline CDebugInfo(const void* data, const uint32_t size) : m_size(size) { if (data) + { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdynamic-class-memaccess" +#endif memcpy(std::launder(this+1),data,m_size); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + } } inline CDebugInfo(const std::string_view& view) : CDebugInfo(nullptr,view.length()+1) { @@ -185,13 +194,20 @@ class CNodePool : public core::IReferenceCounted // wipe v-table to mark as dead (so `~CNodePool` doesn't run destructor twice) // NOTE: This won't work if we start reusing memory, even zeroing out the whole node won't work! Then need an accurate record of live nodes! const void* nullVTable = nullptr; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdynamic-class-memaccess" +#endif assert(memcmp(ptr,&nullVTable,sizeof(nullVTable))!=0); // double free memset(static_cast(ptr),0,sizeof(nullVTable)); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif free(h.untyped,size); } inline CNodePool(const uint8_t _chunkSizeLog2, const uint8_t _maxNodeAlignLog2, refctd_pmr_t&& _pmr) : - m_chunkSizeLog2(_chunkSizeLog2), m_maxNodeAlignLog2(_maxNodeAlignLog2), m_pmr(_pmr ? std::move(_pmr):core::getDefaultMemoryResource()) + m_pmr(_pmr ? std::move(_pmr):core::getDefaultMemoryResource()), m_chunkSizeLog2(_chunkSizeLog2), m_maxNodeAlignLog2(_maxNodeAlignLog2) { assert(m_chunkSizeLog2>=14 && m_maxNodeAlignLog2>=4); } @@ -262,7 +278,7 @@ class CNodePool : public core::IReferenceCounted }; inline uint32_t getChunkIx(const Handle h) {return h.value>>m_chunkSizeLog2;} - template requires (std::is_base_of_v && !std::is_const_v || std::is_void_v) + template requires ((std::is_base_of_v && !std::is_const_v) || std::is_void_v) inline T* deref(const Handle h) { if (!h) diff --git a/include/nbl/asset/utils/CDirQuantCacheBase.h b/include/nbl/asset/utils/CDirQuantCacheBase.h index 1af32e2e2f..5dd0b14ffd 100644 --- a/include/nbl/asset/utils/CDirQuantCacheBase.h +++ b/include/nbl/asset/utils/CDirQuantCacheBase.h @@ -298,7 +298,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl:: if (!file) return false; - auto buffer = asset::ICPUBuffer::create({ file->getSize() }); + auto buffer = asset::ICPUBuffer::create({ {file->getSize(), {}} }); system::IFile::success_t succ; file->read(succ, buffer->getPointer(), 0, file->getSize()); @@ -347,7 +347,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl:: asset::SBufferRange bufferRange; bufferRange.offset = 0; bufferRange.size = getSerializedCacheSizeInBytes(); - bufferRange.buffer = asset::ICPUBuffer::create({ bufferRange.size }); + bufferRange.buffer = asset::ICPUBuffer::create({ {bufferRange.size, {}} }); saveCacheToBuffer(bufferRange); @@ -484,7 +484,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl:: for (auto corn=0u; corn 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/asset/utils/CGeometryManipulator.h b/include/nbl/asset/utils/CGeometryManipulator.h index f903e69f94..30052d4284 100644 --- a/include/nbl/asset/utils/CGeometryManipulator.h +++ b/include/nbl/asset/utils/CGeometryManipulator.h @@ -29,11 +29,11 @@ class NBL_API2 CGeometryManipulator if (!view || !view.composed.isFormatted()) return {}; auto it = reinterpret_cast(view.src.buffer->getPointer())+view.src.offset; - const auto end = it+view.src.actualSize(); + [[maybe_unused]] const auto end = it+view.src.actualSize(); auto addToAABB = [&](auto& aabb)->void { using aabb_t = std::remove_reference_t; - for (auto i=0; i!=view.getElementCount(); i++) + for (uint64_t i=0; i!=view.getElementCount(); i++) { typename aabb_t::point_t pt; view.decodeElement(i,pt); diff --git a/include/nbl/asset/utils/COBBGenerator.h b/include/nbl/asset/utils/COBBGenerator.h index cf2afcecaa..19154d4ea1 100644 --- a/include/nbl/asset/utils/COBBGenerator.h +++ b/include/nbl/asset/utils/COBBGenerator.h @@ -47,7 +47,7 @@ class COBBGenerator static hlsl::shapes::OBB<> compute(size_t vertexCount, FetchVertexFn&& fetchFn, float epsilon) { // Algorithm from Game Engine Gems 2, Fast Computation of Tight-Fitting Oriented Bounding Box - // Credit to Thomas Larsson and Linus Källberg + // Credit to Thomas Larsson and Linus Källberg constexpr size_t SAMPLE_DIR_COUNT = 7; // Number of sample directions constexpr size_t SAMPLE_COUNT = SAMPLE_DIR_COUNT * 2; @@ -198,7 +198,7 @@ class COBBGenerator { int indexFurthestPair = 0; auto maxSqDist = getSqDist(extremalVertices.maxPtr()[0], extremalVertices.minPtr()[0]); - for (int k = 1; k < SAMPLE_DIR_COUNT; k++) + for (size_t k = 1; k < SAMPLE_DIR_COUNT; k++) { const auto sqDist = getSqDist(extremalVertices.maxPtr()[k], extremalVertices.minPtr()[k]); if (sqDist > maxSqDist) { maxSqDist = sqDist; indexFurthestPair = k; } diff --git a/include/nbl/asset/utils/CPolygonGeometryManipulator.h b/include/nbl/asset/utils/CPolygonGeometryManipulator.h index 4a31bd6a95..d2246c7e37 100644 --- a/include/nbl/asset/utils/CPolygonGeometryManipulator.h +++ b/include/nbl/asset/utils/CPolygonGeometryManipulator.h @@ -79,7 +79,7 @@ class NBL_API2 CPolygonGeometryManipulator const auto& weightView = geo->getJointWeightViews()[weightView_i]; hlsl::float32_t4 weight; weightView.weights.decodeElement(vertex_i, weight); - for (auto channel_i = 0; channel_i < getFormatChannelCount(weightView.weights.composed.format); channel_i++) + for (uint32_t channel_i = 0; channel_i < getFormatChannelCount(weightView.weights.composed.format); channel_i++) if (weight[channel_i] > 0.f) return true; } @@ -151,7 +151,7 @@ class NBL_API2 CPolygonGeometryManipulator if (originalView) return originalView.src.buffer->getUsageFlags(); return core::bitflag(IBuffer::EUF_INDEX_BUFFER_BIT); }(); - auto indexBuffer = ICPUBuffer::create({ primCount * indexing->degree() * indexSize, indexBufferUsages }); + auto indexBuffer = ICPUBuffer::create({{ primCount * indexing->degree() * indexSize, indexBufferUsages }}); auto indexBufferPtr = indexBuffer->getPointer(); auto indexView = ICPUPolygonGeometry::SDataView{ .composed = { diff --git a/include/nbl/asset/utils/CQuantNormalCache.h b/include/nbl/asset/utils/CQuantNormalCache.h index 31b7d403d2..8422b92f7d 100644 --- a/include/nbl/asset/utils/CQuantNormalCache.h +++ b/include/nbl/asset/utils/CQuantNormalCache.h @@ -42,8 +42,8 @@ struct QuantNormalHash static constexpr size_t primeNumber1 = 18446744073709551557ull; static constexpr size_t primeNumber2 = 4611686018427388273ull; - return ((static_cast(static_cast(vec.u)*(std::numeric_limits::max)()) * primeNumber1) ^ - (static_cast(static_cast(vec.v)*(std::numeric_limits::max)()) * primeNumber2)); + return ((static_cast(static_cast(vec.u)*static_cast((std::numeric_limits::max)())) * primeNumber1) ^ + (static_cast(static_cast(vec.v)*static_cast((std::numeric_limits::max)())) * primeNumber2)); } }; diff --git a/include/nbl/asset/utils/CQuantQuaternionCache.h b/include/nbl/asset/utils/CQuantQuaternionCache.h index c4b13e9c38..f8eef627be 100644 --- a/include/nbl/asset/utils/CQuantQuaternionCache.h +++ b/include/nbl/asset/utils/CQuantQuaternionCache.h @@ -46,9 +46,9 @@ struct QuantQuaternionHash static constexpr size_t primeNumber2 = 4611686018427388273ull; static constexpr size_t primeNumber3 = 10278296396886393151ull; - return (static_cast(static_cast(vec.x)*(std::numeric_limits::max)()) * primeNumber1) ^ - (static_cast(static_cast(vec.y)*(std::numeric_limits::max)()) * primeNumber2) ^ - (static_cast(static_cast(vec.z)*(std::numeric_limits::max)()) * primeNumber3); + return (static_cast(static_cast(vec.x)*static_cast((std::numeric_limits::max)())) * primeNumber1) ^ + (static_cast(static_cast(vec.y)*static_cast((std::numeric_limits::max)())) * primeNumber2) ^ + (static_cast(static_cast(vec.z)*static_cast((std::numeric_limits::max)())) * primeNumber3); } }; diff --git a/include/nbl/asset/utils/CVertexHashGrid.h b/include/nbl/asset/utils/CVertexHashGrid.h index ce094fabe4..e7db2dcfed 100644 --- a/include/nbl/asset/utils/CVertexHashGrid.h +++ b/include/nbl/asset/utils/CVertexHashGrid.h @@ -182,7 +182,7 @@ class CVertexHashGrid const auto skipListBound = std::visit([&](auto& sorter) { auto hashBound = sorter.getMostSignificantRadixBound(hash); - return std::pair(m_vertices.begin() + hashBound.first, m_vertices.begin() + hashBound.second); + return std::pair(m_vertices.begin() + hashBound.first, m_vertices.begin() + hashBound.second); }, m_sorter); auto begin = std::lower_bound( diff --git a/include/nbl/asset/utils/CVertexWelder.h b/include/nbl/asset/utils/CVertexWelder.h index 7f6065e2a9..ca0be394a7 100644 --- a/include/nbl/asset/utils/CVertexWelder.h +++ b/include/nbl/asset/utils/CVertexWelder.h @@ -234,7 +234,7 @@ class CVertexWelder { positionView.decodeElement(index, position); auto remappedVertexIndex = INVALID_INDEX; as.forEachBroadphaseNeighborCandidates(position, [&](const typename AccelStructureT::vertex_data_t& candidate) { - const auto neighborRemappedIndex = remappedVertexIndexes[candidate.index]; + [[maybe_unused]] const auto neighborRemappedIndex = remappedVertexIndexes[candidate.index]; // make sure we can only map higher indices to lower indices to disallow loops if (candidate.index outBuffer = ICPUBuffer::create({ outSize }); + nbl::core::smart_refctd_ptr outBuffer = ICPUBuffer::create({ {outSize, {}} }); auto origCode = std::string_view(reinterpret_cast(original->getContent()->getPointer()), origLen); auto outCode = reinterpret_cast(outBuffer->getPointer()); diff --git a/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl b/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl index cbaa0a7b7b..d874ee422d 100644 --- a/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl +++ b/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl @@ -334,7 +334,8 @@ struct transpose_helper { using traits = matrix_traits; // GLM's transpose function signature specializes in terms of the input argument - return reinterpret_cast(glm::transpose(reinterpret_cast(m))); + auto result = glm::transpose(reinterpret_cast(m)); + return reinterpret_cast(result); } }; template @@ -365,9 +366,16 @@ struct find_lsb_helper NBL_CONSTEXPR_FUNC static inline T __call(const T arg) { #pragma warning(suppress: 5063) +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconstant-evaluated" +#endif if constexpr (std::is_constant_evaluated()) +#ifdef __clang__ +#pragma clang diagnostic pop +#endif { - for (T ix = T(0); ix < sizeof(size_t) * 8; ix++) + for (T ix = T(0); ix < T(sizeof(size_t) * 8); ix++) if ((T(1) << ix) & arg) return ix; return ~T(0); } @@ -449,7 +457,8 @@ struct inverse_helper static SquareMatrix __call(NBL_CONST_REF_ARG(SquareMatrix) mat) { using traits = matrix_traits; - return reinterpret_cast(glm::inverse(reinterpret_cast(mat))); + auto result = glm::inverse(reinterpret_cast(mat)); + return reinterpret_cast(result); } }; diff --git a/include/nbl/builtin/hlsl/cpp_compat/promote.hlsl b/include/nbl/builtin/hlsl/cpp_compat/promote.hlsl index 1887f4b51f..0d639300c0 100644 --- a/include/nbl/builtin/hlsl/cpp_compat/promote.hlsl +++ b/include/nbl/builtin/hlsl/cpp_compat/promote.hlsl @@ -3,6 +3,10 @@ #include "nbl/builtin/hlsl/type_traits.hlsl" +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunknown-attributes" +#endif + namespace nbl { namespace hlsl @@ -29,7 +33,7 @@ struct Promote && (concepts array_set setter; To output; [[unroll]] - for (int i = 0; i < vector_traits::Dimension; ++i) + for (uint32_t i = 0u; i < vector_traits::Dimension; ++i) setter(output, i, v); return output; } diff --git a/include/nbl/builtin/hlsl/cpp_compat/truncate.hlsl b/include/nbl/builtin/hlsl/cpp_compat/truncate.hlsl index ffe3d12641..39e8f1eade 100644 --- a/include/nbl/builtin/hlsl/cpp_compat/truncate.hlsl +++ b/include/nbl/builtin/hlsl/cpp_compat/truncate.hlsl @@ -4,6 +4,10 @@ #include "nbl/builtin/hlsl/type_traits.hlsl" #include "nbl/builtin/hlsl/concepts/core.hlsl" +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunknown-attributes" +#endif + namespace nbl { namespace hlsl diff --git a/include/nbl/builtin/hlsl/emulated/float64_t.hlsl b/include/nbl/builtin/hlsl/emulated/float64_t.hlsl index da32fab7b0..edee9db5ed 100644 --- a/include/nbl/builtin/hlsl/emulated/float64_t.hlsl +++ b/include/nbl/builtin/hlsl/emulated/float64_t.hlsl @@ -4,6 +4,10 @@ #include #include +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunknown-attributes" +#endif + namespace nbl { namespace hlsl diff --git a/include/nbl/builtin/hlsl/emulated/vector_t.hlsl b/include/nbl/builtin/hlsl/emulated/vector_t.hlsl index 2192d348b9..846a262467 100644 --- a/include/nbl/builtin/hlsl/emulated/vector_t.hlsl +++ b/include/nbl/builtin/hlsl/emulated/vector_t.hlsl @@ -7,6 +7,10 @@ #include #include +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunknown-attributes" +#endif + namespace nbl { namespace hlsl diff --git a/include/nbl/builtin/hlsl/functional.hlsl b/include/nbl/builtin/hlsl/functional.hlsl index 118fe07c63..64fa1c0a24 100644 --- a/include/nbl/builtin/hlsl/functional.hlsl +++ b/include/nbl/builtin/hlsl/functional.hlsl @@ -10,6 +10,9 @@ #include "nbl/builtin/hlsl/concepts/vector.hlsl" #include "nbl/builtin/hlsl/array_accessors.hlsl" +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunknown-attributes" +#endif namespace nbl { diff --git a/include/nbl/builtin/hlsl/ieee754.hlsl b/include/nbl/builtin/hlsl/ieee754.hlsl index af23d6f07d..411a0b80a5 100644 --- a/include/nbl/builtin/hlsl/ieee754.hlsl +++ b/include/nbl/builtin/hlsl/ieee754.hlsl @@ -106,7 +106,6 @@ NBL_CONSTEXPR_FUNC T fastMulExp2(T x, int n) template NBL_CONSTEXPR_FUNC typename unsigned_integer_of_size::type extractMantissa(T x) { - using AsUint = typename unsigned_integer_of_size::type; return ieee754::impl::bitCastToUintType(x) & traits::type>::mantissaMask; } diff --git a/include/nbl/builtin/hlsl/limits.hlsl b/include/nbl/builtin/hlsl/limits.hlsl index fa9edc3bde..3653906798 100644 --- a/include/nbl/builtin/hlsl/limits.hlsl +++ b/include/nbl/builtin/hlsl/limits.hlsl @@ -12,7 +12,14 @@ // C++ headers #ifndef __HLSL_VERSION #include +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonportable-include-path" +#endif #include "IMath/halfLimits.h" +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #endif /* @@ -280,7 +287,14 @@ struct numeric_limits : std::numeric_limits NBL_CONSTEXPR_STATIC_INLINE uint_type quiet_NaN = std::bit_cast(base::quiet_NaN()); NBL_CONSTEXPR_STATIC_INLINE uint_type signaling_NaN = std::bit_cast(base::signaling_NaN()); +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnan-infinity-disabled" +#endif NBL_CONSTEXPR_STATIC_INLINE uint_type infinity = std::bit_cast(base::infinity()); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif }; #endif diff --git a/include/nbl/builtin/hlsl/math/functions.hlsl b/include/nbl/builtin/hlsl/math/functions.hlsl index a1c51d4e51..a632498424 100644 --- a/include/nbl/builtin/hlsl/math/functions.hlsl +++ b/include/nbl/builtin/hlsl/math/functions.hlsl @@ -148,7 +148,14 @@ struct conditionalAbsOrMax_helper::scalar_type)>; const int dimensionOfT = vector_traits::Dimension; using Uint32VectorWithDimensionOfT = vector; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-local-typedef" +#endif using scalar_type = typename vector_traits::scalar_type; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif Uint32VectorWithDimensionOfT xAsUintVec = bit_cast(x); diff --git a/include/nbl/builtin/hlsl/math/linalg/basic.hlsl b/include/nbl/builtin/hlsl/math/linalg/basic.hlsl index 15b9014998..64f923a521 100644 --- a/include/nbl/builtin/hlsl/math/linalg/basic.hlsl +++ b/include/nbl/builtin/hlsl/math/linalg/basic.hlsl @@ -42,7 +42,7 @@ MatT identity() } template truncate(const NBL_CONST_REF_ARG(matrix) inMatrix) +inline matrix truncate(NBL_CONST_REF_ARG(matrix) inMatrix) { matrix retval; diff --git a/include/nbl/builtin/hlsl/surface_transform.h b/include/nbl/builtin/hlsl/surface_transform.h index 0c9b54ce5a..a3436b4207 100644 --- a/include/nbl/builtin/hlsl/surface_transform.h +++ b/include/nbl/builtin/hlsl/surface_transform.h @@ -61,7 +61,7 @@ inline float32_t2x2 transformMatrix(const FLAG_BITS transform) default: break; } - const float _nan = numeric_limits::signaling_NaN; + const float _nan = static_cast(numeric_limits::signaling_NaN); return float32_t2x2(_nan,_nan,_nan,_nan); } diff --git a/include/nbl/builtin/hlsl/tgmath/impl.hlsl b/include/nbl/builtin/hlsl/tgmath/impl.hlsl index 4d1a30c757..69876c244d 100644 --- a/include/nbl/builtin/hlsl/tgmath/impl.hlsl +++ b/include/nbl/builtin/hlsl/tgmath/impl.hlsl @@ -17,6 +17,10 @@ #include #endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wunknown-pragmas" +#endif + namespace nbl { namespace hlsl 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/alloc/GeneralpurposeAddressAllocator.h b/include/nbl/core/alloc/GeneralpurposeAddressAllocator.h index 18dc4bf391..54c49fde86 100644 --- a/include/nbl/core/alloc/GeneralpurposeAddressAllocator.h +++ b/include/nbl/core/alloc/GeneralpurposeAddressAllocator.h @@ -184,7 +184,7 @@ class GeneralpurposeAddressAllocatorBase //! trims the start of a free block to satisfy the alignment constraint of the start and also the minimum block size of the preceeding free space that would be created inline bool alignBlockStart(Block& newBlock, const Block& origBlock, const size_type alignment) const { - newBlock.startOffset = core::roundUp(origBlock.startOffset,alignment); + newBlock.startOffset = hlsl::roundUp(origBlock.startOffset,alignment); #ifdef _NBL_DEBUG assert(&newBlock!=&origBlock); @@ -193,7 +193,7 @@ class GeneralpurposeAddressAllocatorBase { auto initialPreceedingBlockSize = newBlock.startOffset-origBlock.startOffset; if (initialPreceedingBlockSizeBase::maxRequestableAlignment) return invalid_address; - size_type result = core::roundUp(cursor,alignment); + size_type result = hlsl::roundUp(cursor,alignment); size_type newCursor = result+bytes; if (newCursor>bufferSize || newCursor(n_blocks); for (size_t i = 0u; i < n_blocks; ++i) + { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif std::atomic_init(m_flags.get() + i, 0ul); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + } } T* getStorage() @@ -96,7 +105,7 @@ class CConstantRuntimeSizedCircularBufferBase : public CCircularBufferCommonBase template class CCompileTimeSizedCircularBufferBase : public CCircularBufferCommonBase { - static_assert(core::isPoT(S), "Circular buffer capacity must be PoT!"); + static_assert(hlsl::isPoT(S), "Circular buffer capacity must be PoT!"); static constexpr inline auto StorageSize = sizeof(T) * S; @@ -334,7 +343,7 @@ class CCircularBufferBase : public Base #ifdef _NBL_DEBUG if constexpr (!AllowOverflows) { - bool alive = isAlive(ix); + [[maybe_unused]] bool alive = isAlive(ix); assert(alive); } #endif diff --git a/include/nbl/core/containers/DoublyLinkedList.h b/include/nbl/core/containers/DoublyLinkedList.h index af7edcc01a..cdd8a566b6 100644 --- a/include/nbl/core/containers/DoublyLinkedList.h +++ b/include/nbl/core/containers/DoublyLinkedList.h @@ -398,7 +398,7 @@ class DoublyLinkedList::Iterator { using base_iterable_t = DoublyLinkedList; using iterable_t = std::conditional_t; - friend class base_iterable_t; + friend base_iterable_t; public: using value_type = std::conditional_t; using pointer = value_type*; diff --git a/include/nbl/core/def/smart_refctd_ptr.h b/include/nbl/core/def/smart_refctd_ptr.h index 133d6438e8..404660be48 100644 --- a/include/nbl/core/def/smart_refctd_ptr.h +++ b/include/nbl/core/def/smart_refctd_ptr.h @@ -85,6 +85,10 @@ inline smart_refctd_ptr& smart_refctd_ptr inline smart_refctd_ptr make_smart_refctd_ptr(Args&& ... args) { @@ -92,6 +96,9 @@ inline smart_refctd_ptr make_smart_refctd_ptr(Args&& ... args) smart_refctd_ptr smart(obj, dont_grab); return smart; } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif template< class U, class T > diff --git a/include/nbl/core/hash/blake.h b/include/nbl/core/hash/blake.h index fb91c9969f..9d9df46a49 100644 --- a/include/nbl/core/hash/blake.h +++ b/include/nbl/core/hash/blake.h @@ -4,12 +4,13 @@ #ifndef _NBL_CORE_HASH_BLAKE3_H_INCLUDED_ #define _NBL_CORE_HASH_BLAKE3_H_INCLUDED_ - #include "nbl/config/BuildConfigOptions.h" #include "blake3.h" #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 { @@ -32,7 +33,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)); } }; @@ -113,7 +115,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/math/floatutil.h b/include/nbl/core/math/floatutil.h index d66e3d6275..758c8cf0b2 100644 --- a/include/nbl/core/math/floatutil.h +++ b/include/nbl/core/math/floatutil.h @@ -1,6 +1,11 @@ // Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O. // This file is part of the "Nabla Engine". // For conditions of distribution and use, see copyright notice in nabla.h +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnan-infinity-disabled" +#endif + #ifndef _NBL_CORE_FLOAT_UTIL_H_INCLUDED_ #define _NBL_CORE_FLOAT_UTIL_H_INCLUDED_ @@ -361,3 +366,7 @@ uint32_t floatBitsToUint(float&& _f); } #endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file 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/nbl/core/sampling/OwenSampler.h b/include/nbl/core/sampling/OwenSampler.h index c51362472d..62a3c5b34c 100644 --- a/include/nbl/core/sampling/OwenSampler.h +++ b/include/nbl/core/sampling/OwenSampler.h @@ -75,9 +75,9 @@ namespace core #ifdef _NBL_DEBUG for (uint32_t j=0u; j>1u)]); } diff --git a/include/nbl/core/util/bitflag.h b/include/nbl/core/util/bitflag.h index 62bec57d49..9dccf319d5 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);} }; 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/include/nbl/system/CColoredStdoutLoggerWin32.h b/include/nbl/system/CColoredStdoutLoggerWin32.h index 6f3bbd1ebf..1934a9d177 100644 --- a/include/nbl/system/CColoredStdoutLoggerWin32.h +++ b/include/nbl/system/CColoredStdoutLoggerWin32.h @@ -36,11 +36,15 @@ class NBL_API2 CColoredStdoutLoggerWin32 : public IThreadsafeLogger { return 11; } - case ELL_NONE: + case ELL_NONE: { assert(false); // how did this happen?? Btw, do we even need this log level? break; } + case ELL_ALL: + { + break; + } } return 0; } diff --git a/include/nbl/system/CSystemWin32.h b/include/nbl/system/CSystemWin32.h index 01766ddaa8..ddc70c3209 100644 --- a/include/nbl/system/CSystemWin32.h +++ b/include/nbl/system/CSystemWin32.h @@ -74,7 +74,7 @@ class NBL_API2 CSystemWin32 : public ISystem if(logRequests) printf("[INFO]: Requesting \"%s\" module load with \"%s\" search path...\n", dllName, path.c_str()); - if (res = LoadLibraryExA(path.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) + if ((res = LoadLibraryExA(path.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH))) break; } @@ -85,7 +85,7 @@ class NBL_API2 CSystemWin32 : public ISystem if (logRequests) printf("[INFO]: Requesting \"%s\" module load with \"%s\" search path...\n", dllName, path.c_str()); - if (res = LoadLibraryExA(path.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) + if ((res = LoadLibraryExA(path.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH))) break; } } diff --git a/include/nbl/system/IApplicationFramework.h b/include/nbl/system/IApplicationFramework.h index 44d3de0427..57171b89ce 100644 --- a/include/nbl/system/IApplicationFramework.h +++ b/include/nbl/system/IApplicationFramework.h @@ -150,11 +150,11 @@ class IApplicationFramework : public core::IReferenceCounted if (!GlobalsInit()) return nullptr; - #ifdef _NBL_PLATFORM_WINDOWS_ - return nbl::core::make_smart_refctd_ptr(); - #elif defined(_NBL_PLATFORM_ANDROID_) - return nullptr; - #endif +#ifdef _NBL_PLATFORM_WINDOWS_ + return nbl::core::make_smart_refctd_ptr(); +#elif defined(_NBL_PLATFORM_ANDROID_) + return nullptr; +#endif return nullptr; } diff --git a/include/nbl/system/IAsyncQueueDispatcher.h b/include/nbl/system/IAsyncQueueDispatcher.h index d5b0cb8a1a..cadfbc23d7 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" @@ -49,7 +51,7 @@ class IAsyncQueueDispatcherBase //! ANY THREAD [except worker]: via cancellable_future_t::cancel inline void cancel() { - const auto prev = state.exchangeNotify(STATE::CANCELLED); + [[maybe_unused]] const auto prev = state.exchangeNotify(STATE::CANCELLED); // If we were in EXECUTING then worker thread is definitely stuck in `base_t::disassociate_request` spinlock assert(prev==STATE::PENDING || prev==STATE::EXECUTING); // sanity check, but its not our job to set it to nullptr @@ -202,7 +204,7 @@ class IAsyncQueueDispatcherBase //! Utility to write less code, WILL ASSERT IF IT FAILS! So don't use on futures that might be cancelled or fail. inline T copy() const { - const bool success = wait(); + [[maybe_unused]] const bool success = wait(); assert(success); return *get(); } @@ -347,7 +349,7 @@ class IAsyncQueueDispatcherBase inline void associate_request(request_base_t* req) override final { base_t::associate_request(req); - request_base_t* prev = request.exchange(req); + [[maybe_unused]] request_base_t* prev = request.exchange(req); // sanity check assert(prev==nullptr); } @@ -356,7 +358,7 @@ class IAsyncQueueDispatcherBase if (base_t::disassociate_request()) { // only assign if we didn't get cancelled mid-way, otherwise will mess up `associate_request` sanity checks - request_base_t* prev = request.exchange(nullptr); + [[maybe_unused]] request_base_t* prev = request.exchange(nullptr); assert(prev && prev->getState().query()==request_base_t::STATE::EXECUTING); return true; } @@ -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/include/nbl/system/IFileArchive.h b/include/nbl/system/IFileArchive.h index 3fdc518cb1..5cda75ca58 100644 --- a/include/nbl/system/IFileArchive.h +++ b/include/nbl/system/IFileArchive.h @@ -142,7 +142,7 @@ class IFileArchive : public core::IReferenceCounted inline const SFileList::found_t getItemFromPath(const system::path& pathRelativeToArchive) const { - const SFileList::SEntry itemToFind = { pathRelativeToArchive }; + const SFileList::SEntry itemToFind = { pathRelativeToArchive, 0ull, 0ull , 0u, EAT_NULL }; // calling `listAssets` makes sure any "update list" overload can kick in auto items = listAssets(); const auto span = SFileList::span_t(items); diff --git a/include/nbl/system/IFileBase.h b/include/nbl/system/IFileBase.h index c9ceb13a04..10d677f839 100644 --- a/include/nbl/system/IFileBase.h +++ b/include/nbl/system/IFileBase.h @@ -83,7 +83,7 @@ class IFileBase : public core::IReferenceCounted // this is an abstract interface class so this stays protected explicit IFileBase(path&& _filename, const core::bitflag _flags, const time_point_t _initialModified) : - m_filename(std::move(_filename)), m_flags(_flags), m_modified(_initialModified) {} + m_filename(std::move(_filename)), m_modified(_initialModified), m_flags(_flags) {} private: const path m_filename; diff --git a/include/nbl/system/ILogger.h b/include/nbl/system/ILogger.h index db013ebeb4..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); } } @@ -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()); @@ -70,11 +69,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]", 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) @@ -96,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 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/include/nbl/system/atomic_state.h b/include/nbl/system/atomic_state.h index 41ee532596..8fc5e218c1 100644 --- a/include/nbl/system/atomic_state.h +++ b/include/nbl/system/atomic_state.h @@ -17,7 +17,7 @@ class atomic_state_t { static_assert(std::atomic_uint32_t::is_always_lock_free); // must have been consumed before exit ! - const auto atExit = state.load(); + [[maybe_unused]] const auto atExit = state.load(); assert(static_cast(atExit)==kInitial); } @@ -78,7 +78,7 @@ class atomic_state_t template inline void exchangeNotify(const STATE to, const STATE expected) { - const auto prev = exchangeNotify(to); + [[maybe_unused]] const auto prev = exchangeNotify(to); assert(static_cast(prev)==expected); } diff --git a/include/nbl/system/to_string.h b/include/nbl/system/to_string.h index 2a06ace5e5..d6a3e6729c 100644 --- a/include/nbl/system/to_string.h +++ b/include/nbl/system/to_string.h @@ -83,7 +83,7 @@ struct to_string_helper> using value_t = hlsl::morton::code; static std::string __call(value_t value) { - return to_string_helper::__call(value.value); + return to_string_helper::__call(value.value); } }; diff --git a/include/nbl/ui/IWindowManager.h b/include/nbl/ui/IWindowManager.h index ffa83b525f..5c778dd7f2 100644 --- a/include/nbl/ui/IWindowManager.h +++ b/include/nbl/ui/IWindowManager.h @@ -24,7 +24,7 @@ class NBL_API2 IWindowManager : public virtual core::IReferenceCounted inline bool setWindowSize(IWindow* window, const uint32_t width, const uint32_t height) { - auto cb = window->getEventCallback(); + [[maybe_unused]] auto cb = window->getEventCallback(); if (window->getManager()!=this || !window->canProgrammaticallyResize()) return false; @@ -33,7 +33,7 @@ class NBL_API2 IWindowManager : public virtual core::IReferenceCounted inline bool setWindowPosition(IWindow* window, const int32_t x, const int32_t y) { - auto cb = window->getEventCallback(); + [[maybe_unused]] auto cb = window->getEventCallback(); if (window->getManager()!=this) return false; @@ -44,7 +44,7 @@ class NBL_API2 IWindowManager : public virtual core::IReferenceCounted { // TODO /* - auto cb = window->getEventCallback(); + [[maybe_unused]] auto cb = window->getEventCallback(); if (window->getManager() != this || !window->canRotate() || landscape == window->isRotationLandscape()) return false; @@ -55,7 +55,7 @@ class NBL_API2 IWindowManager : public virtual core::IReferenceCounted inline bool show(IWindow* window) { - auto cb = window->getEventCallback(); + [[maybe_unused]] auto cb = window->getEventCallback(); if (window->getManager() != this || !window->isHidden()) return false; @@ -64,7 +64,7 @@ class NBL_API2 IWindowManager : public virtual core::IReferenceCounted inline bool hide(IWindow* window) { - auto cb = window->getEventCallback(); + [[maybe_unused]] auto cb = window->getEventCallback(); if (window->getManager() != this || window->isHidden()) return false; @@ -73,7 +73,7 @@ class NBL_API2 IWindowManager : public virtual core::IReferenceCounted inline bool maximize(IWindow* window) { - auto cb = window->getEventCallback(); + [[maybe_unused]] auto cb = window->getEventCallback(); if (window->getManager() != this || window->isMaximized()) return false; @@ -82,7 +82,7 @@ class NBL_API2 IWindowManager : public virtual core::IReferenceCounted inline bool minimize(IWindow* window) { - auto cb = window->getEventCallback(); + [[maybe_unused]] auto cb = window->getEventCallback(); if (window->getManager() != this || window->isMinimized()) return false; diff --git a/include/nbl/ui/KeyCodes.h b/include/nbl/ui/KeyCodes.h index b6d05aed36..27ce5e8756 100644 --- a/include/nbl/ui/KeyCodes.h +++ b/include/nbl/ui/KeyCodes.h @@ -207,6 +207,7 @@ constexpr char keyCodeToChar(E_KEY_CODE code, bool shiftPressed) case EKC_CLOSE_BRACKET: result = ']'; break; case EKC_BACKSLASH: result = '\\'; break; case EKC_APOSTROPHE: result = '\''; break; + default: break; } } else @@ -261,6 +262,7 @@ constexpr char keyCodeToChar(E_KEY_CODE code, bool shiftPressed) case EKC_CLOSE_BRACKET: result = '}'; break; case EKC_BACKSLASH: result = '|'; break; case EKC_APOSTROPHE: result = '\"'; break; + default: break; } } return result; diff --git a/include/nbl/video/CThreadSafeQueueAdapter.h b/include/nbl/video/CThreadSafeQueueAdapter.h index b9da2c1a6f..900bafd1bb 100644 --- a/include/nbl/video/CThreadSafeQueueAdapter.h +++ b/include/nbl/video/CThreadSafeQueueAdapter.h @@ -60,7 +60,7 @@ class CThreadSafeQueueAdapter final : public IQueue return originalQueue; } - inline const void* getNativeHandle() const + inline const void* getNativeHandle() const override { return originalQueue->getNativeHandle(); } diff --git a/include/nbl/video/CVulkanCommon.h b/include/nbl/video/CVulkanCommon.h index e4dfb7e3e9..564ffec943 100644 --- a/include/nbl/video/CVulkanCommon.h +++ b/include/nbl/video/CVulkanCommon.h @@ -315,6 +315,9 @@ inline ISurface::SColorSpace getColorSpaceFromVkColorSpaceKHR(VkColorSpaceKHR in result.primary = asset::ECP_SRGB; result.eotf = asset::EOTF_UNKNOWN; } break; + + default: + break; } return result; diff --git a/include/nbl/video/CVulkanConnection.h b/include/nbl/video/CVulkanConnection.h index f95c11e6b7..dbbd4b60d1 100644 --- a/include/nbl/video/CVulkanConnection.h +++ b/include/nbl/video/CVulkanConnection.h @@ -35,7 +35,7 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection protected: explicit inline CVulkanConnection(const VkInstance instance, const SFeatures& enabledFeatures, std::unique_ptr&& debugCallback, const VkDebugUtilsMessengerEXT vk_debugMessenger) - : IAPIConnection(enabledFeatures), m_vkInstance(instance), m_debugCallback(std::move(debugCallback)), m_vkDebugUtilsMessengerEXT(vk_debugMessenger) + : IAPIConnection(enabledFeatures), m_vkInstance(instance), m_vkDebugUtilsMessengerEXT(vk_debugMessenger), m_debugCallback(std::move(debugCallback)) { flag.clear(); } diff --git a/include/nbl/video/CVulkanDeviceMemoryBacked.h b/include/nbl/video/CVulkanDeviceMemoryBacked.h index e6d17ddf3e..c05da62267 100644 --- a/include/nbl/video/CVulkanDeviceMemoryBacked.h +++ b/include/nbl/video/CVulkanDeviceMemoryBacked.h @@ -22,7 +22,7 @@ class CVulkanDeviceMemoryBacked : public Interface using VkResource_t = const std::conditional_t; public: - inline IDeviceMemoryBacked::SMemoryBinding getBoundMemory() const {return {m_memory.get(),m_offset};} + inline IDeviceMemoryBacked::SMemoryBinding getBoundMemory() const override {return {m_memory.get(),m_offset};} inline void setMemoryBinding(const IDeviceMemoryBacked::SMemoryBinding& binding) { m_memory = core::smart_refctd_ptr(binding.memory); diff --git a/include/nbl/video/IDescriptorPool.h b/include/nbl/video/IDescriptorPool.h index 78f1ef6c87..c27db2c799 100644 --- a/include/nbl/video/IDescriptorPool.h +++ b/include/nbl/video/IDescriptorPool.h @@ -66,7 +66,8 @@ class NBL_API2 IDescriptorPool : public IBackendObject inline core::smart_refctd_ptr createDescriptorSet(core::smart_refctd_ptr&& layout) { core::smart_refctd_ptr set; - const bool result = createDescriptorSets(1, &layout.get(), &set); + const IGPUDescriptorSetLayout* const pLayout = layout.get(); + const bool result = createDescriptorSets({&pLayout, 1}, &set); if (result) return set; else diff --git a/include/nbl/video/IDeviceMemoryAllocator.h b/include/nbl/video/IDeviceMemoryAllocator.h index e85eec12a0..9be6c7ff75 100644 --- a/include/nbl/video/IDeviceMemoryAllocator.h +++ b/include/nbl/video/IDeviceMemoryAllocator.h @@ -46,7 +46,7 @@ class NBL_API2 IDeviceMemoryAllocator { public: IMemoryTypeIterator(const IDeviceMemoryBacked::SDeviceMemoryRequirements& reqs, core::bitflag allocateFlags) - : m_allocateFlags(static_cast(allocateFlags.value)), m_reqs(reqs) {} + : m_reqs(reqs), m_allocateFlags(static_cast(allocateFlags.value)) {} static inline uint32_t end() {return 32u;} diff --git a/include/nbl/video/IGPUAccelerationStructure.h b/include/nbl/video/IGPUAccelerationStructure.h index 3c10a255a2..27108bb9ec 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 @@ -221,7 +222,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; @@ -448,7 +449,7 @@ class IGPUTopLevelAccelerationStructure : public asset::ITopLevelAccelerationStr return false; const bool arrayOfPointers = instanceDataTypeEncodedInPointersLSB; - constexpr bool HostBuild = std::is_same_v; + [[maybe_unused]] constexpr bool HostBuild = std::is_same_v; // I'm not gonna do the `std::conditional_t` to get the correct Instance struct type as they're the same size essentially const size_t instanceSize = arrayOfPointers ? sizeof(void*):( dstAS->getCreationParams().flags.hasFlags(IGPUAccelerationStructure::SCreationParams::FLAGS::MOTION_BIT) ? sizeof(DevicePolymorphicInstance):sizeof(DeviceStaticInstance) @@ -709,7 +710,7 @@ class IGPUTopLevelAccelerationStructure : public asset::ITopLevelAccelerationStr if (!tracked || !pBLASes) return; auto it = pBLASes->begin(); - for (auto i = 0; istd::numeric_limits::max()-scissor.offset.x) + if (scissor.extent.width>static_cast(std::numeric_limits::max()-scissor.offset.x)) return false; - if (scissor.extent.height>std::numeric_limits::max()-scissor.offset.y) + if (scissor.extent.height>static_cast(std::numeric_limits::max()-scissor.offset.y)) return false; } @@ -483,7 +483,7 @@ class NBL_API2 IGPUCommandBuffer : public IBackendObject // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdClearAttachments.html#VUID-vkCmdClearAttachments-attachmentCount-arraylength // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdClearAttachments.html#VUID-vkCmdClearAttachments-rectCount-arraylength // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdClearAttachments.html#VUID-vkCmdClearAttachments-layerCount-01934 - if (regions.empty() || !clearDepth && !clearStencil && clearColorMask==0) + if (regions.empty() || (!clearDepth && !clearStencil && clearColorMask==0)) return false; for (const auto& region : regions) diff --git a/include/nbl/video/IGPUCommandPool.h b/include/nbl/video/IGPUCommandPool.h index ddc4fcfd5c..881e97d4bc 100644 --- a/include/nbl/video/IGPUCommandPool.h +++ b/include/nbl/video/IGPUCommandPool.h @@ -269,7 +269,7 @@ class IGPUCommandPool : public IBackendObject } m_header; public: - static inline constexpr uint32_t STORAGE_SIZE = COMMAND_SEGMENT_SIZE - core::roundUp(sizeof(header_t), alignof(ICommand)); + static inline constexpr uint32_t STORAGE_SIZE = COMMAND_SEGMENT_SIZE - hlsl::roundUp(sizeof(header_t), alignof(ICommand)); CCommandSegment(CCommandSegment* prev): m_header(nullptr, 0u, 0u, alignof(ICommand), STORAGE_SIZE) @@ -337,7 +337,14 @@ class IGPUCommandPool : public IBackendObject void wipeNextCommandSize() { const auto nextCmdOffset = m_header.commandAllocator.get_allocated_size(); +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winvalid-offsetof" +#endif const auto wipeEnd = nextCmdOffset + offsetof(IGPUCommandPool::ICommand, m_size) + sizeof(IGPUCommandPool::ICommand::m_size); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif if (wipeEnd < m_header.commandAllocator.get_total_size()) *(const_cast(&(reinterpret_cast(m_data + nextCmdOffset)->m_size))) = 0; } @@ -517,7 +524,7 @@ class IGPUCommandPool::CBindDescriptorSetsCmd final : public IFixedSizeCommand&& pipelineLayout, const uint32_t setCount, const IGPUDescriptorSet* const* const sets) : m_layout(std::move(pipelineLayout)) { - for (auto i = 0; i < setCount; ++i) + for (uint32_t i = 0; i < setCount; ++i) { assert(i < IGPUPipelineLayout::DESCRIPTOR_SET_COUNT); m_sets[i] = core::smart_refctd_ptr(sets[i]); @@ -620,7 +627,7 @@ class IGPUCommandPool::CBindVertexBuffersCmd final : public IFixedSizeCommand* const pBindings) { - for (auto i=0; i(pBindings[i].buffer); } diff --git a/include/nbl/video/IGPUDescriptorSet.h b/include/nbl/video/IGPUDescriptorSet.h index 2028623e1c..330ba32332 100644 --- a/include/nbl/video/IGPUDescriptorSet.h +++ b/include/nbl/video/IGPUDescriptorSet.h @@ -118,7 +118,7 @@ class IGPUDescriptorSet : public asset::IDescriptorSet* getDescriptors(const asset::IDescriptor::E_TYPE type, const redirect_t::binding_number_t binding) const { const auto localOffset = getLayout()->getDescriptorRedirect(type).getStorageOffset(binding).data; - if (localOffset == ~0) + if (localOffset == ~0u) return nullptr; auto* descriptors = getAllDescriptors(type); @@ -132,7 +132,7 @@ class IGPUDescriptorSet : public asset::IDescriptorSet* getDescriptors(const asset::IDescriptor::E_TYPE type, const redirect_t::storage_range_index_t bindingStorageIndex) const { const auto localOffset = getLayout()->getDescriptorRedirect(type).getStorageOffset(bindingStorageIndex).data; - if (localOffset == ~0) + if (localOffset == ~0u) return nullptr; auto* descriptors = getAllDescriptors(type); diff --git a/include/nbl/video/IGPUImage.h b/include/nbl/video/IGPUImage.h index e26e5d254b..f3be99467f 100644 --- a/include/nbl/video/IGPUImage.h +++ b/include/nbl/video/IGPUImage.h @@ -18,6 +18,8 @@ namespace nbl::video class IGPUImage : public asset::IImage, public IDeviceMemoryBacked { public: + using asset::IImage::validateCopies; + enum class TILING : uint8_t { OPTIMAL, diff --git a/include/nbl/video/IGPUPipeline.h b/include/nbl/video/IGPUPipeline.h index c22ad998db..bed110a341 100644 --- a/include/nbl/video/IGPUPipeline.h +++ b/include/nbl/video/IGPUPipeline.h @@ -138,7 +138,7 @@ class IGPUPipeline : public IBackendObject, public PipelineNonBackendObjectBase, template explicit IGPUPipeline(core::smart_refctd_ptr&& device, Args&&... args) : - PipelineNonBackendObjectBase(std::forward(args)...), IBackendObject(std::move(device)) + IBackendObject(std::move(device)), PipelineNonBackendObjectBase(std::forward(args)...) {} virtual ~IGPUPipeline() = default; diff --git a/include/nbl/video/ILogicalDevice.h b/include/nbl/video/ILogicalDevice.h index 180342e2d4..d86a59306e 100644 --- a/include/nbl/video/ILogicalDevice.h +++ b/include/nbl/video/ILogicalDevice.h @@ -325,7 +325,14 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe } inline bool bindImageMemory(const std::span bindInfos) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif return bindImageMemory(bindInfos.size(),bindInfos.data()); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } //! Descriptor Creation @@ -424,78 +431,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, @@ -807,7 +749,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); } @@ -1258,7 +1200,7 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe } } // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkComputePipelineCreateInfo.html#VUID-VkComputePipelineCreateInfo-flags-07985 - else if (ci.basePipelineIndex < -1 || ci.basePipelineIndex >= i || ci.basePipelineIndex >= 0 && !params[ci.basePipelineIndex].getFlags().hasFlags(AllowDerivativesFlag)) + else if (ci.basePipelineIndex < -1 || ci.basePipelineIndex >= i || (ci.basePipelineIndex >= 0 && !params[ci.basePipelineIndex].getFlags().hasFlags(AllowDerivativesFlag))) { NBL_LOG_ERROR("Invalid basePipeline was specified (params[%d])", i); return {}; @@ -1483,7 +1425,7 @@ inline bool ILogicalDevice::validateMemoryBarrier(const uint32_t queueFamilyInde if constexpr (std::is_same_v) { // TODO: better check for queue family ownership transfer - const bool ownershipTransfer = barrier.barrier.otherQueueFamilyIndex!=IQueue::FamilyIgnored; + [[maybe_unused]] const bool ownershipTransfer = barrier.barrier.otherQueueFamilyIndex!=IQueue::FamilyIgnored; inner = &barrier.barrier.dep; } else @@ -1602,6 +1544,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/include/nbl/video/ISemaphore.h b/include/nbl/video/ISemaphore.h index d4fbdd1756..65e98da7c6 100644 --- a/include/nbl/video/ISemaphore.h +++ b/include/nbl/video/ISemaphore.h @@ -95,7 +95,7 @@ class ISemaphore : public IBackendObject } inline ~future_t() { - const auto success = wait(); + [[maybe_unused]] const auto success = wait(); assert(success!=WAIT_RESULT::TIMEOUT); storage_t::destruct(); } diff --git a/include/nbl/video/ISwapchain.h b/include/nbl/video/ISwapchain.h index 882ac16648..b66a38e9c3 100644 --- a/include/nbl/video/ISwapchain.h +++ b/include/nbl/video/ISwapchain.h @@ -547,7 +547,7 @@ class ISwapchain : public IBackendObject core::smart_refctd_ptr m_oldSwapchain; private: - friend class CCleanupSwapchainReference; + friend struct CCleanupSwapchainReference; // inline void freeImageExists(const uint8_t ix) { diff --git a/include/nbl/video/TimelineEventHandlers.h b/include/nbl/video/TimelineEventHandlers.h index a3d6aa4c8b..29b16decae 100644 --- a/include/nbl/video/TimelineEventHandlers.h +++ b/include/nbl/video/TimelineEventHandlers.h @@ -42,7 +42,7 @@ class TimelineEventHandlerST final : public TimelineEventHandlerBase public: // Theoretically could make a factory function cause passing a null semaphore is invalid, but counting on users to be relatively intelligent. inline TimelineEventHandlerST(core::smart_refctd_ptr&& sema, const uint64_t initialCapacity=4095/sizeof(FunctorValuePair)+1) : - TimelineEventHandlerBase(std::move(sema)), m_greatestLatch(0), m_greatestSignal(m_sema->getCounterValue()) {} + TimelineEventHandlerBase(std::move(sema)), m_greatestSignal(m_sema->getCounterValue()), m_greatestLatch(0) {} // If you don't want to deadlock here, look into the `abort*` family of methods ~TimelineEventHandlerST() { diff --git a/include/nbl/video/alloc/StreamingTransientDataBuffer.h b/include/nbl/video/alloc/StreamingTransientDataBuffer.h index 44720f968c..e97c00b557 100644 --- a/include/nbl/video/alloc/StreamingTransientDataBuffer.h +++ b/include/nbl/video/alloc/StreamingTransientDataBuffer.h @@ -41,7 +41,7 @@ class StreamingTransientDataBuffer assert(getBuffer()->getBoundMemory().memory->isMappable()); assert(getBuffer()->getBoundMemory().memory->getMappedPointer()); // we're suballocating from a buffer, whole buffer needs to be reachable from the mapped pointer - const auto mappedRange = getBuffer()->getBoundMemory().memory->getMappedRange(); + [[maybe_unused]] const auto mappedRange = getBuffer()->getBoundMemory().memory->getMappedRange(); assert(mappedRange.offset<=getBuffer()->getBoundMemory().offset); assert(mappedRange.offset+mappedRange.length>=getBuffer()->getBoundMemory().offset+getBuffer()->getSize()); } diff --git a/include/nbl/video/alloc/SubAllocatedDescriptorSet.h b/include/nbl/video/alloc/SubAllocatedDescriptorSet.h index e0d23ea8b1..b7c6ff71ca 100644 --- a/include/nbl/video/alloc/SubAllocatedDescriptorSet.h +++ b/include/nbl/video/alloc/SubAllocatedDescriptorSet.h @@ -34,8 +34,8 @@ class SubAllocatedDescriptorSet : public core::IReferenceCounted inline DeferredFreeFunctor(SubAllocatedDescriptorSet* composed, uint32_t binding, size_type count, const value_type* addresses, const T*const *const objectsToHold) : m_addresses(core::make_refctd_dynamic_array>(count)) , m_objectsToHold(core::make_refctd_dynamic_array>(count)) - , m_binding(binding) , m_composed(composed) + , m_binding(binding) { memcpy(m_addresses->data(), addresses, count * sizeof(value_type)); for (size_t i=0u; i inline container_t::iterator find(const lookup_t& assetAndPatch) { - return std::get>(m_containers).find>(assetAndPatch); + return std::get>(m_containers).template find>(assetAndPatch); } template inline container_t::const_iterator find(const lookup_t& assetAndPatch) const { - return std::get>(m_containers).find>(assetAndPatch); + return std::get>(m_containers).template find>(assetAndPatch); } template inline container_t::const_iterator end() const diff --git a/include/nbl/video/utilities/CComputeBlit.h b/include/nbl/video/utilities/CComputeBlit.h index c191fb9cda..b75b5c33d2 100644 --- a/include/nbl/video/utilities/CComputeBlit.h +++ b/include/nbl/video/utilities/CComputeBlit.h @@ -134,7 +134,7 @@ class CComputeBlit : public core::IReferenceCounted } // atomicAdd gets performed on MSB or LSB of a single DWORD const auto paddedAlphaBinCount = core::min( - core::roundUp(baseBucketCount,pipelines.workgroupSize*2), + hlsl::roundUp(baseBucketCount,pipelines.workgroupSize*2), (pipelines.sharedMemorySize-sizeof(uint32_t)*2)/sizeof(uint16_t) ); return paddedAlphaBinCount*layersToBlit; diff --git a/include/nbl/video/utilities/CDrawIndirectAllocator.h b/include/nbl/video/utilities/CDrawIndirectAllocator.h index 6987be240d..c46b7053e6 100644 --- a/include/nbl/video/utilities/CDrawIndirectAllocator.h +++ b/include/nbl/video/utilities/CDrawIndirectAllocator.h @@ -46,7 +46,7 @@ class CDrawIndirectAllocator final : public IDrawIndirectAllocator static_cast(explicit_params) = std::move(params); explicit_params.drawCommandBuffer.offset = 0ull; // need to add a little padding, because generalpurpose allocator doesnt allow for allocations that would leave freeblocks smaller than the minimum allocation size - explicit_params.drawCommandBuffer.size = core::roundUp(params.drawCommandCapacity*params.maxDrawCommandStride+params.maxDrawCommandStride,limits.minSSBOAlignment); + explicit_params.drawCommandBuffer.size = hlsl::roundUp(params.drawCommandCapacity*params.maxDrawCommandStride+params.maxDrawCommandStride,limits.minSSBOAlignment); creationParams.size = explicit_params.drawCommandBuffer.size; explicit_params.drawCommandBuffer.buffer = params.device->createBuffer(std::move(creationParams)); @@ -55,7 +55,7 @@ class CDrawIndirectAllocator final : public IDrawIndirectAllocator auto gpubufMem = params.device->allocate(mreqsDrawCmdBuf, explicit_params.drawCommandBuffer.buffer.get()); explicit_params.drawCountBuffer.offset = 0ull; - explicit_params.drawCountBuffer.size = core::roundUp(params.drawCountCapacity*sizeof(uint32_t),limits.minSSBOAlignment); + explicit_params.drawCountBuffer.size = hlsl::roundUp(params.drawCountCapacity*sizeof(uint32_t),limits.minSSBOAlignment); if (explicit_params.drawCountBuffer.size) { creationParams.size = explicit_params.drawCountBuffer.size; @@ -105,7 +105,7 @@ class CDrawIndirectAllocator final : public IDrawIndirectAllocator static inline size_t computeReservedSize(const uint64_t bufferSize, const uint32_t maxStride) { - return DrawIndirectAddressAllocator::reserved_size(core::roundUpToPoT(maxStride),bufferSize,maxStride); + return DrawIndirectAddressAllocator::reserved_size(hlsl::roundUpToPoT(maxStride),bufferSize,maxStride); } allocator m_alloc; diff --git a/include/nbl/video/utilities/CDumbPresentationOracle.h b/include/nbl/video/utilities/CDumbPresentationOracle.h index 2b469fcc11..78d04aaa3f 100644 --- a/include/nbl/video/utilities/CDumbPresentationOracle.h +++ b/include/nbl/video/utilities/CDumbPresentationOracle.h @@ -25,7 +25,7 @@ class CDumbPresentationOracle : public IPresentationOracle lastTime = std::chrono::steady_clock::now(); } - inline void reportEndFrameRecord() + inline void reportEndFrameRecord() override { auto renderStart = std::chrono::steady_clock::now(); dt = std::chrono::duration_cast(renderStart-lastTime).count(); diff --git a/include/nbl/video/utilities/CSmoothResizeSurface.h b/include/nbl/video/utilities/CSmoothResizeSurface.h index 4d3a243b90..03142c1f41 100644 --- a/include/nbl/video/utilities/CSmoothResizeSurface.h +++ b/include/nbl/video/utilities/CSmoothResizeSurface.h @@ -159,7 +159,7 @@ class NBL_API2 ISmoothResizeSurface : public ISimpleManagedSurface return true; } - bool retval = recreateSwapchain(w,h); + [[maybe_unused]] bool retval = recreateSwapchain(w,h); auto current = getSwapchainResources(); // no point racing to present to old SC if (current->getSwapchain()==oldSwapchain.get()) @@ -378,7 +378,7 @@ class NBL_API2 ISmoothResizeSurface : public ISimpleManagedSurface if (willBlit) { // let the others know we've enqueued another TBP - const auto oldVal = m_lastPresent.pPresentSemaphoreWaitValue->exchange(acquireCount); + [[maybe_unused]] const auto oldVal = m_lastPresent.pPresentSemaphoreWaitValue->exchange(acquireCount); assert(oldValgetDescriptorSetLayout(i); - auto rhs_dsLayout = rhs_layout->getDescriptorSetLayout(i); + auto lhs_dsLayout = lhs_layout->getDescriptorSetLayouts()[i]; + auto rhs_dsLayout = rhs_layout->getDescriptorSetLayouts()[i]; if (lhs_dsLayout==rhs_dsLayout) continue; return Cmp()(lhs_dsLayout,rhs_dsLayout); @@ -129,7 +129,7 @@ class CSubpassKiln { if (lhs.vertexBufferBindings[i].buffer==rhs.vertexBufferBindings[i].buffer) { - if (lhs.vertexBufferBindings[i].offset,rhs.vertexBufferBindings[i].offset) + if (lhs.vertexBufferBindings[i].offset==rhs.vertexBufferBindings[i].offset) continue; return Cmp()(lhs.vertexBufferBindings[i].offset,rhs.vertexBufferBindings[i].offset); } diff --git a/include/nbl/video/utilities/IDrawIndirectAllocator.h b/include/nbl/video/utilities/IDrawIndirectAllocator.h index 7058641f8a..e684db1512 100644 --- a/include/nbl/video/utilities/IDrawIndirectAllocator.h +++ b/include/nbl/video/utilities/IDrawIndirectAllocator.h @@ -103,7 +103,7 @@ class IDrawIndirectAllocator : public core::IReferenceCounted inline uint32_t getCommandStructSize(const uint32_t i) const { assert(i; IDrawIndirectAllocator(core::smart_refctd_ptr&& _drawCountPool, const uint16_t _maxDrawCommandStride, asset::SBufferRange&& _drawCommandBlock, void* _drawAllocatorReserved) - : m_drawCountPool(std::move(_drawCountPool)), m_drawAllocator(_drawAllocatorReserved,0u,0u,core::roundUpToPoT(_maxDrawCommandStride),_drawCommandBlock.size,_maxDrawCommandStride), + : m_drawCountPool(std::move(_drawCountPool)), m_drawAllocator(_drawAllocatorReserved,0u,0u,hlsl::roundUpToPoT(_maxDrawCommandStride),_drawCommandBlock.size,_maxDrawCommandStride), m_drawCommandBlock(std::move(_drawCommandBlock)), m_drawAllocatorReserved(_drawAllocatorReserved), m_maxDrawCommandStride(_maxDrawCommandStride) { } diff --git a/include/nbl/video/utilities/IPropertyPool.h b/include/nbl/video/utilities/IPropertyPool.h index 0f56df622e..8e58831c27 100644 --- a/include/nbl/video/utilities/IPropertyPool.h +++ b/include/nbl/video/utilities/IPropertyPool.h @@ -92,7 +92,7 @@ class NBL_API2 IPropertyPool : public core::IReferenceCounted indexAllocator.free_addr(*it,unit); } const uint32_t head = getAllocated(); - const uint32_t removedCount = oldHead-head; + [[maybe_unused]] const uint32_t removedCount = oldHead-head; // no point trying to move anything if we've freed nothing or everything if (isContiguous() && head!=oldHead) { diff --git a/include/nbl/video/utilities/ISimpleManagedSurface.h b/include/nbl/video/utilities/ISimpleManagedSurface.h index f60aa022dd..9a14dc8054 100644 --- a/include/nbl/video/utilities/ISimpleManagedSurface.h +++ b/include/nbl/video/utilities/ISimpleManagedSurface.h @@ -125,7 +125,7 @@ class NBL_API2 ISimpleManagedSurface : public core::IReferenceCounted // NOTE: Current class doesn't trigger it because it knows nothing about how and when to create or recreate a swapchain. inline bool onCreateSwapchain(const uint8_t qFam, core::smart_refctd_ptr&& _swapchain) { - auto device = const_cast(_swapchain->getOriginDevice()); + [[maybe_unused]] auto device = const_cast(_swapchain->getOriginDevice()); // create images for (auto i=0u; i<_swapchain->getImageCount(); i++) { @@ -211,7 +211,7 @@ class NBL_API2 ISimpleManagedSurface : public core::IReferenceCounted }; protected: // some of the methods need to stay protected in this base class because they need to be performed under a Mutex for smooth resize variants - inline ISimpleManagedSurface(core::smart_refctd_ptr&& _surface, ICallback* _cb) : m_surface(std::move(_surface)), m_cb(_cb) {} + inline ISimpleManagedSurface(core::smart_refctd_ptr&& _surface, ICallback* _cb) : m_cb(_cb), m_surface(std::move(_surface)) {} virtual inline ~ISimpleManagedSurface() = default; virtual inline bool checkQueueFamilyProps(const IPhysicalDevice::SQueueFamilyProperties& props) const {return true;} diff --git a/include/nbl/video/utilities/IUtilities.h b/include/nbl/video/utilities/IUtilities.h index 7817df8d23..403b1a982a 100644 --- a/include/nbl/video/utilities/IUtilities.h +++ b/include/nbl/video/utilities/IUtilities.h @@ -32,8 +32,8 @@ class NBL_API2 IUtilities : public core::IReferenceCounted uint32_t allocationAlignmentForBufferImageCopy) : m_device(std::move(device)) , m_logger(nbl::system::logger_opt_smart_ptr(logger)) - , m_defaultUploadBuffer(std::move(defaultUploadBuffer)) , m_defaultDownloadBuffer(std::move(defaultDownloadBuffer)) + , m_defaultUploadBuffer(std::move(defaultUploadBuffer)) , m_allocationAlignment(allocationAlignment) , m_allocationAlignmentForBufferImageCopy(allocationAlignmentForBufferImageCopy) { @@ -581,7 +581,7 @@ class NBL_API2 IUtilities : public core::IReferenceCounted auto device = const_cast(downstreamingBuffer->getOriginDevice()); if (m_downstreamingBuffer->needsManualFlushOrInvalidate()) { - const auto nonCoherentAtomSize = device->getPhysicalDevice()->getLimits().nonCoherentAtomSize; + [[maybe_unused]] const auto nonCoherentAtomSize = device->getPhysicalDevice()->getLimits().nonCoherentAtomSize; auto flushRange = ILogicalDevice::MappedMemoryRange(downstreamingBuffer->getBoundMemory().memory,m_copyRange.offset,m_copyRange.length,ILogicalDevice::MappedMemoryRange::align_non_coherent_tag); device->invalidateMappedMemoryRanges(1u,&flushRange); } @@ -698,7 +698,7 @@ class NBL_API2 IUtilities : public core::IReferenceCounted { return downloadBufferRangeViaStagingBuffer(default_data_consumption_callback_t(data),nextSubmit,srcBufferRange); }; - if (autoSubmit(submit,lambda).copy()!=IQueue::RESULT::SUCCESS) + if (autoSubmit(submit,lambda).template copy()!=IQueue::RESULT::SUCCESS) return false; //! NOTE this method cannot be turned into a pure autoSubmitAndBlock + lambda because there's stuff to do AFTER the semaphore wait~! diff --git a/include/nbl/video/utilities/ImageRegionIterator.h b/include/nbl/video/utilities/ImageRegionIterator.h index 245622d074..93cdf1c809 100644 --- a/include/nbl/video/utilities/ImageRegionIterator.h +++ b/include/nbl/video/utilities/ImageRegionIterator.h @@ -68,7 +68,7 @@ class ImageRegionIterator asset::E_FORMAT srcImageFormat; const asset::E_FORMAT dstImageFormat; - const void* const srcData; + [[maybe_unused]] const void* const srcData; video::IGPUImage* const dstImage; // Block Offsets diff --git a/include/nbl/video/utilities/SIntendedSubmitInfo.h b/include/nbl/video/utilities/SIntendedSubmitInfo.h index 019dd82b30..054570dec9 100644 --- a/include/nbl/video/utilities/SIntendedSubmitInfo.h +++ b/include/nbl/video/utilities/SIntendedSubmitInfo.h @@ -132,8 +132,9 @@ struct SIntendedSubmitInfo final : core::Uncopyable inline CSubmitStorage(CSubmitStorage&& other) : self(other.self), m_semaphores(std::move(other.m_semaphores)) {} inline CSubmitStorage& operator=(CSubmitStorage&& rhs) { - self = std::move(self); + self = rhs.self; m_semaphores = std::move(rhs.m_semaphores); + return *this; } inline operator std::span() const diff --git a/include/splines.h b/include/splines.h index 8bab35c3f3..360ef44597 100644 --- a/include/splines.h +++ b/include/splines.h @@ -594,6 +594,10 @@ class CQuadraticSpline : public ISpline arcLen2ParameterLinear = 0.f; length = getArcLenFromParameter(parameterLength); +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnan-infinity-disabled" +#endif if (isinf(length)) { integrationConstants[0] = INFINITY; @@ -610,6 +614,9 @@ class CQuadraticSpline : public ISpline assert(integrationConstants[2] >= 0.f); #endif } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif arcLen2ParameterLinear = parameterLength / length; } @@ -620,9 +627,9 @@ class CQuadraticSpline : public ISpline auto differential = directionHelper(parameter); float differentialLen = core::length(differential)[0]; - float a = 4.f*core::lengthsquared(weights[0])[0]; - float b = 4.f*core::dot(weights[0],weights[1])[0]; - float c = core::lengthsquared(weights[1])[0]; + [[maybe_unused]] float a = 4.f*core::lengthsquared(weights[0])[0]; + [[maybe_unused]] float b = 4.f*core::dot(weights[0],weights[1])[0]; + [[maybe_unused]] float c = core::lengthsquared(weights[1])[0]; //float x = parameter; diff --git a/include/vectorSIMD.h b/include/vectorSIMD.h index 6144dc446f..5d381f4088 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; diff --git a/src/nbl/asset/IAssetManager.cpp b/src/nbl/asset/IAssetManager.cpp index 29930bccd9..6b1420823c 100644 --- a/src/nbl/asset/IAssetManager.cpp +++ b/src/nbl/asset/IAssetManager.cpp @@ -97,7 +97,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) @@ -296,7 +296,7 @@ void IAssetManager::insertBuiltinAssets() info.samples = asset::ICPUImage::E_SAMPLE_COUNT_FLAGS::ESCF_1_BIT; info.flags = static_cast(0u); info.usage = asset::IImage::EUF_INPUT_ATTACHMENT_BIT|asset::IImage::EUF_SAMPLED_BIT; - auto buf = asset::ICPUBuffer::create({ info.extent.width*info.extent.height*asset::getTexelOrBlockBytesize(info.format) }); + auto buf = asset::ICPUBuffer::create({ { info.extent.width * info.extent.height * asset::getTexelOrBlockBytesize(info.format) } }); memcpy(buf->getPointer(), //magenta-grey 2x2 chessboard std::array{{255, 0, 255, 255, 128, 128, 128, 255, 128, 128, 128, 255, 255, 0, 255, 255}}.data(), diff --git a/src/nbl/asset/ICPUImage.cpp b/src/nbl/asset/ICPUImage.cpp index cd3f884890..f4a29f60f4 100644 --- a/src/nbl/asset/ICPUImage.cpp +++ b/src/nbl/asset/ICPUImage.cpp @@ -94,8 +94,6 @@ class CFlattenRegionsStreamHashImageFilter : public CMatchedSizeInOutImageFilter if (!state->scratch.memory) return false; - const auto& parameters = state->inImage->getCreationParameters(); - if (state->scratch.size != state_type::getRequiredScratchByteSize(state->inImage)) return false; diff --git a/src/nbl/asset/ICPUPolygonGeometry.cpp b/src/nbl/asset/ICPUPolygonGeometry.cpp index 1acff42876..a3d1170a08 100644 --- a/src/nbl/asset/ICPUPolygonGeometry.cpp +++ b/src/nbl/asset/ICPUPolygonGeometry.cpp @@ -69,7 +69,7 @@ class CTriangleStripIndexingCB final : public IPolygonGeometryBase::IIndexingCal else indexOfIndex = ctx.beginPrimitive+2; const int32_t perm[] = {-1,-2,0}; - for (const auto end=ctx.endPrimitive+2; indexOfIndex!=end; indexOfIndex++) + for (const auto end=ctx.endPrimitive+2; std::cmp_not_equal(indexOfIndex, end); indexOfIndex++) ctx.streamOut(indexOfIndex,perm); } @@ -102,7 +102,7 @@ class CTriangleFanIndexingCB final : public IPolygonGeometryBase::IIndexingCallb else indexOfIndex = ctx.beginPrimitive+2; int32_t perm[] = {0x7eadbeefu,-1,0}; - for (const auto end=ctx.endPrimitive+2; indexOfIndex!=end; indexOfIndex++) + for (const auto end=ctx.endPrimitive+2; std::cmp_not_equal(indexOfIndex, end); indexOfIndex++) { // first index is always global 0 perm[0] = -indexOfIndex; diff --git a/src/nbl/asset/interchange/CBufferLoaderBIN.h b/src/nbl/asset/interchange/CBufferLoaderBIN.h index b47866ff3c..244184dca8 100644 --- a/src/nbl/asset/interchange/CBufferLoaderBIN.h +++ b/src/nbl/asset/interchange/CBufferLoaderBIN.h @@ -33,7 +33,7 @@ class CBufferLoaderBIN final : public asset::IAssetLoader private: struct SContext { - SContext(const size_t& sizeInBytes) : sourceCodeBuffer(ICPUBuffer::create({ sizeInBytes })) {} + SContext(const size_t& sizeInBytes) : sourceCodeBuffer(ICPUBuffer::create({{ sizeInBytes }})) {} system::IFile* file; core::smart_refctd_ptr sourceCodeBuffer; }; diff --git a/src/nbl/asset/interchange/CGLILoader.cpp b/src/nbl/asset/interchange/CGLILoader.cpp index 1599b765b0..cdc3bb0be3 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; @@ -105,6 +104,7 @@ namespace nbl } default: { + imageType = IImage::ET_1D; // suppress -Wsometimes-uninitialized by setting whatever value imageViewType = ICPUImageView::ET_COUNT; assert(0); break; @@ -115,8 +115,7 @@ 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 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 b538f75eb3..ee80c17123 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" using namespace nbl; @@ -100,7 +101,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)); @@ -353,7 +356,7 @@ namespace //! Read until line break is reached and stop at the next non-space character - const char* goNextLine(const char* buf, const char* const _bufEnd) + [[maybe_unused]] const char* goNextLine(const char* buf, const char* const _bufEnd) { // look for newline characters while (buf != _bufEnd) @@ -393,7 +396,7 @@ namespace return length; } - const char* goAndCopyNextWord(char* outBuf, const char* inBuf, uint32_t outBufLength, const char* _bufEnd) + [[maybe_unused]] const char* goAndCopyNextWord(char* outBuf, const char* inBuf, uint32_t outBufLength, const char* _bufEnd) { inBuf = goNextWord(inBuf, _bufEnd, false); copyWord(outBuf, inBuf, outBufLength, _bufEnd); @@ -618,7 +621,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(); @@ -626,7 +629,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/interchange/CHLSLLoader.cpp b/src/nbl/asset/interchange/CHLSLLoader.cpp index fece93d7b6..73d0a970a7 100644 --- a/src/nbl/asset/interchange/CHLSLLoader.cpp +++ b/src/nbl/asset/interchange/CHLSLLoader.cpp @@ -16,7 +16,7 @@ SAssetBundle CHLSLLoader::loadAsset(system::IFile* _file, const IAssetLoader::SA return {}; const auto len = _file->getSize(); - auto source = ICPUBuffer::create({ len+1 }); + auto source = ICPUBuffer::create({{ len+1 }}); system::IFile::success_t success; _file->read(success, source->getPointer(), 0, len); diff --git a/src/nbl/asset/interchange/CImageLoaderJPG.cpp b/src/nbl/asset/interchange/CImageLoaderJPG.cpp index 1db5e16ac2..d1cfcf4d32 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; @@ -310,7 +307,7 @@ asset::SAssetBundle CImageLoaderJPG::loadAsset(system::IFile* _file, const asset uint32_t rowspan = region.bufferRowLength * cinfo.out_color_components; // Allocate memory for buffer - auto buffer = asset::ICPUBuffer::create({ rowspan*height }); + auto buffer = asset::ICPUBuffer::create({ {rowspan*height} }); // Here we use the library's state variable cinfo.output_scanline as the // loop counter, so that we don't have to keep track ourselves. diff --git a/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp b/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp index da4e00070f..6d68a3e686 100644 --- a/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp +++ b/src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp @@ -123,7 +123,7 @@ using suffixOfChannelBundle = std::string; using channelName = std::string; // sytnax if as follows using mapOfChannels = std::unordered_map; // suffix.channel, where channel are "R", "G", "B", "A" -class SContext; +struct SContext; bool readVersionField(IMF::IStream* nblIStream, SContext& ctx, const system::logger_opt_ptr); bool readHeader(IMF::IStream* nblIStream, SContext& ctx); template @@ -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); @@ -359,7 +359,7 @@ SAssetBundle CImageLoaderOpenEXR::loadAsset(system::IFile* _file, const asset::I auto image = ICPUImage::create(std::move(params)); { // create image and buffer that backs it const uint32_t texelFormatByteSize = getTexelOrBlockBytesize(image->getCreationParameters().format); - auto texelBuffer = ICPUBuffer::create({ image->getImageDataSizeInBytes() }); + auto texelBuffer = ICPUBuffer::create({{ image->getImageDataSizeInBytes() }}); auto regions = core::make_refctd_dynamic_array>(1u); ICPUImage::SBufferCopy& region = regions->front(); region.imageSubresource.aspectMask = IImage::E_ASPECT_FLAGS::EAF_COLOR_BIT; @@ -561,8 +561,8 @@ bool readHeader(IMF::IStream* nblIStream, SContext& ctx) if (!file.isComplete()) return false; - auto& attribs = ctx.attributes; - auto& versionField = ctx.versionField; + [[maybe_unused]] auto& attribs = ctx.attributes; + // auto& versionField = ctx.versionField; /* diff --git a/src/nbl/asset/interchange/CImageLoaderOpenEXR.h b/src/nbl/asset/interchange/CImageLoaderOpenEXR.h index fae6cf2d44..d58d8664aa 100644 --- a/src/nbl/asset/interchange/CImageLoaderOpenEXR.h +++ b/src/nbl/asset/interchange/CImageLoaderOpenEXR.h @@ -39,7 +39,7 @@ class CImageLoaderOpenEXR final : public IImageLoader private: - IAssetManager* m_manager; + [[maybe_unused]] IAssetManager* m_manager; }; } diff --git a/src/nbl/asset/interchange/CImageLoaderPNG.cpp b/src/nbl/asset/interchange/CImageLoaderPNG.cpp index 1e15195a73..50d8f030b3 100644 --- a/src/nbl/asset/interchange/CImageLoaderPNG.cpp +++ b/src/nbl/asset/interchange/CImageLoaderPNG.cpp @@ -86,9 +86,9 @@ bool CImageLoaderPng::isALoadableFileFormat(system::IFile* _file, const system:: // Read the first few bytes of the PNG _file system::IFile::success_t success; _file->read(success, buffer, 0, sizeof(buffer)); - if (!success) - return false; - + if (!success) + return false; + // Check if it really is a PNG _file return !png_sig_cmp(buffer, 0, 8); #else @@ -286,7 +286,7 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset region.imageOffset = { 0u, 0u, 0u }; region.imageExtent = imgInfo.extent; - auto texelBuffer = ICPUBuffer::create({ region.bufferRowLength * region.imageExtent.height * texelFormatBytesize }); + auto texelBuffer = ICPUBuffer::create({{ region.bufferRowLength * region.imageExtent.height * texelFormatBytesize }}); // Fill array of pointers to rows in image data const uint32_t pitch = region.bufferRowLength*texelFormatBytesize; diff --git a/src/nbl/asset/interchange/CImageLoaderTGA.cpp b/src/nbl/asset/interchange/CImageLoaderTGA.cpp index e5068ed737..96a448beff 100644 --- a/src/nbl/asset/interchange/CImageLoaderTGA.cpp +++ b/src/nbl/asset/interchange/CImageLoaderTGA.cpp @@ -30,7 +30,7 @@ namespace asset auto inputTexelOrBlockByteSize = inputBuffer->getSize(); const uint32_t texelOrBlockLength = inputTexelOrBlockByteSize / asset::getTexelOrBlockBytesize(inputFormat); - auto outputBuffer = asset::ICPUBuffer::create({ texelOrBlockLength * asset::getTexelOrBlockBytesize(outputFormat) }); + auto outputBuffer = asset::ICPUBuffer::create({{ texelOrBlockLength * asset::getTexelOrBlockBytesize(outputFormat) }}); auto outputTexelOrBlockByteSize = outputBuffer->getSize(); for (auto i = 0ull; i < texelOrBlockLength; ++i) @@ -49,7 +49,7 @@ void CImageLoaderTGA::loadCompressedImage(system::IFile *file, const STGAHeader& // I only changed the formatting a little bit. int32_t bytesPerPixel = header.PixelDepth/8; int32_t imageSizeInBytes = header.ImageHeight * header.ImageWidth * bytesPerPixel; - bufferData = ICPUBuffer::create({ wholeSizeWithPitchInBytes }); + bufferData = ICPUBuffer::create({{ wholeSizeWithPitchInBytes }}); auto data = reinterpret_cast(bufferData->getPointer()); int32_t currentByte = 0; @@ -202,7 +202,7 @@ asset::SAssetBundle CImageLoaderTGA::loadAsset(system::IFile* _file, const asset if (header.ColorMapType) { auto colorMapEntryByteSize = header.ColorMapEntrySize / 8 * header.ColorMapLength; - auto colorMapEntryBuffer = asset::ICPUBuffer::create({ static_cast(colorMapEntryByteSize) }); + auto colorMapEntryBuffer = asset::ICPUBuffer::create({{ static_cast(colorMapEntryByteSize) }}); { system::IFile::success_t success; _file->read(success, colorMapEntryBuffer->getPointer(), offset, header.ColorMapEntrySize / 8 * header.ColorMapLength); @@ -251,7 +251,7 @@ asset::SAssetBundle CImageLoaderTGA::loadAsset(system::IFile* _file, const asset { region.bufferRowLength = calcPitchInBlocks(region.imageExtent.width, getTexelOrBlockBytesize(EF_R8G8B8_SRGB)); const int32_t imageSize = endBufferSize = region.imageExtent.height * region.bufferRowLength * bytesPerTexel; - texelBuffer = ICPUBuffer::create({ static_cast(imageSize) }); + texelBuffer = ICPUBuffer::create({{ static_cast(imageSize) }}); { system::IFile::success_t success; _file->read(success, texelBuffer->getPointer(), offset, imageSize); diff --git a/src/nbl/asset/interchange/CImageWriterJPG.cpp b/src/nbl/asset/interchange/CImageWriterJPG.cpp index 3943e207ed..467f50f26b 100644 --- a/src/nbl/asset/interchange/CImageWriterJPG.cpp +++ b/src/nbl/asset/interchange/CImageWriterJPG.cpp @@ -151,7 +151,7 @@ static bool writeJPEGFile(system::IFile* file, system::ISystem* sys, const asset jpeg_start_compress(&cinfo, TRUE); const auto JPG_BYTE_PITCH = rowByteSize; - auto destBuffer = asset::ICPUBuffer::create({ JPG_BYTE_PITCH }); + auto destBuffer = asset::ICPUBuffer::create({{ JPG_BYTE_PITCH }}); auto dest = reinterpret_cast(destBuffer->getPointer()); if (dest) @@ -163,7 +163,7 @@ static bool writeJPEGFile(system::IFile* file, system::ISystem* sys, const asset uint8_t* src = reinterpret_cast(convertedImage->getBuffer()->getPointer()); /* Switch up, write from bottom -> top because the texture is flipped from OpenGL side */ - uint32_t eof = cinfo.image_height * cinfo.image_width * cinfo.input_components; + [[maybe_unused]] uint32_t eof = cinfo.image_height * cinfo.image_width * cinfo.input_components; while (cinfo.next_scanline < cinfo.image_height) { diff --git a/src/nbl/asset/interchange/CImageWriterJPG.h b/src/nbl/asset/interchange/CImageWriterJPG.h index 40157f0bf6..bd4fbf323c 100644 --- a/src/nbl/asset/interchange/CImageWriterJPG.h +++ b/src/nbl/asset/interchange/CImageWriterJPG.h @@ -25,7 +25,7 @@ class CImageWriterJPG : public asset::IAssetWriter //! constructor explicit CImageWriterJPG(core::smart_refctd_ptr&& sys); - virtual const char** getAssociatedFileExtensions() const + virtual const char** getAssociatedFileExtensions() const override { static const char* ext[]{ "jpg", "jpeg", "jpe", "jif", "jfif", "jfi", nullptr }; return ext; @@ -35,7 +35,7 @@ class CImageWriterJPG : public asset::IAssetWriter virtual uint32_t getSupportedFlags() override { return asset::EWF_COMPRESSED; } - virtual uint32_t getForcedFlags() { return asset::EWF_BINARY; } + virtual uint32_t getForcedFlags() override { return asset::EWF_BINARY; } virtual bool writeAsset(system::IFile* _file, const SAssetWriteParams& _params, IAssetWriterOverride* _override = nullptr) override; }; diff --git a/src/nbl/asset/interchange/CImageWriterOpenEXR.h b/src/nbl/asset/interchange/CImageWriterOpenEXR.h index 37da219c64..cb5cab40b4 100644 --- a/src/nbl/asset/interchange/CImageWriterOpenEXR.h +++ b/src/nbl/asset/interchange/CImageWriterOpenEXR.h @@ -35,7 +35,7 @@ class CImageWriterOpenEXR final : public IImageWriter uint32_t getSupportedFlags() override { return asset::EWF_BINARY; } - uint32_t getForcedFlags() { return asset::EWF_BINARY; } + uint32_t getForcedFlags() override { return asset::EWF_BINARY; } bool writeAsset(system::IFile* _file, const SAssetWriteParams& _params, IAssetWriterOverride* _override = nullptr) override; diff --git a/src/nbl/asset/interchange/CImageWriterPNG.cpp b/src/nbl/asset/interchange/CImageWriterPNG.cpp index ddb9cc1933..cf00c40ee6 100644 --- a/src/nbl/asset/interchange/CImageWriterPNG.cpp +++ b/src/nbl/asset/interchange/CImageWriterPNG.cpp @@ -46,7 +46,7 @@ static void png_cpexcept_warning(png_structp png_ptr, png_const_charp msg) // PNG function for file writing void PNGAPI user_write_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length) { - png_size_t check; + [[maybe_unused]] png_size_t check; system::IFile* file=(system::IFile*)png_get_io_ptr(png_ptr); //check=(png_size_t) file->write((const void*)data,(uint32_t)length); diff --git a/src/nbl/asset/interchange/CImageWriterPNG.h b/src/nbl/asset/interchange/CImageWriterPNG.h index ec2f3b39ef..a14450912b 100644 --- a/src/nbl/asset/interchange/CImageWriterPNG.h +++ b/src/nbl/asset/interchange/CImageWriterPNG.h @@ -31,7 +31,7 @@ class CImageWriterPNG : public asset::IAssetWriter //! constructor explicit CImageWriterPNG(core::smart_refctd_ptr&& sys); - virtual const char** getAssociatedFileExtensions() const + virtual const char** getAssociatedFileExtensions() const override { static const char* ext[]{ "png", nullptr }; return ext; @@ -41,7 +41,7 @@ class CImageWriterPNG : public asset::IAssetWriter virtual uint32_t getSupportedFlags() override { return 0u; } - virtual uint32_t getForcedFlags() { return asset::EWF_BINARY; } + virtual uint32_t getForcedFlags() override { return asset::EWF_BINARY; } virtual bool writeAsset(system::IFile* _file, const SAssetWriteParams& _params, IAssetWriterOverride* _override = nullptr) override; }; diff --git a/src/nbl/asset/interchange/CImageWriterTGA.cpp b/src/nbl/asset/interchange/CImageWriterTGA.cpp index b2c8587183..7f6dab8226 100644 --- a/src/nbl/asset/interchange/CImageWriterTGA.cpp +++ b/src/nbl/asset/interchange/CImageWriterTGA.cpp @@ -134,7 +134,7 @@ bool CImageWriterTGA::writeAsset(system::IFile* _file, const SAssetWriteParams& int32_t row_size = ((imageHeader.PixelDepth / 8) * imageHeader.ImageWidth); // allocate a row do translate data into - auto rowPointerBuffer = ICPUBuffer::create({ static_cast(row_size) }); + auto rowPointerBuffer = ICPUBuffer::create({ {static_cast(row_size)} }); auto row_pointer = reinterpret_cast(rowPointerBuffer->getPointer()); uint32_t y; diff --git a/src/nbl/asset/interchange/CImageWriterTGA.h b/src/nbl/asset/interchange/CImageWriterTGA.h index 2341d1a910..e12683be2d 100644 --- a/src/nbl/asset/interchange/CImageWriterTGA.h +++ b/src/nbl/asset/interchange/CImageWriterTGA.h @@ -35,7 +35,7 @@ class CImageWriterTGA : public asset::IAssetWriter virtual uint32_t getSupportedFlags() override { return 0u; } - virtual uint32_t getForcedFlags() { return asset::EWF_BINARY; } + virtual uint32_t getForcedFlags() override { return asset::EWF_BINARY; } virtual bool writeAsset(system::IFile* _file, const SAssetWriteParams& _params, IAssetWriterOverride* _override = nullptr) override; }; diff --git a/src/nbl/asset/interchange/CPLYMeshFileLoader.cpp b/src/nbl/asset/interchange/CPLYMeshFileLoader.cpp index 932a04b82c..038c6ef10d 100644 --- a/src/nbl/asset/interchange/CPLYMeshFileLoader.cpp +++ b/src/nbl/asset/interchange/CPLYMeshFileLoader.cpp @@ -4,6 +4,10 @@ // See the original file in irrlicht source for authors #ifdef _NBL_COMPILE_WITH_PLY_LOADER_ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif #include "CPLYMeshFileLoader.h" @@ -468,18 +472,18 @@ SAssetBundle CPLYMeshFileLoader::loadAsset(system::IFile* _file, const IAssetLoa return {}; SContext ctx = { - asset::IAssetLoader::SAssetLoadContext{ + .inner = asset::IAssetLoader::SAssetLoadContext{ _params, _file }, - _hierarchyLevel, - _override + .topHierarchyLevel = _hierarchyLevel, + .loaderOverride = _override }; ctx.init(); // start with empty mesh auto geometry = make_smart_refctd_ptr(); - uint32_t vertCount=0; + [[maybe_unused]] uint32_t vertCount=0; // Currently only supports ASCII or binary meshes if (strcmp(ctx.getNextLine(),"ply")) @@ -880,4 +884,8 @@ SAssetBundle CPLYMeshFileLoader::loadAsset(system::IFile* _file, const IAssetLoa } // end namespace nbl::asset + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #endif // _NBL_COMPILE_WITH_PLY_LOADER_ 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/CPLYMeshWriter.h b/src/nbl/asset/interchange/CPLYMeshWriter.h index e709ffa0fe..826e350740 100644 --- a/src/nbl/asset/interchange/CPLYMeshWriter.h +++ b/src/nbl/asset/interchange/CPLYMeshWriter.h @@ -21,7 +21,7 @@ class CPLYMeshWriter : public IGeometryWriter public: CPLYMeshWriter(); - virtual const char** getAssociatedFileExtensions() const + virtual const char** getAssociatedFileExtensions() const override { static const char* ext[]{ "ply", nullptr }; return ext; @@ -29,7 +29,7 @@ class CPLYMeshWriter : public IGeometryWriter virtual uint32_t getSupportedFlags() override { return asset::EWF_BINARY; } - virtual uint32_t getForcedFlags() { return 0u; } + virtual uint32_t getForcedFlags() override { return 0u; } virtual bool writeAsset(system::IFile* _file, const SAssetWriteParams& _params, IAssetWriterOverride* _override = nullptr) override; @@ -65,7 +65,7 @@ class CPLYMeshWriter : public IGeometryWriter else currentFlipOnVariable = false; - ss << std::setprecision(6) << _vec[i] * (currentFlipOnVariable ? -1 : 1) << " "; + ss << std::setprecision(6) << _vec[i] * (currentFlipOnVariable ? -1 : 1) << " "; } auto str = ss.str(); diff --git a/src/nbl/asset/interchange/CSPVLoader.cpp b/src/nbl/asset/interchange/CSPVLoader.cpp index 7d44085742..d7d6d164d1 100644 --- a/src/nbl/asset/interchange/CSPVLoader.cpp +++ b/src/nbl/asset/interchange/CSPVLoader.cpp @@ -15,12 +15,12 @@ SAssetBundle CSPVLoader::loadAsset(system::IFile* _file, const IAssetLoader::SAs if (!_file) return {}; - auto buffer = ICPUBuffer::create({ _file->getSize() }); + auto buffer = ICPUBuffer::create({{ _file->getSize() }}); system::IFile::success_t success; _file->read(success, buffer->getPointer(), 0, _file->getSize()); - if (!success) - return {}; + if (!success) + return {}; if (reinterpret_cast(buffer->getPointer())[0]!=SPV_MAGIC_NUMBER) return {}; diff --git a/src/nbl/asset/interchange/CSTLMeshWriter.cpp b/src/nbl/asset/interchange/CSTLMeshWriter.cpp index 45c7c1f939..9ccb89c337 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" @@ -12,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() { @@ -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/asset/interchange/CSTLMeshWriter.h b/src/nbl/asset/interchange/CSTLMeshWriter.h index a25a84534c..4ae593704d 100644 --- a/src/nbl/asset/interchange/CSTLMeshWriter.h +++ b/src/nbl/asset/interchange/CSTLMeshWriter.h @@ -22,7 +22,7 @@ class CSTLMeshWriter : public IGeometryWriter public: CSTLMeshWriter(); - virtual const char** getAssociatedFileExtensions() const + virtual const char** getAssociatedFileExtensions() const override { static const char* ext[]{ "stl", nullptr }; return ext; @@ -30,7 +30,7 @@ class CSTLMeshWriter : public IGeometryWriter virtual uint32_t getSupportedFlags() override { return asset::EWF_BINARY; } - virtual uint32_t getForcedFlags() { return 0u; } + virtual uint32_t getForcedFlags() override { return 0u; } virtual bool writeAsset(system::IFile* _file, const SAssetWriteParams& _params, IAssetWriterOverride* _override = nullptr) override; diff --git a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp index 9886514c81..7e73d5410a 100644 --- a/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp +++ b/src/nbl/asset/material_compiler/CMaterialCompilerGLSLBackendCommon.cpp @@ -5,7 +5,6 @@ #include #include -#include namespace nbl { diff --git a/src/nbl/asset/utils/CCompilerSet.cpp b/src/nbl/asset/utils/CCompilerSet.cpp index e1b161f4e3..5e108aab9d 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 IShader* shad 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/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); } } diff --git a/src/nbl/asset/utils/CGLSLCompiler.cpp b/src/nbl/asset/utils/CGLSLCompiler.cpp index a593a11597..d5bcb632bf 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 } {} @@ -204,7 +204,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) { @@ -214,7 +214,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) { @@ -275,7 +275,7 @@ core::smart_refctd_ptr CGLSLCompiler::compileToSPIRV_impl(const std::st 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) diff --git a/src/nbl/asset/utils/CGeometryCreator.cpp b/src/nbl/asset/utils/CGeometryCreator.cpp index 3750a37a70..a614cfb50e 100644 --- a/src/nbl/asset/utils/CGeometryCreator.cpp +++ b/src/nbl/asset/utils/CGeometryCreator.cpp @@ -85,7 +85,7 @@ template static ICPUPolygonGeometry::SDataView createIndexView(size_t indexCount, size_t maxIndex) { const auto bytesize = sizeof(IndexT) * indexCount; - auto indices = ICPUBuffer::create({bytesize,IBuffer::EUF_INDEX_BUFFER_BIT}); + auto indices = ICPUBuffer::create({{bytesize,IBuffer::EUF_INDEX_BUFFER_BIT}}); hlsl::shapes::AABB<4,IndexT> aabb; aabb.minVx[0] = 0; @@ -120,7 +120,7 @@ static ICPUPolygonGeometry::SDataView createPositionView(size_t positionCount, c { using position_t = hlsl::vector; constexpr auto AttrSize = sizeof(position_t); - auto buff = ICPUBuffer::create({AttrSize * positionCount,IBuffer::EUF_NONE}); + auto buff = ICPUBuffer::create({{AttrSize * positionCount,IBuffer::EUF_NONE}}); constexpr auto format = []() { @@ -144,7 +144,7 @@ static ICPUPolygonGeometry::SDataView createPositionView(size_t positionCount, c static ICPUPolygonGeometry::SDataView createSnormNormalView(size_t normalCount, const hlsl::shapes::AABB<4, int8_t>& aabb) { constexpr auto AttrSize = sizeof(snorm_normal_t); - auto buff = ICPUBuffer::create({AttrSize * normalCount,IBuffer::EUF_NONE}); + auto buff = ICPUBuffer::create({{AttrSize * normalCount,IBuffer::EUF_NONE}}); return { .composed = { .encodedDataRange = {.s8=aabb}, @@ -863,7 +863,7 @@ core::smart_refctd_ptr CGeometryCreator::createDisk(const f } { constexpr auto AttrSize = sizeof(decltype(*normals)); - auto buff = ICPUBuffer::create({AttrSize*vertexCount,IBuffer::EUF_NONE}); + auto buff = ICPUBuffer::create({{AttrSize*vertexCount,IBuffer::EUF_NONE}}); shapes::AABB<4,int8_t> aabb; aabb.maxVx = snorm_positive_z; aabb.minVx = -aabb.maxVx; @@ -880,14 +880,14 @@ core::smart_refctd_ptr CGeometryCreator::createDisk(const f // populate data { - const float angle = 360.f / static_cast(tesselation); + [[maybe_unused]] const float angle = 360.f / static_cast(tesselation); // center *(positions++) = float32_t2(0.f,0.f); *(uvs++) = uint16_t2(0,UnityUV); // last positions[tesselation] = float32_t3(0.f,radius,0.f); uvs[tesselation] = uint16_t2(UnityUV,0); - for (auto i=0; i; @@ -1261,8 +1261,8 @@ class Icosphere // /__ /__ /__ /__ /__ // \ /\ /\ /\ /\ / : (i+3, i+4), (i+3, i+5), (i+4, i+5) // \/__\/__\/__\/__\/__ - // \ \ \ \ \ : (i+9,i+10), (i+9, i+11) - // \ \ \ \ \ + // \ \ \ \ \ : (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) @@ -1318,11 +1318,11 @@ class Icosphere // 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 - // \ /\ /\ /\ /\ /\ - // \/ \/ \/ \/ \/ \ + // /\ /\ /\ /\ /\ + // / \/ \/ \/ \/ \ + //10--14--15--16--17--11 + // \ /\ /\ /\ /\ /\ + // \/ \/ \/ \/ \/ \ // 12--18--19--20--21--13 // \ /\ /\ /\ /\ / // \/ \/ \/ \/ \/ @@ -1522,7 +1522,7 @@ class Icosphere float newT1[2], newT2[2], newT3[2]; // new texture coords float normal[3]; // new face normal uint32_t index = 0; // new index value - int32_t i, j; + uint32_t i, j; // iteration for (i = 1; i <= subdivision; ++i) @@ -1541,7 +1541,7 @@ class Icosphere index = 0; indexCount = (int)tmpIndices.size(); - for (j = 0; j < indexCount; j += 3) + for (j = 0; j < static_cast(indexCount); j += 3) { // get 3 vertice and texcoords of a triangle v1 = &tmpVertices[tmpIndices[j] * 3]; @@ -1617,7 +1617,7 @@ class Icosphere float newN1[3], newN2[3], newN3[3]; // new subdivided normals float newT1[2], newT2[2], newT3[2]; // new subdivided texture coords uint32_t newI1, newI2, newI3; // new subdivided indices - int32_t i, j; + uint32_t i, j; // iteration for subdivision for (i = 1; i <= subdivision; ++i) @@ -1629,8 +1629,8 @@ class Icosphere indices.clear(); lineIndices.clear(); - indexCount = tmpIndices.size(); - for (j = 0; j < indexCount; j += 3) + indexCount = static_cast(tmpIndices.size()); + for (j = 0; j < static_cast(indexCount); j += 3) { // get 3 indices of each triangle i1 = tmpIndices[j]; @@ -1814,7 +1814,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; @@ -1854,7 +1854,7 @@ core::smart_refctd_ptr CGeometryCreator::createIcoSphere(fl { using normal_t = float32_t3; constexpr auto AttrSize = sizeof(normal_t); - auto buff = ICPUBuffer::create({icosphere.getNormalSize(), IBuffer::EUF_NONE}); + auto buff = ICPUBuffer::create({{icosphere.getNormalSize(), IBuffer::EUF_NONE}}); const auto normals = reinterpret_cast(buff->getPointer()); memcpy(normals, icosphere.getNormals(), icosphere.getNormalSize()); shapes::AABB<4,float32_t> aabb; @@ -1985,7 +1985,7 @@ core::smart_refctd_ptr CGeometryCreator::createGrid(const h static constexpr auto stride = getTexelOrBlockBytesize(); const auto bytes = stride * vertexCount; - auto buffer = ICPUBuffer::create({ bytes, IBuffer::EUF_NONE }); + auto buffer = ICPUBuffer::create({{ bytes, IBuffer::EUF_NONE }}); ICPUPolygonGeometry::SDataView positionView = { .composed = { .encodedDataRange = {.f32 = aabb}, diff --git a/src/nbl/asset/utils/CHLSLCompiler.cpp b/src/nbl/asset/utils/CHLSLCompiler.cpp index 62166a885c..bb3bec9b1c 100644 --- a/src/nbl/asset/utils/CHLSLCompiler.cpp +++ b/src/nbl/asset/utils/CHLSLCompiler.cpp @@ -257,12 +257,12 @@ static void try_upgrade_shader_stage(std::vector& arguments, asset static void add_required_arguments_if_not_present(std::vector& arguments, system::logger_opt_ptr &logger) { auto set = std::unordered_set(); - for (int i = 0; i < arguments.size(); i++) + for (size_t i = 0; i < arguments.size(); i++) set.insert(arguments[i]); const auto required = CHLSLCompiler::getRequiredArguments(); - for (int j = 0; j < required.size(); j++) + for (size_t j = 0; j < required.size(); j++) { bool missing = set.find(required[j]) == set.end(); if (missing) { @@ -296,12 +296,19 @@ static DxcCompilationResult dxcCompile(const CHLSLCompiler* compiler, nbl::asset std::ostringstream insertion; insertion << "#pragma wave dxc_compile_flags( "; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif std::wstring_convert, wchar_t> conv; for (uint32_t arg = 0; arg < argCount; arg ++) { auto str = conv.to_bytes(args[arg]); insertion << str.c_str() << " "; } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif insertion << ")\n"; compiler->insertIntoStart(source, std::move(insertion)); @@ -511,7 +518,7 @@ core::smart_refctd_ptr CHLSLCompiler::compileToSPIRV_impl(const std::st } // auto set = std::unordered_set(); - for (int i = 0; i < arguments.size(); i++) + for (size_t i = 0; i < arguments.size(); i++) set.insert(arguments[i]); auto add_if_missing = [&arguments, &set, logger](std::wstring flag) { if (set.find(flag) == set.end()) { @@ -560,7 +567,7 @@ core::smart_refctd_ptr CHLSLCompiler::compileToSPIRV_impl(const std::st return nullptr; } - auto outSpirv = ICPUBuffer::create({ compileResult.objectBlob->GetBufferSize() }); + auto outSpirv = ICPUBuffer::create({{ compileResult.objectBlob->GetBufferSize() }}); memcpy(outSpirv->getPointer(), compileResult.objectBlob->GetBufferPointer(), compileResult.objectBlob->GetBufferSize()); // Optimizer step (TODO: improve by working on `compileResult.objectBlob->GetBufferPointer()` directly) diff --git a/src/nbl/asset/utils/CIESProfileParser.cpp b/src/nbl/asset/utils/CIESProfileParser.cpp index 66196b1902..ed8b256589 100644 --- a/src/nbl/asset/utils/CIESProfileParser.cpp +++ b/src/nbl/asset/utils/CIESProfileParser.cpp @@ -57,7 +57,7 @@ bool CIESProfileParser::parse(CIESProfile& result) } if (line == "TILT=INCLUDE") { - double lampToLuminaire = getDouble("lampToLuminaire truncated"); + [[maybe_unused]] double lampToLuminaire = getDouble("lampToLuminaire truncated"); int numTilt = getDouble("numTilt truncated"); for (int i = 0; i < numTilt; i++) getDouble("tilt angle truncated"); @@ -69,8 +69,8 @@ bool CIESProfileParser::parse(CIESProfile& result) return false; } - int numLamps = getInt("numLamps truncated"); - double lumensPerLamp = getDouble("lumensPerLamp truncated"); + [[maybe_unused]] int numLamps = getInt("numLamps truncated"); + [[maybe_unused]] double lumensPerLamp = getDouble("lumensPerLamp truncated"); double candelaMultiplier = getDouble("candelaMultiplier truncated"); int vSize = getInt("vSize truncated"); int hSize = getInt("hSize truncated"); @@ -88,8 +88,8 @@ bool CIESProfileParser::parse(CIESProfile& result) return false; } - int unitsType = getInt("unitsType truncated"); - double width = getDouble("width truncated"), + [[maybe_unused]] int unitsType = getInt("unitsType truncated"); + [[maybe_unused]] double width = getDouble("width truncated"), length = getDouble("length truncated"), height = getDouble("height truncated"), ballastFactor = getDouble("ballastFactor truncated"), diff --git a/src/nbl/asset/utils/CPolygonGeometryManipulator.cpp b/src/nbl/asset/utils/CPolygonGeometryManipulator.cpp index b4f2f2ef06..cf19c9f188 100644 --- a/src/nbl/asset/utils/CPolygonGeometryManipulator.cpp +++ b/src/nbl/asset/utils/CPolygonGeometryManipulator.cpp @@ -42,7 +42,7 @@ core::smart_refctd_ptr CPolygonGeometryManipulator::createU { if (!inView) return {}; - auto buffer = ICPUBuffer::create({ outIndexCount*inView.composed.stride , inView.src.buffer->getUsageFlags() }); + auto buffer = ICPUBuffer::create({{ outIndexCount*inView.composed.stride , inView.src.buffer->getUsageFlags() }}); return { .composed = inView.composed, .src = {.offset = 0, .size = buffer->getSize(), .buffer = std::move(buffer)} @@ -118,7 +118,7 @@ core::smart_refctd_ptr CPolygonGeometryManipulator::createU std::byte* const outJointIndices = reinterpret_cast(outView.indices.getPointer()); memcpy(outJointIndices + outIndex * jointIndexSize, inJointIndices + inIndex * jointIndexSize, jointIndexSize); - const std::byte* const inWeights = reinterpret_cast(inView.weights.getPointer()); + [[maybe_unused]] const std::byte* const inWeights = reinterpret_cast(inView.weights.getPointer()); const auto jointWeightSize = inView.weights.composed.stride; std::byte* const outWeights = reinterpret_cast(outView.weights.getPointer()); memcpy(outWeights + outIndex * jointWeightSize, outWeights + inIndex * jointWeightSize, jointWeightSize); @@ -1035,7 +1035,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); @@ -1053,7 +1052,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: @@ -1061,7 +1059,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/asset/utils/CSPIRVIntrospector.cpp b/src/nbl/asset/utils/CSPIRVIntrospector.cpp index 818fbc584b..fbaf124f92 100644 --- a/src/nbl/asset/utils/CSPIRVIntrospector.cpp +++ b/src/nbl/asset/utils/CSPIRVIntrospector.cpp @@ -148,7 +148,7 @@ core::smart_refctd_ptr CSPIRVIntrospector::createApproximat return isIntrospectionPushConstantRangeSubset; }); - auto asdf = layoutPushConstantRanges.end(); + [[maybe_unused]] auto asdf = layoutPushConstantRanges.end(); if (subsetRangeFound == layoutPushConstantRanges.end()) return nullptr; @@ -158,7 +158,7 @@ core::smart_refctd_ptr CSPIRVIntrospector::createApproximat // now validate if bindings of descriptor sets in `introspection` are also present in `layout` descriptor sets and validate their compatability for (uint32_t dstSetIdx = 0; dstSetIdx < ICPUPipelineLayout::DESCRIPTOR_SET_COUNT; ++dstSetIdx) { - const auto& layoutDescriptorSetLayout = layout->getDescriptorSetLayout(dstSetIdx); + [[maybe_unused]] const auto& layoutDescriptorSetLayout = layout->getDescriptorSetLayout(dstSetIdx); const auto& introspectionDescriptorSetLayout = introspection->getDescriptorSetInfo(dstSetIdx); if (!introspectionDescriptorSetLayout.empty()) @@ -258,11 +258,11 @@ NBL_API2 bool CSPIRVIntrospector::CPipelineIntrospectionData::merge(const CSPIRV // validate if only descriptors with the highest bindings are run-time sized for (uint32_t i = 0u; i < ICPUPipelineLayout::DESCRIPTOR_SET_COUNT; ++i) { - const auto& introBindingInfos = stageData->getDescriptorSetInfo(i); + [[maybe_unused]] const auto& introBindingInfos = stageData->getDescriptorSetInfo(i); for (const auto& descriptor : descriptorsToMerge[i]) { - if (descriptor.binding < highestBindingsTmp[i].binding && descriptor.isRuntimeSized()) + if (descriptor.binding < static_cast(highestBindingsTmp[i].binding) && descriptor.isRuntimeSized()) return false; } @@ -277,7 +277,7 @@ NBL_API2 bool CSPIRVIntrospector::CPipelineIntrospectionData::merge(const CSPIRV // can only be success now const auto& pc = stageData->getPushConstants(); - auto a = pc.size; + [[maybe_unused]] auto a = pc.size; if (pc.present()) { std::span> pcRangesSpan = { @@ -297,7 +297,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); @@ -309,6 +309,7 @@ NBL_API2 core::smart_refctd_dynamic_array CSPIRVIntrospector }; SPushConstantRange current = { + .stageFlags = hlsl::ShaderStage::ESS_UNKNOWN, .offset = 0, .size = 0 }; @@ -411,7 +412,10 @@ CSPIRVIntrospector::CStageIntrospectionData::SDescriptorVarInfo* CSPIRVInt .type = restype }, /*.name = */addString(r.name), - /*.count = */addDescriptorCount(descriptorArraySize, isArrayTypeLiteral) + /*.count = */addDescriptorCount(descriptorArraySize, isArrayTypeLiteral), + /*.restrict_ = */0, + /*.aliased = */0, + /*.union = */{} }; auto& ref = reinterpret_cast>*>(m_descriptorSetBindings)[descSet].emplace_back(std::move(res)); @@ -437,7 +441,7 @@ void CSPIRVIntrospector::CStageIntrospectionData::shaderMemBlockIntrospection(co // NOTE: might need to lookup SPIRType based on `base_type_id` and forward to `SPIRType::type_alias` here instead introspectionStack.emplace(r.base_type_id); - bool first = true; + [[maybe_unused]] bool first = true; while (!introspectionStack.empty()) { const auto entry = introspectionStack.top(); @@ -858,7 +862,7 @@ void CSPIRVIntrospector::CStageIntrospectionData::finalize(const IShader::E_SHAD // get these before they change const auto memberTypes = type->memberTypes()(basePtr); const auto memberNames = type->memberNames()(basePtr); - for (auto m=0; mmemberCount; m++) + for (auto m=0u; mmemberCount; m++) { reinterpret_cast**>(memberTypes)[m] = reinterpret_cast*>(memberTypes[m](basePtr)); reinterpret_cast*>(memberNames)[m] = memberNames[m](basePtr); @@ -910,7 +914,7 @@ void CSPIRVIntrospector::CStageIntrospectionData::printType(std::ostringstream& // pre auto indent = [&]() -> std::ostringstream& { - for (auto i=0; imemberCount; m++) + for (auto m=0u; mmemberCount; m++) { printType(out,type->memberTypes()[m],nextDepth); out << " " << type->memberNames()[m].data() << "; // offset=" << type->memberOffsets()[m] << ",size=" << type->memberSizes()[m] << ",stride=" << type->memberStrides()[m] << "\n"; } @@ -979,7 +983,7 @@ size_t CSPIRVIntrospector::calcBytesizeForType(spirv_cross::Compiler& comp, cons void CSPIRVIntrospector::CStageIntrospectionData::debugPrint(system::ILogger* logger) const { - auto* const basePtr = m_memPool.data(); + [[maybe_unused]] auto* const basePtr = m_memPool.data(); std::ostringstream debug = {}; if (!m_specConstants.empty()) @@ -1054,7 +1058,7 @@ void CSPIRVIntrospector::CStageIntrospectionData::debugPrint(system::ILogger* lo } } - logger->log("%s", system::ILogger::ELL_DEBUG, debug.str() + '\n'); + logger->log("%s", system::ILogger::ELL_DEBUG, (debug.str() + '\n').c_str()); } } \ No newline at end of file diff --git a/src/nbl/asset/utils/CSmoothNormalGenerator.cpp b/src/nbl/asset/utils/CSmoothNormalGenerator.cpp index f8bc45a317..a49c2c49a3 100644 --- a/src/nbl/asset/utils/CSmoothNormalGenerator.cpp +++ b/src/nbl/asset/utils/CSmoothNormalGenerator.cpp @@ -13,12 +13,12 @@ namespace nbl { namespace asset { -static bool operator<(uint32_t lhs, const CSmoothNormalGenerator::VertexData& rhs) +[[maybe_unused]] static bool operator<(uint32_t lhs, const CSmoothNormalGenerator::VertexData& rhs) { return lhs < rhs.hash; } -static bool operator<(const CSmoothNormalGenerator::VertexData& lhs, uint32_t rhs) +[[maybe_unused]] static bool operator<(const CSmoothNormalGenerator::VertexData& lhs, uint32_t rhs) { return lhs.hash < rhs; } @@ -44,7 +44,7 @@ CSmoothNormalGenerator::VertexHashMap CSmoothNormalGenerator::setupData(const as { const size_t idxCount = polygon->getPrimitiveCount() * 3; - const auto cellCount = std::max(core::roundUpToPoT((idxCount + 31) >> 5), 4); + const auto cellCount = std::max(hlsl::roundUpToPoT((idxCount + 31) >> 5), 4); VertexHashMap vertices(idxCount, std::min(16u * 1024u, cellCount), epsilon * 2.f); for (uint32_t i = 0; i < idxCount; i += 3) @@ -75,7 +75,7 @@ core::smart_refctd_ptr CSmoothNormalGenerator::processConne auto outPolygon = core::move_and_static_cast(polygon->clone(0u)); static constexpr auto NormalFormat = EF_R32G32B32_SFLOAT; const auto normalFormatBytesize = asset::getTexelOrBlockBytesize(NormalFormat); - auto normalBuf = ICPUBuffer::create({ normalFormatBytesize * outPolygon->getPositionView().getElementCount()}); + auto normalBuf = ICPUBuffer::create({{ normalFormatBytesize * outPolygon->getPositionView().getElementCount()}}); auto normalView = polygon->getNormalView(); hlsl::shapes::AABB<4,hlsl::float32_t> aabb; diff --git a/src/nbl/asset/utils/ISPIRVEntryPointTrimmer.cpp b/src/nbl/asset/utils/ISPIRVEntryPointTrimmer.cpp index 6695c78e96..08786503cb 100644 --- a/src/nbl/asset/utils/ISPIRVEntryPointTrimmer.cpp +++ b/src/nbl/asset/utils/ISPIRVEntryPointTrimmer.cpp @@ -6,6 +6,8 @@ #include "nbl/system/ILogger.h" #include "spirv-tools/libspirv.hpp" +#include + using namespace nbl::asset; static constexpr spv_target_env SPIRV_VERSION = spv_target_env::SPV_ENV_UNIVERSAL_1_6; @@ -152,7 +154,7 @@ ISPIRVEntryPointTrimmer::Result ISPIRVEntryPointTrimmer::trim(const ICPUBuffer* // Keep in mind about this layout while reading all the code below: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#LogicalLayout // skip until entry point - while (offset < spirvDwordCount) { + while (std::cmp_less(offset, spirvDwordCount)) { const auto instruction = spirv[offset]; const auto [length, opcode] = parse_instruction(instruction); if (opcode == spv::OpEntryPoint) break; @@ -160,7 +162,7 @@ ISPIRVEntryPointTrimmer::Result ISPIRVEntryPointTrimmer::trim(const ICPUBuffer* } // handle entry points removal - while (offset < spirvDwordCount) { + while (std::cmp_less(offset, spirvDwordCount)) { const auto curOffset = offset; const auto instruction = spirv[curOffset]; const auto [length, opcode] = parse_instruction(instruction); @@ -204,7 +206,7 @@ ISPIRVEntryPointTrimmer::Result ISPIRVEntryPointTrimmer::trim(const ICPUBuffer* minimizedSpirv.insert(minimizedSpirv.end(), spirv + curOffset, spirv + offset); } - const auto wereAllEntryPointsFound = foundEntryPoint == entryPoints.size(); + const auto wereAllEntryPointsFound = std::cmp_equal(foundEntryPoint, entryPoints.size()); if (!wereAllEntryPointsFound) { logger.log("Some entry point that is requested to be retained is not found in SPIR-V", system::ILogger::ELL_ERROR); @@ -223,7 +225,7 @@ ISPIRVEntryPointTrimmer::Result ISPIRVEntryPointTrimmer::trim(const ICPUBuffer* } // handle execution model removal - while (offset < spirvDwordCount) + while (std::cmp_less(offset, spirvDwordCount)) { const auto curOffset = offset; const auto instruction = spirv[curOffset]; diff --git a/src/nbl/asset/utils/ISPIRVOptimizer.cpp b/src/nbl/asset/utils/ISPIRVOptimizer.cpp index 8833f016f8..1b4e7ca004 100644 --- a/src/nbl/asset/utils/ISPIRVOptimizer.cpp +++ b/src/nbl/asset/utils/ISPIRVOptimizer.cpp @@ -106,7 +106,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 a6cd95b441..3c3fe4db8c 100644 --- a/src/nbl/asset/utils/IShaderCompiler.cpp +++ b/src/nbl/asset/utils/IShaderCompiler.cpp @@ -414,7 +414,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))); @@ -569,7 +569,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 @@ -623,7 +623,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); @@ -636,8 +636,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) { @@ -671,7 +671,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/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/core/alloc/refctd_memory_resource.cpp b/src/nbl/core/alloc/refctd_memory_resource.cpp index 9eb9a991b4..da2aa1d5e0 100644 --- a/src/nbl/core/alloc/refctd_memory_resource.cpp +++ b/src/nbl/core/alloc/refctd_memory_resource.cpp @@ -12,7 +12,7 @@ namespace nbl::core { static smart_refctd_ptr default_memory_resource = nullptr; -smart_refctd_ptr core::getNullMemoryResource() +smart_refctd_ptr getNullMemoryResource() { static smart_refctd_ptr null_memory_resource = nullptr; if (!null_memory_resource) @@ -20,14 +20,14 @@ smart_refctd_ptr core::getNullMemoryResource() return null_memory_resource; } -smart_refctd_ptr core::getDefaultMemoryResource() +smart_refctd_ptr getDefaultMemoryResource() { if (!default_memory_resource) default_memory_resource = make_smart_refctd_ptr(std::pmr::get_default_resource()); return default_memory_resource; } -void core::setDefaultMemoryResource(refctd_memory_resource* memoryResource) +void setDefaultMemoryResource(refctd_memory_resource* memoryResource) { default_memory_resource = smart_refctd_ptr(memoryResource, dont_grab); } diff --git a/src/nbl/system/CArchiveLoaderTar.cpp b/src/nbl/system/CArchiveLoaderTar.cpp index 25a3bfd6df..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 { @@ -148,7 +149,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()); @@ -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/system/CArchiveLoaderZip.cpp b/src/nbl/system/CArchiveLoaderZip.cpp index c820f12cb6..c936495407 100644 --- a/src/nbl/system/CArchiveLoaderZip.cpp +++ b/src/nbl/system/CArchiveLoaderZip.cpp @@ -97,7 +97,7 @@ struct SZipFileExtraHeader constexpr int16_t ZIP_FILE_ENCRYPTED = 0x0001; // the fields crc-32, compressed size and uncompressed size are set to // zero in the local header -constexpr int16_t ZIP_INFO_IN_DATA_DESCRIPTOR = 0x0008; +[[maybe_unused]] constexpr int16_t ZIP_INFO_IN_DATA_DESCRIPTOR = 0x0008; using namespace nbl; @@ -577,8 +577,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); @@ -602,7 +602,12 @@ 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, 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/system/CColoredStdoutLoggerWin32.cpp b/src/nbl/system/CColoredStdoutLoggerWin32.cpp index f2690a81b4..1e34a6d6f8 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 diff --git a/src/nbl/system/CSystemWin32.cpp b/src/nbl/system/CSystemWin32.cpp index 2798b4fb27..788716189e 100644 --- a/src/nbl/system/CSystemWin32.cpp +++ b/src/nbl/system/CSystemWin32.cpp @@ -60,7 +60,7 @@ core::smart_refctd_ptr CSystemWin32::CCaller::createFile(const std: HANDLE _native = CreateFileA(p.string().data(), fileAccess, shareMode, &secAttribs, creationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr); if (_native==INVALID_HANDLE_VALUE) { - auto e = GetLastError(); + [[maybe_unused]] auto e = GetLastError(); return nullptr; } diff --git a/src/nbl/system/DefaultFuncPtrLoader.cpp b/src/nbl/system/DefaultFuncPtrLoader.cpp index e073608dae..fe522106e1 100644 --- a/src/nbl/system/DefaultFuncPtrLoader.cpp +++ b/src/nbl/system/DefaultFuncPtrLoader.cpp @@ -59,7 +59,7 @@ void* DefaultFuncPtrLoader::loadFuncPtr(const char* funcname) if (isLibraryLoaded()) { #if defined(_NBL_WINDOWS_API_) - return GetProcAddress(LIB,funcname); + return reinterpret_cast(GetProcAddress(LIB,funcname)); #elif defined(_NBL_POSIX_API_) return dlsym(lib,funcname); #endif diff --git a/src/nbl/system/IFileArchive.cpp b/src/nbl/system/IFileArchive.cpp index bc8fb9a1c7..2eface5f29 100644 --- a/src/nbl/system/IFileArchive.cpp +++ b/src/nbl/system/IFileArchive.cpp @@ -30,13 +30,13 @@ IFileArchive::SFileList IFileArchive::listAssets(path pathRelativeToArchive) con // // lower bound // by appending slash and char with code 1, we essentially make sure that all matches will be lexicographically greater, and start with pathRelativeToArchive/ - const auto lower = std::lower_bound(begin,end, SFileList::SEntry{pathRelativeToArchive/"\1"}); + const auto lower = std::lower_bound(begin,end, SFileList::SEntry{pathRelativeToArchive/"\1", 0ull, 0ull, 0u, EAT_NULL }); if (lower!=end) { // upper bound // we cannot do std::upper_bound, because any value longer than pathRelativeToArchive is greater, thus the only matches between std::lower_bound and std::upper_bound would be ones exactly matching pathRelativeToArchive // by appending char with code 1 and taking the lower bound, we can find the first element with prefix greater than pathRelativeToArchive, thus the upper bound - auto upper = std::lower_bound(lower,end,SFileList::SEntry{pathRelativeToArchive.string()+"\1"}); + auto upper = std::lower_bound(lower,end,SFileList::SEntry{pathRelativeToArchive.string()+"\1", 0ull, 0ull, 0u, EAT_NULL }); trimmedList.m_span = {lower,upper}; } else 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); 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/CWindowManagerWin32.h b/src/nbl/ui/CWindowManagerWin32.h index 93ffb67071..6dabdbba3f 100644 --- a/src/nbl/ui/CWindowManagerWin32.h +++ b/src/nbl/ui/CWindowManagerWin32.h @@ -5,6 +5,12 @@ #include "nbl/ui/IWindowWin32.h" #include "nbl/ui/ICursorControl.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + #ifdef _NBL_PLATFORM_WINDOWS_ namespace nbl::ui { @@ -34,7 +40,7 @@ class NBL_API2 CWindowManagerWin32 final : public IWindowManagerWin32, public IC inline bool isVisible() const override { - CURSORINFO ci = { sizeof(CURSORINFO) }; + CURSORINFO ci = { sizeof(CURSORINFO), 0 }; GetCursorInfo(&ci); return ci.flags; // returning flags cause they're equal to 0 when the cursor is hidden } @@ -216,4 +222,9 @@ class NBL_API2 CWindowManagerWin32 final : public IWindowManagerWin32, public IC } #endif + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #endif \ No newline at end of file diff --git a/src/nbl/ui/CWindowWin32.cpp b/src/nbl/ui/CWindowWin32.cpp index dd87ca9dee..b09bf4cfaa 100644 --- a/src/nbl/ui/CWindowWin32.cpp +++ b/src/nbl/ui/CWindowWin32.cpp @@ -32,7 +32,7 @@ CWindowWin32::CWindowWin32(SCreationParams&& params, core::smart_refctd_ptr devices(deviceCount); GetRawInputDeviceList(devices.data(), &deviceCount, sizeof(RAWINPUTDEVICELIST)); auto deviceList = devices.data(); - for (int i = 0; i < deviceCount; i++) + for (UINT i = 0; i < deviceCount; i++) { auto hDevice = deviceList[i].hDevice; switch (deviceList[i].dwType) @@ -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; } @@ -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); @@ -205,7 +205,7 @@ LRESULT CALLBACK CWindowWin32::WndProc(HWND hWnd, UINT message, WPARAM wParam, L { RAWINPUT* rawInput; UINT size; - UINT headerSize; + [[maybe_unused]] UINT headerSize; GetRawInputData((HRAWINPUT)lParam, RID_INPUT, nullptr, &size, sizeof(RAWINPUTHEADER)); core::vector data(size); // TODO: preallocate some upper bound, dont want an alloc here! GetRawInputData((HRAWINPUT)lParam, RID_INPUT, data.data(), &size, sizeof(RAWINPUTHEADER)); diff --git a/src/nbl/ui/CWindowWin32.h b/src/nbl/ui/CWindowWin32.h index fcb675900e..e85759fe71 100644 --- a/src/nbl/ui/CWindowWin32.h +++ b/src/nbl/ui/CWindowWin32.h @@ -81,7 +81,6 @@ class NBL_API2 CWindowWin32 final : public IWindowWin32 inline core::smart_refctd_ptr removeMouseEventChannel(HANDLE deviceHandle) { - RAWINPUT; auto it = m_mouseEventChannels.find(deviceHandle); auto channel = std::move(it->second); m_mouseEventChannels.erase(it); diff --git a/src/nbl/video/CSurfaceVulkan.cpp b/src/nbl/video/CSurfaceVulkan.cpp index 7feda9fcd3..75d42838a7 100644 --- a/src/nbl/video/CSurfaceVulkan.cpp +++ b/src/nbl/video/CSurfaceVulkan.cpp @@ -2,6 +2,13 @@ #include #include +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#pragma clang diagnostic ignored "-Wimplicit-int-conversion" +#endif + namespace nbl::video { bool ISurfaceVulkan::isSupportedForPhysicalDevice(const IPhysicalDevice* physicalDevice, const uint32_t _queueFamIx) const @@ -106,7 +113,7 @@ bool ISurfaceVulkan::isSupportedForPhysicalDevice(const IPhysicalDevice* physica } capabilities.minImageCount = vk_surfaceCapabilities.surfaceCapabilities.minImageCount; - capabilities.maxImageCount = (vk_surfaceCapabilities.surfaceCapabilities.maxImageCount == 0u) ? ~0u : vk_surfaceCapabilities.surfaceCapabilities.maxImageCount; + capabilities.maxImageCount = static_cast((vk_surfaceCapabilities.surfaceCapabilities.maxImageCount == 0u) ? ~0u : vk_surfaceCapabilities.surfaceCapabilities.maxImageCount); capabilities.currentExtent = vk_surfaceCapabilities.surfaceCapabilities.currentExtent; capabilities.minImageExtent = vk_surfaceCapabilities.surfaceCapabilities.minImageExtent; capabilities.maxImageExtent = vk_surfaceCapabilities.surfaceCapabilities.maxImageExtent; @@ -165,4 +172,8 @@ core::smart_refctd_ptr CSurfaceVulkanWin32Native::cre return core::smart_refctd_ptr(retval, core::dont_grab); } #endif -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanAccelerationStructure.cpp b/src/nbl/video/CVulkanAccelerationStructure.cpp index 94c63010b5..688825125a 100644 --- a/src/nbl/video/CVulkanAccelerationStructure.cpp +++ b/src/nbl/video/CVulkanAccelerationStructure.cpp @@ -1,6 +1,12 @@ #include "nbl/video/CVulkanAccelerationStructure.h" #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -38,4 +44,8 @@ bool CVulkanAccelerationStructure::wasBuildSuccessful( template class CVulkanAccelerationStructure; template class CVulkanAccelerationStructure; -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanAccelerationStructure.h b/src/nbl/video/CVulkanAccelerationStructure.h index 4c0d67eee1..3faed9cde0 100644 --- a/src/nbl/video/CVulkanAccelerationStructure.h +++ b/src/nbl/video/CVulkanAccelerationStructure.h @@ -9,6 +9,12 @@ #include "nbl/video/CVulkanCommon.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#pragma clang diagnostic ignored "-Wsign-compare" +#endif namespace nbl::video { @@ -19,7 +25,7 @@ template //requires std::is_base_of_vgetInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanBufferView.cpp b/src/nbl/video/CVulkanBufferView.cpp index 2995b7734e..b36110a84b 100644 --- a/src/nbl/video/CVulkanBufferView.cpp +++ b/src/nbl/video/CVulkanBufferView.cpp @@ -3,6 +3,12 @@ #include "nbl/video/CVulkanCommon.h" #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -27,4 +33,8 @@ void CVulkanBufferView::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanCommandBuffer.cpp b/src/nbl/video/CVulkanCommandBuffer.cpp index a04b5940ce..1391ae4be5 100644 --- a/src/nbl/video/CVulkanCommandBuffer.cpp +++ b/src/nbl/video/CVulkanCommandBuffer.cpp @@ -4,6 +4,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" #include "nbl/video/CVulkanQueryPool.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#pragma clang diagnostic ignored "-Wsign-compare" +#endif using namespace nbl; using namespace nbl::video; @@ -875,4 +881,8 @@ bool CVulkanCommandBuffer::executeCommands_impl(const uint32_t count, IGPUComman getFunctionTable().vkCmdExecuteCommands(m_cmdbuf, count, vk_commandBuffers.data()); return true; -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanCommandBuffer.h b/src/nbl/video/CVulkanCommandBuffer.h index 48d7e9e85c..aab3b9af58 100644 --- a/src/nbl/video/CVulkanCommandBuffer.h +++ b/src/nbl/video/CVulkanCommandBuffer.h @@ -15,6 +15,12 @@ #include "nbl/video/CVulkanPipelineLayout.h" #include "nbl/video/CVulkanComputePipeline.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -177,9 +183,9 @@ class CVulkanCommandBuffer final : public IGPUCommandBuffer return true; } - bool copyAccelerationStructure_impl(const IGPUAccelerationStructure* src, IGPUAccelerationStructure* dst, const bool compact); - bool copyAccelerationStructureToMemory_impl(const IGPUAccelerationStructure* src, const asset::SBufferBinding& dst); - bool copyAccelerationStructureFromMemory_impl(const asset::SBufferBinding& src, IGPUAccelerationStructure* dst); + bool copyAccelerationStructure_impl(const IGPUAccelerationStructure* src, IGPUAccelerationStructure* dst, const bool compact) override; + bool copyAccelerationStructureToMemory_impl(const IGPUAccelerationStructure* src, const asset::SBufferBinding& dst) override; + bool copyAccelerationStructureFromMemory_impl(const asset::SBufferBinding& src, IGPUAccelerationStructure* dst) override; bool bindComputePipeline_impl(const IGPUComputePipeline* const pipeline) override; bool bindGraphicsPipeline_impl(const IGPUGraphicsPipeline* const pipeline) override; @@ -284,4 +290,8 @@ class CVulkanCommandBuffer final : public IGPUCommandBuffer } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #endif diff --git a/src/nbl/video/CVulkanCommandPool.cpp b/src/nbl/video/CVulkanCommandPool.cpp index f879cee518..3fd1bd031c 100644 --- a/src/nbl/video/CVulkanCommandPool.cpp +++ b/src/nbl/video/CVulkanCommandPool.cpp @@ -2,6 +2,13 @@ #include "nbl/video/CVulkanCommandBuffer.h" #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#pragma clang diagnostic ignored "-Wmisleading-indentation" +#endif + namespace nbl::video { @@ -64,4 +71,8 @@ bool CVulkanCommandPool::reset_impl() return vulkanDevice->getFunctionTable()->vk.vkResetCommandPool(vulkanDevice->getInternalObject(),m_vkCommandPool,VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT)==VK_SUCCESS; } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanCommandPool.h b/src/nbl/video/CVulkanCommandPool.h index d1c3085b4e..6dddf47ccb 100644 --- a/src/nbl/video/CVulkanCommandPool.h +++ b/src/nbl/video/CVulkanCommandPool.h @@ -26,7 +26,7 @@ class CVulkanCommandPool final : public IGPUCommandPool private: ~CVulkanCommandPool(); - bool createCommandBuffers_impl(const BUFFER_LEVEL level, const std::span> 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/CVulkanComputePipeline.cpp b/src/nbl/video/CVulkanComputePipeline.cpp index 8335bae4fc..e301d18ada 100644 --- a/src/nbl/video/CVulkanComputePipeline.cpp +++ b/src/nbl/video/CVulkanComputePipeline.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -26,4 +32,8 @@ void CVulkanComputePipeline::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanConnection.cpp b/src/nbl/video/CVulkanConnection.cpp index 42122937a6..dfb27e8357 100644 --- a/src/nbl/video/CVulkanConnection.cpp +++ b/src/nbl/video/CVulkanConnection.cpp @@ -4,6 +4,12 @@ #include "nbl/video/CVulkanCommon.h" #include "nbl/video/debug/CVulkanDebugCallback.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + // TODO: move inside `create` and call it LOG_FAIL and return nullptr #define LOG(logger, ...) if (logger) {logger->log(__VA_ARGS__);} @@ -214,6 +220,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) @@ -377,7 +384,11 @@ bool CVulkanConnection::endCapture() int vulkaninfo(const std::span args) { - return ::vulkaninfo(args.size(), const_cast(args.data())); + return ::vulkaninfo(args.size(), const_cast(args.data())); } } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/src/nbl/video/CVulkanDescriptorPool.cpp b/src/nbl/video/CVulkanDescriptorPool.cpp index 5ad067ddcf..c36e3bb2aa 100644 --- a/src/nbl/video/CVulkanDescriptorPool.cpp +++ b/src/nbl/video/CVulkanDescriptorPool.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -66,4 +72,8 @@ bool CVulkanDescriptorPool::reset_impl() return success; } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanDescriptorSetLayout.cpp b/src/nbl/video/CVulkanDescriptorSetLayout.cpp index 69635880a8..a3a1003857 100644 --- a/src/nbl/video/CVulkanDescriptorSetLayout.cpp +++ b/src/nbl/video/CVulkanDescriptorSetLayout.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { CVulkanDescriptorSetLayout::~CVulkanDescriptorSetLayout() @@ -23,4 +29,8 @@ void CVulkanDescriptorSetLayout::setObjectDebugName(const char* label) const nameInfo.pObjectName = getObjectDebugName(); vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanDeviceMemoryBacked.cpp b/src/nbl/video/CVulkanDeviceMemoryBacked.cpp index 90b2993cb3..31e87781e4 100644 --- a/src/nbl/video/CVulkanDeviceMemoryBacked.cpp +++ b/src/nbl/video/CVulkanDeviceMemoryBacked.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanDeviceMemoryBacked.h" #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -43,4 +49,8 @@ CVulkanDeviceMemoryBacked::CVulkanDeviceMemoryBacked( template class CVulkanDeviceMemoryBacked; template class CVulkanDeviceMemoryBacked; -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanFramebuffer.cpp b/src/nbl/video/CVulkanFramebuffer.cpp index f79ecc59c9..a4390af374 100644 --- a/src/nbl/video/CVulkanFramebuffer.cpp +++ b/src/nbl/video/CVulkanFramebuffer.cpp @@ -4,6 +4,12 @@ #include "nbl/video/CVulkanRenderpass.h" #include "nbl/video/CVulkanImageView.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -28,4 +34,8 @@ void CVulkanFramebuffer::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanImage.cpp b/src/nbl/video/CVulkanImage.cpp index 748f21720b..80d7046044 100644 --- a/src/nbl/video/CVulkanImage.cpp +++ b/src/nbl/video/CVulkanImage.cpp @@ -3,6 +3,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -31,4 +37,8 @@ void CVulkanImage::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanImageView.cpp b/src/nbl/video/CVulkanImageView.cpp index 31a2bc6385..56b2039981 100644 --- a/src/nbl/video/CVulkanImageView.cpp +++ b/src/nbl/video/CVulkanImageView.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -26,4 +32,8 @@ void CVulkanImageView::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanLogicalDevice.cpp b/src/nbl/video/CVulkanLogicalDevice.cpp index 46b79a7094..19ecb3ca66 100644 --- a/src/nbl/video/CVulkanLogicalDevice.cpp +++ b/src/nbl/video/CVulkanLogicalDevice.cpp @@ -8,6 +8,12 @@ #include "nbl/video/CVulkanQueryPool.h" #include "nbl/video/CVulkanCommandBuffer.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#pragma clang diagnostic ignored "-Wsign-compare" +#endif using namespace nbl; using namespace nbl::video; @@ -201,7 +207,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; } @@ -651,7 +657,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) { @@ -1472,7 +1478,14 @@ void CVulkanLogicalDevice::createRayTracingPipelines_impl( const SSpecializationValidationResult& validation ) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-local-typedef" +#endif using SShaderGroupParams = IGPURayTracingPipeline::SCreationParams::SShaderGroupsParams; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif using SHitShaderGroup = IGPURayTracingPipeline::SHitGroup; const auto dynamicStates = std::array{ VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR }; @@ -1696,4 +1709,8 @@ core::smart_refctd_ptr CVulkanLogicalDevice::createCommandPool_ if (m_devf.vk.vkCreateCommandPool(m_vkdev,&vk_createInfo,nullptr,&vk_commandPool)==VK_SUCCESS) return core::make_smart_refctd_ptr(core::smart_refctd_ptr(this),flags,familyIx,vk_commandPool); return nullptr; -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanLogicalDevice.h b/src/nbl/video/CVulkanLogicalDevice.h index 4cc633ec55..a0e379b9ed 100644 --- a/src/nbl/video/CVulkanLogicalDevice.h +++ b/src/nbl/video/CVulkanLogicalDevice.h @@ -32,6 +32,12 @@ #include "nbl/video/CVulkanGraphicsPipeline.h" #include "nbl/video/CVulkanRayTracingPipeline.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -78,7 +84,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: @@ -322,4 +328,8 @@ class CVulkanLogicalDevice final : public ILogicalDevice } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanPhysicalDevice.cpp b/src/nbl/video/CVulkanPhysicalDevice.cpp index da86d7c9d9..9d269d05c5 100644 --- a/src/nbl/video/CVulkanPhysicalDevice.cpp +++ b/src/nbl/video/CVulkanPhysicalDevice.cpp @@ -1,6 +1,15 @@ #include "nbl/video/CVulkanPhysicalDevice.h" #include "nbl/video/CVulkanLogicalDevice.h" +#include "nbl/builtin/hlsl/math/intutil.hlsl" + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#pragma clang diagnostic ignored "-Wsign-compare" +#endif + namespace nbl::video { @@ -410,9 +419,9 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart properties.conformanceVersion.patch = vulkan12Properties.conformanceVersion.patch; // Helper bools :D - const bool isIntelGPU = (properties.driverID == E_DRIVER_ID::EDI_INTEL_OPEN_SOURCE_MESA || properties.driverID == E_DRIVER_ID::EDI_INTEL_PROPRIETARY_WINDOWS); - const bool isAMDGPU = (properties.driverID == E_DRIVER_ID::EDI_AMD_OPEN_SOURCE || properties.driverID == E_DRIVER_ID::EDI_AMD_PROPRIETARY); - const bool isNVIDIAGPU = (properties.driverID == E_DRIVER_ID::EDI_NVIDIA_PROPRIETARY); + [[maybe_unused]] const bool isIntelGPU = (properties.driverID == E_DRIVER_ID::EDI_INTEL_OPEN_SOURCE_MESA || properties.driverID == E_DRIVER_ID::EDI_INTEL_PROPRIETARY_WINDOWS); + [[maybe_unused]] const bool isAMDGPU = (properties.driverID == E_DRIVER_ID::EDI_AMD_OPEN_SOURCE || properties.driverID == E_DRIVER_ID::EDI_AMD_PROPRIETARY); + [[maybe_unused]] const bool isNVIDIAGPU = (properties.driverID == E_DRIVER_ID::EDI_NVIDIA_PROPRIETARY); //vulkan12Properties.denormBehaviorIndependence; //vulkan12Properties.denormBehaviorIndependence; @@ -647,7 +656,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)) @@ -1339,6 +1348,8 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart if (!isExtensionSupported(VK_IMG_FORMAT_PVRTC_EXTENSION_NAME)) skip = true; break; + default: + break; } if (skip) continue; @@ -1928,3 +1939,7 @@ core::smart_refctd_ptr CVulkanPhysicalDevice::createLogicalDevic } } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/src/nbl/video/CVulkanPipelineCache.cpp b/src/nbl/video/CVulkanPipelineCache.cpp index 8610eee75f..bbf48f7279 100644 --- a/src/nbl/video/CVulkanPipelineCache.cpp +++ b/src/nbl/video/CVulkanPipelineCache.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -55,4 +61,8 @@ void CVulkanPipelineCache::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanPipelineLayout.cpp b/src/nbl/video/CVulkanPipelineLayout.cpp index f85e3212fb..f82d4e2e79 100644 --- a/src/nbl/video/CVulkanPipelineLayout.cpp +++ b/src/nbl/video/CVulkanPipelineLayout.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -26,4 +32,8 @@ void CVulkanPipelineLayout::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanQueue.cpp b/src/nbl/video/CVulkanQueue.cpp index 109507d777..9503d37fff 100644 --- a/src/nbl/video/CVulkanQueue.cpp +++ b/src/nbl/video/CVulkanQueue.cpp @@ -4,6 +4,12 @@ #include "nbl/video/CVulkanSemaphore.h" #include "nbl/video/CVulkanCommandBuffer.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -116,4 +122,8 @@ bool CVulkanQueue::endDebugMarker() } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanQueue.h b/src/nbl/video/CVulkanQueue.h index 40eb060bd2..351c6e1b2d 100644 --- a/src/nbl/video/CVulkanQueue.h +++ b/src/nbl/video/CVulkanQueue.h @@ -16,7 +16,7 @@ class CVulkanQueue final : public IQueue { public: inline CVulkanQueue(ILogicalDevice* logicalDevice, renderdoc_api_t* rdoc, VkInstance vkinst, VkQueue vkq, const uint32_t _famIx, const core::bitflag _flags, const float _priority) - : IQueue(logicalDevice, _famIx, _flags, _priority), m_vkQueue(vkq), m_rdoc_api(rdoc), m_vkInstance(vkinst) {} + : IQueue(logicalDevice, _famIx, _flags, _priority), m_rdoc_api(rdoc), m_vkInstance(vkinst), m_vkQueue(vkq) {} static inline RESULT getResultFrom(const VkResult result) { @@ -45,8 +45,8 @@ class CVulkanQueue final : public IQueue RESULT submit_impl(const std::span _submits) override; RESULT waitIdle_impl() const override; - renderdoc_api_t* m_rdoc_api; - VkInstance m_vkInstance; + [[maybe_unused]] renderdoc_api_t* m_rdoc_api; + [[maybe_unused]] VkInstance m_vkInstance; VkQueue m_vkQueue; }; diff --git a/src/nbl/video/CVulkanRenderpass.cpp b/src/nbl/video/CVulkanRenderpass.cpp index 51b4e40990..b70662545c 100644 --- a/src/nbl/video/CVulkanRenderpass.cpp +++ b/src/nbl/video/CVulkanRenderpass.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -26,4 +32,8 @@ void CVulkanRenderpass::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanSampler.cpp b/src/nbl/video/CVulkanSampler.cpp index b4d95c3728..f389ed417a 100644 --- a/src/nbl/video/CVulkanSampler.cpp +++ b/src/nbl/video/CVulkanSampler.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -26,4 +32,8 @@ void CVulkanSampler::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanSemaphore.cpp b/src/nbl/video/CVulkanSemaphore.cpp index 071c4b2843..826d1a1e5c 100644 --- a/src/nbl/video/CVulkanSemaphore.cpp +++ b/src/nbl/video/CVulkanSemaphore.cpp @@ -2,6 +2,12 @@ #include "nbl/video/CVulkanLogicalDevice.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif + namespace nbl::video { @@ -44,4 +50,8 @@ void CVulkanSemaphore::setObjectDebugName(const char* label) const vkSetDebugUtilsObjectNameEXT(vulkanDevice->getInternalObject(), &nameInfo); } -} \ No newline at end of file +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif \ No newline at end of file diff --git a/src/nbl/video/CVulkanSwapchain.cpp b/src/nbl/video/CVulkanSwapchain.cpp index af551fd28d..440620cf1d 100644 --- a/src/nbl/video/CVulkanSwapchain.cpp +++ b/src/nbl/video/CVulkanSwapchain.cpp @@ -4,6 +4,13 @@ #include "nbl/video/CVulkanImage.h" #include "nbl/video/CVulkanConnection.h" +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#pragma clang diagnostic ignored "-Wsign-compare" +#endif + namespace nbl::video { @@ -515,3 +522,7 @@ void CVulkanSwapchain::setObjectDebugName(const char* label) const } } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/src/nbl/video/IAPIConnection.cpp b/src/nbl/video/IAPIConnection.cpp index 05ababf2f1..1028b03577 100644 --- a/src/nbl/video/IAPIConnection.cpp +++ b/src/nbl/video/IAPIConnection.cpp @@ -125,14 +125,14 @@ renderdoc_api_t* IAPIConnection::loadRenderdoc() pRENDERDOC_GetAPI RENDERDOC_GetAPI = nullptr; #ifdef _NBL_PLATFORM_WINDOWS_ - if (HMODULE mod=GetModuleHandleA("renderdoc.dll"); mod) - RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)GetProcAddress(mod,"RENDERDOC_GetAPI"); + if (HMODULE mod = GetModuleHandleA("renderdoc.dll"); mod) + RENDERDOC_GetAPI = reinterpret_cast(reinterpret_cast(GetProcAddress(mod, "RENDERDOC_GetAPI"))); #elif defined(_NBL_PLATFORM_ANDROID_) if (void* mod=dlopen("libVkLayer_GLES_RenderDoc.so",RTLD_NOW|RTLD_NOLOAD); mod) - pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod,"RENDERDOC_GetAPI"); + RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod,"RENDERDOC_GetAPI"); #elif defined(_NBL_PLATFORM_LINUX_) if (void* mod=dlopen("librenderdoc.so",RTLD_NOW|RTLD_NOLOAD); mod) - pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod,"RENDERDOC_GetAPI"); + RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod,"RENDERDOC_GetAPI"); #else #error "Nabla Unsupported Platform!" #endif diff --git a/src/nbl/video/IDescriptorPool.cpp b/src/nbl/video/IDescriptorPool.cpp index 3df1616c4c..5c7b033829 100644 --- a/src/nbl/video/IDescriptorPool.cpp +++ b/src/nbl/video/IDescriptorPool.cpp @@ -7,7 +7,7 @@ namespace nbl::video IDescriptorPool::IDescriptorPool(core::smart_refctd_ptr&& dev, const SCreateInfo& createInfo) : IBackendObject(std::move(dev)), m_creationParameters(createInfo), m_logger(getOriginDevice()->getPhysicalDevice()->getDebugCallback() ? getOriginDevice()->getPhysicalDevice()->getDebugCallback()->getLogger():nullptr) { - for (auto i = 0; i < static_cast(asset::IDescriptor::E_TYPE::ET_COUNT); ++i) + for (size_t i = 0; i < static_cast(asset::IDescriptor::E_TYPE::ET_COUNT); ++i) m_descriptorAllocators[i] = std::make_unique(m_creationParameters.maxDescriptorCount[i], m_creationParameters.flags.hasFlags(ECF_FREE_DESCRIPTOR_SET_BIT)); // For mutable samplers pertaining to combined image samplers. We don't know if there will be mutable samplers in sets allocated by this pool when we create the pool. @@ -87,7 +87,7 @@ bool IDescriptorPool::reset() { // something else except for the allocated sets needs to be holding onto the pool, so that // we don't have an implicit call to `~IDescriptorPool` on `this` before we get out of the current stackframe - assert(getReferenceCount() > m_descriptorSetAllocator.get_allocated_size()); + assert(std::cmp_greater(getReferenceCount(), m_descriptorSetAllocator.get_allocated_size())); const auto& compilerIsRetarded = m_descriptorSetAllocator; for (const uint32_t setIndex : compilerIsRetarded) diff --git a/src/nbl/video/IGPUAccelerationStructure.cpp b/src/nbl/video/IGPUAccelerationStructure.cpp index 828ba309b8..7dd14b1616 100644 --- a/src/nbl/video/IGPUAccelerationStructure.cpp +++ b/src/nbl/video/IGPUAccelerationStructure.cpp @@ -75,15 +75,15 @@ uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(cons return {}; const uint32_t geometryCount = inputCount(); - // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793 - if (geometryCount>limits.maxAccelerationStructureGeometryCount) - return {}; + // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793 + if (geometryCount>limits.maxAccelerationStructureGeometryCount) + return {}; const bool isAABB = buildFlags.hasFlags(BUILD_FLAGS::GEOMETRY_TYPE_IS_AABB_BIT); #ifdef _NBL_DEBUG size_t totalPrims = 0ull; - const auto& bufferUsages = physDev->getBufferFormatUsages(); + // const auto& bufferUsages = physDev->getBufferFormatUsages(); for (auto i=0u; i; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif const auto& limits = getOriginDevice()->getPhysicalDevice()->getLimits(); auto invalidBufferRegion = [this, &limits](const asset::SStridedRange& stRange, const char* groupName) -> bool @@ -1036,7 +1044,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; @@ -1308,7 +1316,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))) { @@ -1575,7 +1583,7 @@ bool IGPUCommandBuffer::clearAttachments(const SClearAttachments& info) return false; } } - for (auto i=0; i&& layout, core::smart_refctd_ptr&& pool, IDescriptorPool::SStorageOffsets&& offsets) - : base_t(std::move(layout)), IBackendObject(std::move(core::smart_refctd_ptr(pool->getOriginDevice()))), m_version(0ull), m_pool(std::move(pool)), m_storageOffsets(std::move(offsets)) + : base_t(std::move(layout)), IBackendObject(core::smart_refctd_ptr(pool->getOriginDevice())), m_version(0ull), m_pool(std::move(pool)), m_storageOffsets(std::move(offsets)) { for (auto i = 0u; i < static_cast(asset::IDescriptor::E_TYPE::ET_COUNT); ++i) { @@ -172,7 +172,7 @@ void IGPUDescriptorSet::processWrite(const IGPUDescriptorSet::SWriteDescriptorSe assert(mutableSamplers); } - for (auto j = 0; j < write.count; ++j) + for (uint32_t j = 0; j < write.count; ++j) { descriptors[j + write.arrayElement] = write.info[j].desc; diff --git a/src/nbl/video/ILogicalDevice.cpp b/src/nbl/video/ILogicalDevice.cpp index d5b38f9b69..7e7aeddfa8 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" @@ -59,8 +60,9 @@ class SpirvTrimTask }; 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_compilerSet(params.compilerSet), m_api(api), m_physicalDevice(physicalDevice), m_logger(m_physicalDevice->getDebugCallback() ? m_physicalDevice->getDebugCallback()->getLogger() : nullptr), + m_enabledFeatures(params.featuresToEnable), m_spirvTrimmer(core::make_smart_refctd_ptr()) { { @@ -222,78 +224,78 @@ 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); - 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; - }; + // 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 +// // 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; } @@ -341,7 +343,7 @@ core::smart_refctd_ptr ILogicalDevice::compileShader(const SShad if (creationParams.optimizer) { spirvShader = core::make_smart_refctd_ptr( - std::move(creationParams.optimizer->optimize(source->getContent(), m_logger)), + creationParams.optimizer->optimize(source->getContent(), m_logger), asset::IShader::E_CONTENT_TYPE::ECT_SPIRV, std::string(source->getFilepathHint())); } @@ -491,8 +493,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; @@ -557,12 +559,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]); @@ -638,7 +640,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 @@ -943,7 +945,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()) @@ -1149,4 +1151,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 diff --git a/src/nbl/video/IPhysicalDevice.cpp b/src/nbl/video/IPhysicalDevice.cpp index dca2a47289..84c00b088b 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/IQueue.cpp b/src/nbl/video/IQueue.cpp index 108f76183c..bc81758381 100644 --- a/src/nbl/video/IQueue.cpp +++ b/src/nbl/video/IQueue.cpp @@ -177,8 +177,6 @@ IQueue::DeferredSubmitCallback::DeferredSubmitCallback(const SSubmitInfo& info) case 0: { const IGPUCommandBuffer::TLASTrackingWrite& op = std::get<0>(var); - - using iterator = decltype(op.src)::iterator; m_readTLASVersions[op.dst] = m_TLASOverwrites[op.dst] = op.dst->pushTrackedBLASes({op.src.begin()},{op.src.end()}); break; } 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); diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index d7f2d7dbbc..20a9ec15cd 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -2,8 +2,20 @@ // This file is part of the "Nabla Engine". #include "nbl/video/utilities/CAssetConverter.h" +#include "nbl/builtin/hlsl/math/intutil.hlsl" + #include +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-braces" +#pragma clang diagnostic ignored "-Wsign-compare" +#pragma clang diagnostic ignored "-Wimplicit-int-conversion" +#pragma clang diagnostic ignored "-Wbitfield-constant-conversion" +#pragma clang diagnostic ignored "-Wunused-lambda-capture" +#endif using namespace nbl::core; using namespace nbl::asset; @@ -519,7 +531,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) { @@ -609,7 +621,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()) @@ -1460,7 +1472,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()) @@ -1474,7 +1486,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; @@ -1542,7 +1554,7 @@ bool CAssetConverter::CHashCache::hash_impl::operator()(lookup_tgetCachedCreationParams(); { - for (auto i=0; i : public GetDependantVisitBasegetMemoryReqs(); // round up the offset to get the correct alignment - offsetsTmp[i] = core::roundUp(offsetsTmp[i],0x1ull< 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); @@ -2874,7 +2887,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult auto visit = [&](const patched_instance_t& user)->void { // we don't use the result yet - const bool success = AssetVisitor>{ + [[maybe_unused]] const bool success = AssetVisitor>{ { .inputs = inputs, .device = device, @@ -3015,7 +3028,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult } ); // special pass to propagate Motion Acceleration Structure flag upwards from BLAS to referencing TLAS - std::get>(dfsCaches).for_each([device,&inputs,&dfsCaches](const instance_t& assetInstance, dfs_cache::created_t& created)->void + std::get>(dfsCaches).for_each([&inputs,&dfsCaches](const instance_t& assetInstance, dfs_cache::created_t& created)->void { auto& patch = created.patch; // we already have motion, can stop searching @@ -3205,7 +3218,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult { IGPUBuffer::SCreationParams params = {}; constexpr size_t MinASBufferAlignment = 256u; - params.size = core::roundUp(sizes.accelerationStructureSize,MinASBufferAlignment); + params.size = hlsl::roundUp(sizes.accelerationStructureSize,MinASBufferAlignment); params.usage = IGPUBuffer::E_USAGE_FLAGS::EUF_ACCELERATION_STRUCTURE_STORAGE_BIT|IGPUBuffer::E_USAGE_FLAGS::EUF_SHADER_DEVICE_ADDRESS_BIT; // concurrent ownership if any const auto queueFamilies = inputs.getSharedOwnershipQueueFamilies(uniqueCopyGroupID,as,patch); @@ -3417,7 +3430,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult core::vector> immutableSamplers(asset->getImmutableSamplers().size()); { const auto& immutableSamplerRedirects = asset->getImmutableSamplerRedirect(); - auto outImmutableSamplers = immutableSamplers.data(); + [[maybe_unused]] auto outImmutableSamplers = immutableSamplers.data(); for (auto j=0u; j SReserveResult SShaderEntryMap tesselationEvaluationEntryMap; SShaderEntryMap geometryEntryMap; SShaderEntryMap fragmentEntryMap; - bool depNotFound = false; { params.layout = visitor.layout; params.renderpass = visitor.renderpass; // while there are patches possible for shaders, the only patch which can happen here is changing a stage from UNKNOWN to match the slot here - using stage_t = hlsl::ShaderStage; - using GPUShaderSpecInfo = IGPUPipelineBase::SShaderSpecInfo; + using GPUShaderSpecInfo = IGPUPipelineBase::SShaderSpecInfo; params.vertexShader = GPUShaderSpecInfo::create(visitor.getSpecInfo(hlsl::ESS_VERTEX), &vertexEntryMap); params.tesselationControlShader = GPUShaderSpecInfo::create(visitor.getSpecInfo(hlsl::ESS_TESSELLATION_CONTROL), &tesselationControlEntryMap); params.tesselationEvaluationShader = GPUShaderSpecInfo::create(visitor.getSpecInfo(hlsl::ESS_TESSELLATION_EVALUATION), &tesselationEvaluationEntryMap); @@ -3638,7 +3649,14 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult // no derivatives, special flags, etc. IGPURayTracingPipeline::SCreationParams params = {}; using SShaderEntryMap = IGPUPipelineBase::SShaderEntryMap; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-local-typedef" +#endif using stage_t = hlsl::ShaderStage; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif using GPUShaderSpecInfo = IGPUPipelineBase::SShaderSpecInfo; params.layout = visitor.layout; @@ -4536,7 +4554,6 @@ ISemaphore::future_t 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(); @@ -4799,7 +4816,7 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul // { // If format cannot be stored directly, alias the texel block to a compatible `uint_t` format and we'll encode manually. - auto storeFormat = format; + [[maybe_unused]] auto storeFormat = format; if (!physDev->getImageFormatUsages(image->getTiling())[format].storageImage) switch (image->getTexelBlockInfo().getBlockByteSize()) { @@ -5318,7 +5335,7 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul } allocSizes.push_back(size); alignments.push_back(alignment); - const auto tmp = asToBuild.second.scratchSize; + //const auto tmp = asToBuild.second.scratchSize; //logger.log("%p Triangle Data Size %d Align %d Scratch Size %d",system::ILogger::ELL_DEBUG,canonical.get(),size,alignment,tmp); } } @@ -5371,7 +5388,6 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul { uint32_t operator()(void* dst, const size_t offsetInRange, const uint32_t blockSize) override { - using blas_ref_t = IGPUBottomLevelAccelerationStructure::device_op_ref_t; assert(offsetInRange%16==0); uint32_t bytesWritten = 0; @@ -5641,7 +5657,7 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul // This is a Spec limit/rpomise we don't even expose it constexpr size_t MinASBufferAlignment = 256u; using usage_f = IGPUBuffer::E_USAGE_FLAGS; - IGPUBuffer::SCreationParams creationParams = { {.size=core::roundUp(sizes[i],MinASBufferAlignment),.usage=usage_f::EUF_ACCELERATION_STRUCTURE_STORAGE_BIT|usage_f::EUF_SHADER_DEVICE_ADDRESS_BIT},{}}; + IGPUBuffer::SCreationParams creationParams = { {.size=hlsl::roundUp(sizes[i],MinASBufferAlignment),.usage=usage_f::EUF_ACCELERATION_STRUCTURE_STORAGE_BIT|usage_f::EUF_SHADER_DEVICE_ADDRESS_BIT},{}}; // same sharing setup as the previous AS buffer creationParams.queueFamilyIndexCount = oldBuffer->getCachedCreationParams().queueFamilyIndexCount; creationParams.queueFamilyIndices = oldBuffer->getCachedCreationParams().queueFamilyIndices; @@ -5651,7 +5667,6 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul logFail("create Buffer backing the Compacted Acceleration Structure",as); continue; } - auto bufReqs = buf->getMemoryReqs(); backingBuffers[i].value = std::move(buf); // allocate new memory - definitely don't want to be raytracing from across the PCIE slot if (!deferredAllocator.request(backingBuffers.data()+i,physDev->getDeviceLocalMemoryTypeBits())) @@ -6150,3 +6165,7 @@ ISemaphore::future_t CAssetConverter::convert_impl(SReserveResul #endif } } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/src/nbl/video/utilities/CComputeBlit.cpp b/src/nbl/video/utilities/CComputeBlit.cpp index 924c337cbe..b577d4d17b 100644 --- a/src/nbl/video/utilities/CComputeBlit.cpp +++ b/src/nbl/video/utilities/CComputeBlit.cpp @@ -1,6 +1,13 @@ #include "nbl/video/utilities/CComputeBlit.h" #include "nbl/builtin/hlsl/binding_info.hlsl" #include "nbl/builtin/hlsl/tgmath.hlsl" +#include "nbl/builtin/hlsl/math/intutil.hlsl" + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-designated-field-initializers" +#endif using namespace nbl::core; using namespace nbl::hlsl; @@ -31,8 +38,8 @@ auto CComputeBlit::createAndCachePipelines(const SPipelinesCreateInfo& info) -> const auto& limits = m_device->getPhysicalDevice()->getLimits(); retval.workgroupSize = 0x1u< CComputeBlit::createNormalizationSpeci " blit.execute(inCSA, outImgA, hA, ppA, sA, workGroupID, globalInvocationID, localInvocationIndex);\n" "}\n"; } +#endif + +#ifdef __clang__ +#pragma clang diagnostic pop #endif \ No newline at end of file diff --git a/src/nbl/video/utilities/ImageRegionIterator.cpp b/src/nbl/video/utilities/ImageRegionIterator.cpp index d9f3faaa1b..6b25743774 100644 --- a/src/nbl/video/utilities/ImageRegionIterator.cpp +++ b/src/nbl/video/utilities/ImageRegionIterator.cpp @@ -1,5 +1,7 @@ #include "nbl/video/utilities/ImageRegionIterator.h" +#include "nbl/builtin/hlsl/math/intutil.hlsl" + namespace nbl::video { @@ -12,6 +14,7 @@ ImageRegionIterator::ImageRegionIterator( size_t optimalRowPitchAlignment ) : regions(copyRegions) + , optimalRowPitchAlignment(optimalRowPitchAlignment) , minImageTransferGranularity(queueFamilyProps.minImageTransferGranularity) , srcImageFormat(srcImageFormat) , dstImageFormat(dstImage->getCreationParameters().format) @@ -22,7 +25,6 @@ ImageRegionIterator::ImageRegionIterator( , currentSliceInLayer(0u) , currentLayerInRegion(0u) , currentRegion(0u) - , optimalRowPitchAlignment(optimalRowPitchAlignment) { if(srcImageFormat == asset::EF_UNKNOWN) srcImageFormat = dstImageFormat; @@ -124,7 +126,7 @@ size_t ImageRegionIterator::getMemoryNeededForRemainingRegions() const // We want to first roundUp to bufferOffsetAlignment everytime we increment, because the incrementation here correspond a single copy command that needs it's bufferOffset to be aligned correctly (assuming enough memory). auto incrementMemoryNeeded = [&](const uint32_t size) { - memoryNeededForRemainingRegions = core::roundUp(memoryNeededForRemainingRegions, bufferOffsetAlignment); + memoryNeededForRemainingRegions = hlsl::roundUp(memoryNeededForRemainingRegions, bufferOffsetAlignment); memoryNeededForRemainingRegions += size; }; @@ -275,7 +277,7 @@ bool ImageRegionIterator::advanceAndCopyToStagingBuffer(asset::IImage::SBufferCo auto addToCurrentUploadBufferOffset = [&](uint32_t size) -> 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)