Skip to content

Commit 62eaff7

Browse files
committed
hashing for ICPUShader
1 parent 0ecb30b commit 62eaff7

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

include/nbl/asset/utils/IShaderCompiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ class NBL_API2 IShaderCompiler : public core::IReferenceCounted
562562

563563
// terminating char
564564
*outCode = 0;
565-
565+
outBuffer->setContentHash(outBuffer->computeContentHash());
566566
return nbl::core::make_smart_refctd_ptr<ICPUShader>(std::move(outBuffer), original->getStage(), original->getContentType(), std::string(original->getFilepathHint()));
567567
}
568568
else

src/nbl/asset/interchange/CGLSLLoader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ SAssetBundle CGLSLLoader::loadAsset(system::IFile* _file, const IAssetLoader::SA
4646
}
4747

4848
auto shader = core::make_smart_refctd_ptr<ICPUShader>(reinterpret_cast<char*>(source), found->second, IShader::E_CONTENT_TYPE::ECT_GLSL, filename.string());
49+
{
50+
auto backingBuffer = shader->getContent();
51+
const_cast<ICPUBuffer*>(backingBuffer)->setContentHash(backingBuffer->computeContentHash());
52+
}
4953
_NBL_ALIGNED_FREE(source);
5054

5155
return SAssetBundle(nullptr,{ std::move(shader) });

src/nbl/asset/utils/IShaderCompiler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ core::smart_refctd_ptr<IShaderCompiler::CCache> IShaderCompiler::CCache::deseria
334334
auto code = core::make_smart_refctd_ptr<ICPUBuffer>(shaderCreationParams[i].codeByteSize);
335335
// Copy the shader bytecode into the buffer
336336
memcpy(code->getPointer(), serializedCache.data() + SHADER_BUFFER_SIZE_BYTES + shaderCreationParams[i].offset, shaderCreationParams[i].codeByteSize);
337+
code->setContentHash(code->computeContentHash());
337338
// Create the ICPUShader
338339
auto value = core::make_smart_refctd_ptr<ICPUShader>(std::move(code), shaderCreationParams[i].stage, shaderCreationParams[i].contentType, std::move(shaderCreationParams[i].filepathHint));
339340

0 commit comments

Comments
 (0)