Skip to content

Commit 0c2625f

Browse files
authored
Merge pull request #538 from CesiumGS/shared-image-crash
Fix shared image crash
2 parents 2a1ccb9 + 4281d8e commit 0c2625f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## ? - ?
4+
5+
##### Fixes :wrench:
6+
7+
- Fixed a bug that could cause a crash or incorrect textures when multiple `Cesium3DTileset` tiles referenced the same image by URL.
8+
39
## v1.14.0 - 2024-12-02
410

511
##### Additions :tada:

native~/Runtime/src/UnityPrepareRendererResources.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ void generateMipMaps(
268268
const Sampler* pSampler =
269269
Model::getSafe(&pModel->samplers, pTexture->sampler);
270270
if (pImage && pSampler) {
271+
// We currently do not support shared resources, so if this image is
272+
// associated with a depot, unshare it. This is necessary to avoid a
273+
// race condition where multiple threads attempt to generate mipmaps for
274+
// the same shared image simultaneously.
275+
if (pImage->pAsset && pImage->pAsset->getDepot()) {
276+
// Copy the asset.
277+
pImage->pAsset.emplace(*pImage->pAsset);
278+
}
279+
271280
switch (pSampler->minFilter.value_or(
272281
CesiumGltf::Sampler::MinFilter::LINEAR_MIPMAP_LINEAR)) {
273282
case CesiumGltf::Sampler::MinFilter::LINEAR_MIPMAP_LINEAR:

0 commit comments

Comments
 (0)