Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3rdparty/nbl_spirv_cross
4 changes: 2 additions & 2 deletions include/nbl/asset/IAnimationLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>& _quat, const CQuantQuaternionCache* quantCache, const core::vectorSIMDf& _translation)
{
Expand Down Expand Up @@ -155,7 +155,7 @@ class IAnimationLibrary : public virtual core::IReferenceCounted
}

template <typename>
friend struct IAnimationLibrary;
friend class IAnimationLibrary;

// map must contain one `const char*` per bone
template<class OtherBufferType>
Expand Down
2 changes: 1 addition & 1 deletion include/nbl/asset/IAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class IAsset : virtual public core::IReferenceCounted
inline void visitDependents(std::function<bool(IAsset*)> visit)
{
assert(isMutable());
visitDependents([&](const IAsset* dependent) -> bool
static_cast<const IAsset*>(this)->visitDependents([&](const IAsset* dependent) -> bool
{
return visit(const_cast<IAsset*>(dependent));
});
Expand Down
4 changes: 2 additions & 2 deletions include/nbl/asset/IAssetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ class NBL_API2 IAssetManager : public core::IReferenceCounted
//! Constructor
explicit IAssetManager(core::smart_refctd_ptr<system::ISystem>&& system, core::smart_refctd_ptr<CCompilerSet>&& 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_hash_t>(core::blake3_hasher{}));
initializeMeshTools();
Expand Down
2 changes: 1 addition & 1 deletion include/nbl/asset/IBufferView.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IBufferView : public IDescriptor
size_t getByteSize() const { return m_size; }

protected:
IBufferView(const SBufferRange<BufferType>& underlying, E_FORMAT _format) : m_size(underlying.size), m_offset(underlying.offset), m_buffer(underlying.buffer), m_format(_format)
IBufferView(const SBufferRange<BufferType>& underlying, E_FORMAT _format) : m_offset(underlying.offset), m_size(underlying.size), m_buffer(underlying.buffer), m_format(_format)
{
if (m_size==asset::SBufferRange<BufferType>::WholeBuffer)
m_size = m_buffer->getSize()-m_offset;
Expand Down
6 changes: 3 additions & 3 deletions include/nbl/asset/ICPUAccelerationStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class ICPUBottomLevelAccelerationStructure final : public IPreHashed, public IBo
verticesB = reinterpret_cast<const uint8_t*>(triangles.vertexData[1].buffer->getPointer())+triangles.vertexData[1].offset;
auto hashIndices = [&]<typename IndexType>() -> void
{
for (auto i=0; i<indexCount; i++)
for (uint32_t i=0; i<indexCount; i++)
{
uint32_t vertexIndex = i;
if constexpr (std::is_integral_v<IndexType>)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions include/nbl/asset/ICPUDescriptorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ class NBL_API2 ICPUDescriptorSet final : public IDescriptorSet<ICPUDescriptorSet

if (descriptorInfoArr->size() != 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);

Expand Down
6 changes: 3 additions & 3 deletions include/nbl/asset/ICPUGeometryCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NBL_API2 ICPUGeometryCollection : public IAsset, public IGeometryCollectio
return true;
}

inline core::smart_refctd_ptr<IAsset> clone(uint32_t _depth=~0u) const
inline core::smart_refctd_ptr<IAsset> clone(uint32_t _depth=~0u) const override
{
const auto nextDepth = _depth ? (_depth-1):0;
auto retval = core::smart_refctd_ptr<ICPUGeometryCollection>();
Expand All @@ -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())
{
Expand Down Expand Up @@ -87,7 +87,7 @@ class NBL_API2 ICPUGeometryCollection : public IAsset, public IGeometryCollectio
template<typename Iterator>// requires std::is_same_v<decltype(*declval<Iterator>()),decltype(ICPUBottomLevelAccelerationStructure::Triangles&)>
inline Iterator exportForBLAS(Iterator out, uint32_t* pWrittenOrdinals=nullptr) const
{
return exportForBLAS(std::forward<Iterator>(out),[](const hlsl::float32_t3x4& lhs, const hlsl::float32_t3x4& rhs)->void
return exportForBLAS(std::forward<Iterator>(out),[this, &pWrittenOrdinals](hlsl::float32_t3x4& lhs, const hlsl::float32_t3x4& rhs)->void
{
lhs = rhs;
if (pWrittenOrdinals)
Expand Down
1 change: 1 addition & 0 deletions include/nbl/asset/ICPUImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion include/nbl/asset/ICPUMorphTargets.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class NBL_API2 ICPUMorphTargets : public IAsset, public IMorphTargets<ICPUGeomet
return true;
}

inline core::smart_refctd_ptr<IAsset> clone(uint32_t _depth=~0u) const
inline core::smart_refctd_ptr<IAsset> clone(uint32_t _depth=~0u) const override
{
const auto nextDepth = _depth ? (_depth-1):0;
auto retval = core::smart_refctd_ptr<ICPUMorphTargets>();
Expand Down
1 change: 1 addition & 0 deletions include/nbl/asset/ICPUPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SShaderSpecInfo> getSpecInfos(const hlsl::ShaderStage stage)
{
if (!isMutable()) return {};
Expand Down
4 changes: 2 additions & 2 deletions include/nbl/asset/ICPUPipelineLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ICPUPipelineLayout : public IAsset, public IPipelineLayout<ICPUDescriptorS

inline bool valid() 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 (!m_descSetLayouts[i]->valid()) return false;
Expand All @@ -81,7 +81,7 @@ class ICPUPipelineLayout : public IAsset, public IPipelineLayout<ICPUDescriptorS

inline void visitDependents_impl(std::function<bool(const IAsset*)> 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;
Expand Down
10 changes: 6 additions & 4 deletions include/nbl/asset/ICPURayTracingPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ICPURayTracingPipeline final : public ICPUPipeline<IRayTracingPipeline<ICP

inline std::span<const SShaderSpecInfo> getSpecInfos(const hlsl::ShaderStage stage) const override
{
switch (stage)
switch (stage)
{
case hlsl::ShaderStage::ESS_RAYGEN:
return { &m_raygen, 1 };
Expand All @@ -50,7 +50,8 @@ class ICPURayTracingPipeline final : public ICPUPipeline<IRayTracingPipeline<ICP
return m_hitGroups.intersections;
case hlsl::ShaderStage::ESS_CALLABLE:
return m_callables;

default:
break;
}
return {};
}
Expand All @@ -63,7 +64,7 @@ class ICPURayTracingPipeline final : public ICPUPipeline<IRayTracingPipeline<ICP
inline core::vector<SShaderSpecInfo>* 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:
Expand All @@ -76,7 +77,8 @@ class ICPURayTracingPipeline final : public ICPUPipeline<IRayTracingPipeline<ICP
return &m_hitGroups.intersections;
case hlsl::ShaderStage::ESS_CALLABLE:
return &m_callables;

default:
break;
}
return nullptr;
}
Expand Down
6 changes: 3 additions & 3 deletions include/nbl/asset/ICPUScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ class ICPUScene final : public IAsset, public IScene
auto materialTableOffsetIt = m_instances.materials.begin();
for (const auto& targets : m_instances.morphTargets)
{
const auto materialTableOffset = *(materialTableOffsetIt++);
[[maybe_unused]] const auto materialTableOffset = *(materialTableOffsetIt++);
// TODO: check if `materialTableOffset` can be contained in `materialTable`
if (!targets || targets->valid())
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<IAsset> clone(uint32_t _depth=~0u) const
inline core::smart_refctd_ptr<IAsset> clone(uint32_t _depth=~0u) const override
{
const auto nextDepth = _depth ? (_depth-1):0;
// TODO: copy the material_table state/contents!
Expand Down
6 changes: 3 additions & 3 deletions include/nbl/asset/IFramebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class IFramebuffer
const auto& subresourceRange = viewParams.subresourceRange;
const int32_t layerCount = static_cast<int32_t>(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<base_t::layers)
if (static_cast<uint32_t>(layerCount)<base_t::layers)
return true;
// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkFramebufferCreateInfo.html#VUID-VkFramebufferCreateInfo-renderPass-04536
if (layerCount<=viewMaskMSB)
Expand Down Expand Up @@ -204,9 +204,9 @@ class IFramebuffer
m_attachments = core::make_refctd_dynamic_array<attachments_array_t>(depthStencilCount+colorCount);
m_params.depthStencilAttachments = m_attachments->data();
m_params.colorAttachments = m_params.depthStencilAttachments+depthStencilCount;
for (auto i=0; i<depthStencilCount; i++)
for (uint32_t i=0; i<depthStencilCount; i++)
m_params.depthStencilAttachments[i] = core::smart_refctd_ptr<ImageViewType>(params.depthStencilAttachments[i]);
for (auto i=0; i<colorCount; i++)
for (uint32_t i=0; i<colorCount; i++)
m_params.colorAttachments[i] = core::smart_refctd_ptr<ImageViewType>(params.colorAttachments[i]);
}
virtual ~IFramebuffer() = default;
Expand Down
16 changes: 7 additions & 9 deletions include/nbl/asset/IGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);}
Expand Down Expand Up @@ -366,10 +366,10 @@ class IGeometry : public std::conditional_t<std::is_same_v<BufferType,ICPUBuffer
inline void encodeElement(const Index elIx, const V& v)
{
if (!composed.isFormatted())
return false;
return;
void* const out = getPointer<Index>(elIx);
if (!out)
return false;
return;
using traits = hlsl::vector_traits<V>;
using code_t = std::conditional_t<hlsl::concepts::FloatingPointVector<V>,hlsl::float64_t,std::conditional_t<hlsl::concepts::SignedIntVector<V>,int64_t,uint64_t>>;
code_t tmp[traits::Dimension];
Expand All @@ -382,9 +382,7 @@ class IGeometry : public std::conditional_t<std::is_same_v<BufferType,ICPUBuffer
tmp[i] = v[i];
}
assert(!isScaledFormat(composed.format)); // handle this by improving the decode functions, not adding workarounds here
if (encodePixels<code_t>(composed.format,out,tmp))
return true;
return false;
encodePixels<code_t>(composed.format,out,tmp);
}

//
Expand Down Expand Up @@ -417,14 +415,14 @@ class IGeometry : public std::conditional_t<std::is_same_v<BufferType,ICPUBuffer
inline void* getPointer(const Index elIx=0)
{
if (_this)
return _this->getPointer<Index,BufferType>(elIx);
return _this->template getPointer<Index,BufferType>(elIx);
return nullptr;
}
template<typename V, typename Index=uint32_t> requires hlsl::concepts::Vector<V>
inline void encodeElement(const Index elIx, const V& v)
{
if (_this)
_this->encodeElement<V,Index,BufferType>(elIx,v);
_this->template encodeElement<V,Index,BufferType>(elIx,v);
}
};
//
Expand Down Expand Up @@ -501,7 +499,7 @@ class IIndexableGeometry : public IGeometry<BufferType>
template<typename _B=BufferType> 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();
}
Expand Down
3 changes: 1 addition & 2 deletions include/nbl/asset/IGeometryCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class NBL_API2 IGeometryCollection : public virtual core::IReferenceCounted
if (jointRedirectView.getElementCount()<geometry->getJointCount())
return false;
}
else
return true;
return true;
}

inline bool hasTransform() const {return !core::isnan(transform[0][0]);}
Expand Down
7 changes: 3 additions & 4 deletions include/nbl/asset/IImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -297,7 +296,7 @@ class IImage : public virtual core::IReferenceCounted
default:
break;
}
const uint32_t round = core::roundUpToPoT<uint32_t>(maxSideLen);
const uint32_t round = hlsl::roundUpToPoT<uint32_t>(maxSideLen);
return hlsl::findLSB(round);
}
inline static uint32_t calculateFullMipPyramidLevelCount(const VkExtent3D& extent, E_TYPE type)
Expand Down Expand Up @@ -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<asset::E_FORMAT>(fmt);
Expand Down Expand Up @@ -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<uint32_t>(subresource.aspectMask.value) == 1u)
if (!(hlsl::bitCount<uint32_t>(subresource.aspectMask.value) == 1u))
return false;
if (subresource.mipLevel >= m_creationParams.mipLevels)
return false;
Expand Down
2 changes: 1 addition & 1 deletion include/nbl/asset/IPipelineLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Loading