Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Plugins/NativeEngine/Source/NativeEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ namespace Babylon
texture->Create2D(static_cast<uint16_t>(image->m_width), static_cast<uint16_t>(image->m_height), (image->m_numMips > 1), 1, Cast(image->m_format), flags);
}

for (uint8_t mip = 0; mip < image->m_numMips; ++mip)
for (uint8_t mip = 0, numMips = image->m_numMips; mip < numMips; ++mip)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this fixes the problem completely. We are still using image inside the for loop. At the minimum, the image->m_numMips usage needs to be replaced with numMips, but I'm not sure that's good enough.

Ditto for the other function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is the last loop when it needs to exit was touching image, which might be released from the other thread. Alternative is just to do bgfx::copy and not deal with bgfx::makeRef / release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss offline

{
bimg::ImageMip imageMip{};
if (bimg::imageGetRawData(*image, 0, mip, image->m_data, image->m_size, imageMip))
Expand Down Expand Up @@ -387,7 +387,7 @@ namespace Babylon
for (uint8_t side = 0; side < 6; ++side)
{
bimg::ImageContainer* image{images[side]};
for (uint8_t mip = 0; mip < image->m_numMips; ++mip)
for (uint8_t mip = 0, numMips = image->m_numMips; mip < numMips; ++mip)
{
bimg::ImageMip imageMip{};
if (bimg::imageGetRawData(*image, 0, mip, image->m_data, image->m_size, imageMip))
Expand Down
Loading