Commit 7ff605a5 by Cody Northrop Committed by Commit Bot

Capture/Replay: Fix compressed texture level caching

Before this commit, the following sequence would cause an assert: glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_8x8, ...); glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGBA_ASTC_8x8, ...); This is due to code we added that clears the compressed texture cache when it detects we already have an entry for the texture level. This is allowed in GL, to respecify a texture level by simply calling glCompressedTexImage on it again. The problem is we would clear the entire texture from the cache, not just the level being respecified. Test: Recapture Asphalt 8 Bug: angleproject:5678 Change-Id: I473d6ea1cb8823bfec680ddd78c3457b93ecc431 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2716639Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
parent a833f200
......@@ -4949,30 +4949,32 @@ std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture
EntryPoint entryPoint)
{
auto foundTextureLevels = mCachedTextureLevelData.find(texture->id());
if (foundTextureLevels == mCachedTextureLevelData.end() ||
entryPoint == EntryPoint::GLCompressedTexImage2D ||
entryPoint == EntryPoint::GLCompressedTexImage3D)
if (foundTextureLevels == mCachedTextureLevelData.end())
{
// Delete the cached entry (if it exists) in case the caller is respecifying the texture.
mCachedTextureLevelData.erase(texture->id());
// Initialize the texture ID data.
auto emplaceResult = mCachedTextureLevelData.emplace(texture->id(), TextureLevels());
ASSERT(emplaceResult.second);
foundTextureLevels = emplaceResult.first;
}
else
{
ASSERT(entryPoint == EntryPoint::GLCompressedTexSubImage2D ||
entryPoint == EntryPoint::GLCompressedTexSubImage3D);
}
TextureLevels &foundLevels = foundTextureLevels->second;
TextureLevels::iterator foundLevel = foundLevels.find(level);
if (foundLevel != foundLevels.end())
{
// If we have a cache for this level, return it now
return foundLevel->second;
if (entryPoint == EntryPoint::GLCompressedTexImage2D ||
entryPoint == EntryPoint::GLCompressedTexImage3D)
{
// Delete the cached entry in case the caller is respecifying the level.
foundLevels.erase(level);
}
else
{
ASSERT(entryPoint == EntryPoint::GLCompressedTexSubImage2D ||
entryPoint == EntryPoint::GLCompressedTexSubImage3D);
// If we have a cache for this level, return it now
return foundLevel->second;
}
}
// Otherwise, create an appropriately sized cache for this level
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment