Skip to content

Commit 0ecb30b

Browse files
committed
hash buffer in image loaders
1 parent d5b387a commit 0ecb30b

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

src/nbl/asset/interchange/CGLILoader.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,12 @@ namespace nbl
210210

211211
image->setBufferAndRegions(std::move(texelBuffer), regions);
212212

213-
auto hash = contentHasher.finalizeSeq();
214-
image->setContentHash(hash);
213+
{
214+
auto hash = contentHasher.finalizeSeq();
215+
auto* buffer = image->getBuffer();
216+
image->setContentHash(hash);
217+
buffer->setContentHash(buffer->computeContentHash());
218+
}
215219

216220
ICPUImageView::SCreationParams imageViewInfo = {};
217221
imageViewInfo.image = std::move(image);

src/nbl/asset/interchange/CImageLoaderJPG.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,12 @@ asset::SAssetBundle CImageLoaderJPG::loadAsset(system::IFile* _file, const asset
339339
core::smart_refctd_ptr<ICPUImage> image = ICPUImage::create(std::move(imgInfo));
340340
image->setBufferAndRegions(std::move(buffer), regions);
341341

342-
auto hash = contentHasher.finalizeSeq();
343-
image->setContentHash(hash);
342+
{
343+
auto hash = contentHasher.finalizeSeq();
344+
auto* buffer = image->getBuffer();
345+
buffer->setContentHash(buffer->computeContentHash());
346+
image->setContentHash(hash);
347+
}
344348

345349
return SAssetBundle(nullptr,{image});
346350

src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,10 @@ SAssetBundle CImageLoaderOpenEXR::loadAsset(system::IFile* _file, const asset::I
386386

387387
CImageHasher contentHasher(params);
388388
contentHasher.hashSeq(0, 0, image->getBuffer()->getPointer(), image->getImageDataSizeInBytes());
389+
389390
auto contentHash = contentHasher.finalizeSeq();
391+
auto* const buffer = image->getBuffer();
392+
buffer->setContentHash(buffer->computeContentHash());
390393
image->setContentHash(contentHash);
391394

392395
meta->placeMeta(metaOffset++,image.get(),std::string(suffixOfChannels),IImageMetadata::ColorSemantic{ ECP_SRGB,EOTF_IDENTITY });

src/nbl/asset/interchange/CImageLoaderPNG.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,12 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset
340340

341341
image->setBufferAndRegions(std::move(texelBuffer), regions);
342342

343-
auto hash = image->computeContentHash();
344-
image->setContentHash(hash);
343+
{
344+
auto hash = image->computeContentHash();
345+
auto* const buffer = image->getBuffer();
346+
buffer->setContentHash(buffer->computeContentHash());
347+
image->setContentHash(hash);
348+
}
345349

346350
return SAssetBundle(nullptr,{image});
347351
}

src/nbl/asset/interchange/CImageLoaderTGA.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,12 @@ asset::SAssetBundle CImageLoaderTGA::loadAsset(system::IFile* _file, const asset
321321
if (!image)
322322
return {};
323323

324-
auto hash = image->computeContentHash();
325-
image->setContentHash(hash);
324+
{
325+
auto hash = image->computeContentHash();
326+
auto* const buffer = image->getBuffer();
327+
buffer->setContentHash(buffer->getContentHash());
328+
image->setContentHash(hash);
329+
}
326330

327331
return SAssetBundle(nullptr,{std::move(image)});
328332
}

0 commit comments

Comments
 (0)