Commit 26e02593 by Tim Van Patten Committed by Commit Bot

Capture/Replay: Erase texture from mCachedTextureLevelData

When the caller issues a glCompressedTexImage call, we need to delete the cached texture data, since the texture size/data are being respecified and the old data is now stale. This fixes MEC for "Klondike Adventures". Bug: angleproject:5549 Change-Id: Ie788e2bf39f7a29ec6bc55f95d6f570f1d22d659 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2633071 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent f5d56799
...@@ -3822,8 +3822,8 @@ void FrameCapture::captureCompressedTextureData(const gl::Context *context, cons ...@@ -3822,8 +3822,8 @@ void FrameCapture::captureCompressedTextureData(const gl::Context *context, cons
// Record the data, indexed by textureID and level // Record the data, indexed by textureID and level
GLint level = call.params.getParam("level", ParamType::TGLint, 1).value.GLintVal; GLint level = call.params.getParam("level", ParamType::TGLint, 1).value.GLintVal;
std::vector<uint8_t> &levelData = std::vector<uint8_t> &levelData =
context->getShareGroup()->getFrameCaptureShared()->getTextureLevelCacheLocation( context->getShareGroup()->getFrameCaptureShared()->getCachedTextureLevelData(
texture, targetPacked, level); texture, targetPacked, level, call.entryPoint);
// Unpack the various pixel rectangle parameters. // Unpack the various pixel rectangle parameters.
ASSERT(widthParamOffset != -1); ASSERT(widthParamOffset != -1);
...@@ -3901,6 +3901,7 @@ void FrameCapture::captureCompressedTextureData(const gl::Context *context, cons ...@@ -3901,6 +3901,7 @@ void FrameCapture::captureCompressedTextureData(const gl::Context *context, cons
GLint y = yindex + yoffset; GLint y = yindex + yoffset;
GLint pixelOffset = zindex * pixelDepthPitch + yindex * pixelRowPitch; GLint pixelOffset = zindex * pixelDepthPitch + yindex * pixelRowPitch;
GLint levelOffset = z * levelDepthPitch + y * levelRowPitch + xoffset * pixelBytes; GLint levelOffset = z * levelDepthPitch + y * levelRowPitch + xoffset * pixelBytes;
ASSERT(static_cast<size_t>(levelOffset + pixelRowPitch) <= levelData.size());
memcpy(&levelData[levelOffset], &pixelData[pixelOffset], pixelRowPitch); memcpy(&levelData[levelOffset], &pixelData[pixelOffset], pixelRowPitch);
} }
} }
...@@ -4721,18 +4722,29 @@ const std::vector<uint8_t> &FrameCaptureShared::retrieveCachedTextureLevel(gl::T ...@@ -4721,18 +4722,29 @@ const std::vector<uint8_t> &FrameCaptureShared::retrieveCachedTextureLevel(gl::T
return capturedTextureLevel; return capturedTextureLevel;
} }
std::vector<uint8_t> &FrameCaptureShared::getTextureLevelCacheLocation(gl::Texture *texture, std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture *texture,
gl::TextureTarget target, gl::TextureTarget target,
GLint level) GLint level,
EntryPoint entryPoint)
{ {
auto foundTextureLevels = mCachedTextureLevelData.find(texture->id()); auto foundTextureLevels = mCachedTextureLevelData.find(texture->id());
if (foundTextureLevels == mCachedTextureLevelData.end()) if (foundTextureLevels == mCachedTextureLevelData.end() ||
entryPoint == EntryPoint::GLCompressedTexImage2D ||
entryPoint == EntryPoint::GLCompressedTexImage3D)
{ {
// If we haven't cached this texture, initialize the texture ID data. // 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()); auto emplaceResult = mCachedTextureLevelData.emplace(texture->id(), TextureLevels());
ASSERT(emplaceResult.second); ASSERT(emplaceResult.second);
foundTextureLevels = emplaceResult.first; foundTextureLevels = emplaceResult.first;
} }
else
{
ASSERT(entryPoint == EntryPoint::GLCompressedTexSubImage2D ||
entryPoint == EntryPoint::GLCompressedTexSubImage3D);
}
TextureLevels &foundLevels = foundTextureLevels->second; TextureLevels &foundLevels = foundTextureLevels->second;
TextureLevels::iterator foundLevel = foundLevels.find(level); TextureLevels::iterator foundLevel = foundLevels.find(level);
......
...@@ -403,9 +403,10 @@ class FrameCaptureShared final : angle::NonCopyable ...@@ -403,9 +403,10 @@ class FrameCaptureShared final : angle::NonCopyable
const std::vector<uint8_t> &retrieveCachedTextureLevel(gl::TextureID id, GLint level); const std::vector<uint8_t> &retrieveCachedTextureLevel(gl::TextureID id, GLint level);
// Create the location that should be used to cache texture level data // Create the location that should be used to cache texture level data
std::vector<uint8_t> &getTextureLevelCacheLocation(gl::Texture *texture, std::vector<uint8_t> &getCachedTextureLevelData(gl::Texture *texture,
gl::TextureTarget target, gl::TextureTarget target,
GLint level); GLint level,
EntryPoint entryPoint);
// Remove any cached texture levels on deletion // Remove any cached texture levels on deletion
void deleteCachedTextureLevelData(gl::TextureID id); void deleteCachedTextureLevelData(gl::TextureID id);
......
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