Skip to content

Commit f3961db

Browse files
committed
resolve reviews
Signed-off-by: Ali Cheraghi <alichraghi@proton.me>
1 parent 3445f61 commit f3961db

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

include/nbl/asset/utils/IShaderCompiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
368368
// Used for late initialization while looking up a cache, so as not to always initialize an entry even if caching was not requested
369369
inline SEntry& operator=(SEntry&& other) = default;
370370

371-
void setContent(const asset::ICPUBuffer* uncompressedSpirvBuffer, dependency_container_t&& dependencies);
371+
bool setContent(const asset::ICPUBuffer* uncompressedSpirvBuffer, dependency_container_t&& dependencies);
372372

373373
core::smart_refctd_ptr<ICPUShader> decompressShader() const;
374374

src/nbl/asset/utils/IShaderCompiler.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ inline core::smart_refctd_ptr<ICPUShader> nbl::asset::IShaderCompiler::compileTo
5555

5656
if (options.writeCache)
5757
{
58-
entry.setContent(retVal->getContent(), std::move(dependencies));
59-
options.writeCache->insert(std::move(entry));
58+
if (entry.setContent(retVal->getContent(), std::move(dependencies)))
59+
options.writeCache->insert(std::move(entry));
6060
}
6161
return retVal;
6262
}
@@ -398,7 +398,7 @@ core::smart_refctd_ptr<IShaderCompiler::CCache> IShaderCompiler::CCache::deseria
398398
static void* SzAlloc(ISzAllocPtr p, size_t size) { p = p; return _NBL_ALIGNED_MALLOC(size, _NBL_SIMD_ALIGNMENT); }
399399
static void SzFree(ISzAllocPtr p, void* address) { p = p; _NBL_ALIGNED_FREE(address); }
400400

401-
void nbl::asset::IShaderCompiler::CCache::SEntry::setContent(const asset::ICPUBuffer* uncompressedSpirvBuffer, dependency_container_t&& dependencies)
401+
bool nbl::asset::IShaderCompiler::CCache::SEntry::setContent(const asset::ICPUBuffer* uncompressedSpirvBuffer, dependency_container_t&& dependencies)
402402
{
403403
dependencies = std::move(dependencies);
404404
uncompressedContentHash = uncompressedSpirvBuffer->getContentHash();
@@ -421,11 +421,12 @@ void nbl::asset::IShaderCompiler::CCache::SEntry::setContent(const asset::ICPUBu
421421
&props, compressedSpirv.data(), &propsSize, props.writeEndMark,
422422
nullptr, &alloc, &alloc);
423423

424-
assert(propsSize == LZMA_PROPS_SIZE);
425-
assert(res == SZ_OK);
424+
if (res != SZ_OK || propsSize != LZMA_PROPS_SIZE) return false;
426425

427426
spirv = core::make_smart_refctd_ptr<ICPUBuffer>(propsSize + destLen);
428427
memcpy(spirv->getPointer(), compressedSpirv.data(), spirv->getSize());
428+
429+
return true;
429430
}
430431

431432
core::smart_refctd_ptr<ICPUShader> nbl::asset::IShaderCompiler::CCache::SEntry::decompressShader() const

0 commit comments

Comments
 (0)