Skip to content

Commit fab2b2f

Browse files
committed
pull from asset-conversion-v3
1 parent ac0519c commit fab2b2f

File tree

8 files changed

+60
-44
lines changed

8 files changed

+60
-44
lines changed

3rdparty/parallel-hashmap

Submodule parallel-hashmap updated 53 files

include/nbl/asset/IPipelineLayout.h

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -89,51 +89,56 @@ class IPipelineLayout
8989
public:
9090
static inline constexpr uint32_t DESCRIPTOR_SET_COUNT = 4u;
9191

92-
const DescLayoutType* getDescriptorSetLayout(uint32_t _set) const { return m_descSetLayouts[_set].get(); }
93-
core::SRange<const SPushConstantRange> getPushConstantRanges() const
94-
{
95-
if (m_pushConstantRanges)
96-
return {m_pushConstantRanges->data(), m_pushConstantRanges->data()+m_pushConstantRanges->size()};
97-
else
98-
return {nullptr, nullptr};
99-
}
92+
std::span<const DescLayoutType* const,DESCRIPTOR_SET_COUNT> getDescriptorSetLayouts() const
93+
{
94+
return std::span<const DescLayoutType* const,DESCRIPTOR_SET_COUNT>(&m_descSetLayouts[0].get(),DESCRIPTOR_SET_COUNT);
95+
}
96+
[[deprecated]] const DescLayoutType* getDescriptorSetLayout(uint32_t _set) const { return getDescriptorSetLayouts()[_set]; }
10097

101-
bool isCompatibleForPushConstants(const IPipelineLayout<DescLayoutType>* _other) const
102-
{
103-
if (getPushConstantRanges().size() != _other->getPushConstantRanges().size())
104-
return false;
98+
core::SRange<const SPushConstantRange> getPushConstantRanges() const
99+
{
100+
if (m_pushConstantRanges)
101+
return {m_pushConstantRanges->data(), m_pushConstantRanges->data()+m_pushConstantRanges->size()};
102+
else
103+
return {nullptr, nullptr};
104+
}
105105

106-
const size_t cnt = getPushConstantRanges().size();
107-
const SPushConstantRange* lhs = getPushConstantRanges().begin();
108-
const SPushConstantRange* rhs = _other->getPushConstantRanges().begin();
109-
for (size_t i = 0ull; i < cnt; ++i)
110-
if (lhs[i] != rhs[i])
106+
bool isCompatibleForPushConstants(const IPipelineLayout<DescLayoutType>* _other) const
107+
{
108+
if (getPushConstantRanges().size() != _other->getPushConstantRanges().size())
111109
return false;
112110

113-
return true;
114-
}
111+
const size_t cnt = getPushConstantRanges().size();
112+
const SPushConstantRange* lhs = getPushConstantRanges().begin();
113+
const SPushConstantRange* rhs = _other->getPushConstantRanges().begin();
114+
for (size_t i = 0ull; i < cnt; ++i)
115+
if (lhs[i] != rhs[i])
116+
return false;
115117

116-
//! Checks if `this` and `_other` are compatible for set `_setNum`. See https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#descriptorsets-compatibility for compatiblity rules.
117-
/**
118-
@returns Max value of `_setNum` for which the two pipeline layouts are compatible or -1 if they're not compatible at all.
119-
*/
120-
int32_t isCompatibleUpToSet(const uint32_t _setNum, const IPipelineLayout<DescLayoutType>* _other) const
121-
{
122-
if (!_setNum || (_setNum >= DESCRIPTOR_SET_COUNT)) //vulkan would also care about push constant ranges compatibility here
123-
return -1;
118+
return true;
119+
}
124120

125-
uint32_t i = 0u;
126-
for (; i <=_setNum; i++)
121+
//! Checks if `this` and `_other` are compatible for set `_setNum`. See https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#descriptorsets-compatibility for compatiblity rules.
122+
/**
123+
@returns Max value of `_setNum` for which the two pipeline layouts are compatible or -1 if they're not compatible at all.
124+
*/
125+
int32_t isCompatibleUpToSet(const uint32_t _setNum, const IPipelineLayout<DescLayoutType>* _other) const
127126
{
128-
const DescLayoutType* lhs = m_descSetLayouts[i].get();
129-
const DescLayoutType* rhs = _other->getDescriptorSetLayout(i);
127+
if (!_setNum || (_setNum >= DESCRIPTOR_SET_COUNT)) //vulkan would also care about push constant ranges compatibility here
128+
return -1;
130129

131-
const bool compatible = (lhs == rhs) || (lhs && lhs->isIdenticallyDefined(rhs));
132-
if (!compatible)
133-
break;
130+
uint32_t i = 0u;
131+
for (; i <=_setNum; i++)
132+
{
133+
const DescLayoutType* lhs = m_descSetLayouts[i].get();
134+
const DescLayoutType* rhs = _other->getDescriptorSetLayout(i);
135+
136+
const bool compatible = (lhs == rhs) || (lhs && lhs->isIdenticallyDefined(rhs));
137+
if (!compatible)
138+
break;
139+
}
140+
return static_cast<int32_t>(i)-1;
134141
}
135-
return static_cast<int32_t>(i)-1;
136-
}
137142

138143
protected:
139144
IPipelineLayout(

include/nbl/asset/IPreHashed.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ class IPreHashed : public IAsset
123123
virtual void discardContent_impl() = 0;
124124

125125
private:
126-
core::blake3_hash_t m_contentHash = {};
126+
// The initial value is a hash of an "as if" of a zero-length array
127+
core::blake3_hash_t m_contentHash = static_cast<core::blake3_hash_t>(core::blake3_hasher{});
127128
};
128129
}
129130

include/nbl/asset/utils/IShaderCompiler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
442442
return found;
443443
}
444444
auto retVal = compileToSPIRV_impl(code, options, options.writeCache ? &dependencies : nullptr);
445+
// compute the SPIR-V shader content hash
446+
{
447+
auto backingBuffer = retVal->getContent();
448+
const_cast<ICPUBuffer*>(backingBuffer)->setContentHash(backingBuffer->computeContentHash());
449+
}
445450
if (options.writeCache)
446451
{
447452
entry.dependencies = std::move(dependencies);

include/nbl/core/hash/blake.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct blake3_hasher::update_impl<std::span<U,N>,Dummy>
9292
hasher.update(input.data(),input.size()*sizeof(U));
9393
else // Note ideally I'd have some check for a `trivially_serializable` trait or something
9494
for (const auto& item : input)
95-
hasher << input;
95+
hasher << item;
9696

9797
}
9898
};
@@ -116,7 +116,7 @@ struct hash<nbl::core::blake3_hash_t>
116116
{
117117
auto* as_p_uint64_t = reinterpret_cast<const size_t*>(blake3.data);
118118
size_t retval = as_p_uint64_t[0];
119-
for (auto i=1; i<BLAKE3_OUT_LEN; i++)
119+
for (auto i=1; i<BLAKE3_OUT_LEN/sizeof(size_t); i++)
120120
retval ^= as_p_uint64_t[i] + 0x9e3779b97f4a7c15ull + (retval << 6) + (retval >> 2);
121121
return retval;
122122
}

include/nbl/video/IDescriptorPool.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ class NBL_API2 IDescriptorPool : public IBackendObject
7373
return nullptr;
7474
}
7575

76-
uint32_t createDescriptorSets(uint32_t count, const IGPUDescriptorSetLayout* const* layouts, core::smart_refctd_ptr<IGPUDescriptorSet>* output);
76+
uint32_t createDescriptorSets(const std::span<const IGPUDescriptorSetLayout* const> layouts, core::smart_refctd_ptr<IGPUDescriptorSet>* output);
77+
[[deprecated]] inline uint32_t createDescriptorSets(uint32_t count, const IGPUDescriptorSetLayout* const* layouts, core::smart_refctd_ptr<IGPUDescriptorSet>* output)
78+
{
79+
return createDescriptorSets({layouts,count},output);
80+
}
7781

7882
bool reset();
7983

src/nbl/video/IDescriptorPool.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ IDescriptorPool::IDescriptorPool(core::smart_refctd_ptr<const ILogicalDevice>&&
2828
m_descriptorSetAllocator = core::IteratablePoolAddressAllocator<uint32_t>(m_descriptorSetAllocatorReservedSpace.get(), 0, 0, 1, m_creationParameters.maxSets, 1);
2929
}
3030

31-
uint32_t IDescriptorPool::createDescriptorSets(uint32_t count, const IGPUDescriptorSetLayout* const* layouts, core::smart_refctd_ptr<IGPUDescriptorSet>* output)
31+
uint32_t IDescriptorPool::createDescriptorSets(const std::span<const IGPUDescriptorSetLayout* const> layouts, core::smart_refctd_ptr<IGPUDescriptorSet>* output)
3232
{
33+
const size_t count = layouts.size();
3334
core::vector<uint32_t> reverseMap(count,count);
3435

3536
core::vector<const IGPUDescriptorSetLayout*> repackedLayouts;
@@ -73,7 +74,7 @@ uint32_t IDescriptorPool::createDescriptorSets(uint32_t count, const IGPUDescrip
7374
else
7475
{
7576
// Free the allocated offsets for all the successfully allocated descriptor sets and the offset of the descriptor sets themselves.
76-
rewindLastStorageAllocations(successCount,offsets.data(),layouts);
77+
rewindLastStorageAllocations(successCount,offsets.data(),layouts.data());
7778
std::fill_n(output,count,nullptr);
7879
successCount = 0;
7980
}

0 commit comments

Comments
 (0)