Commit a70a6a9d by Cody Northrop Committed by Commit Bot

Capture/Replay: Fix compressed cube textures

We were only tracking one image per level of cube map textures. Instead, we need to track one per face (6). Test: MEC for Extreme Car Driving Simulator Bug: b/180419767 Bug: angleproject:5735 Change-Id: I59e6a5e83a60666a29f44d0a1e1993a1b461e8e7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2744293Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com>
parent c935ba5b
...@@ -2707,7 +2707,7 @@ void CaptureMidExecutionSetup(const gl::Context *context, ...@@ -2707,7 +2707,7 @@ void CaptureMidExecutionSetup(const gl::Context *context,
// use that rather than try to read data back that may have been converted. // use that rather than try to read data back that may have been converted.
const std::vector<uint8_t> &capturedTextureLevel = const std::vector<uint8_t> &capturedTextureLevel =
context->getShareGroup()->getFrameCaptureShared()->retrieveCachedTextureLevel( context->getShareGroup()->getFrameCaptureShared()->retrieveCachedTextureLevel(
texture->id(), index.getLevelIndex()); texture->id(), index.getTarget(), index.getLevelIndex());
// Use the shadow copy of the data to populate the call // Use the shadow copy of the data to populate the call
CaptureTextureContents(setupCalls, &replayState, texture, index, desc, CaptureTextureContents(setupCalls, &replayState, texture, index, desc,
...@@ -3572,6 +3572,20 @@ bool FindShaderProgramIDInCall(const CallCapture &call, gl::ShaderProgramID *idO ...@@ -3572,6 +3572,20 @@ bool FindShaderProgramIDInCall(const CallCapture &call, gl::ShaderProgramID *idO
return false; return false;
} }
GLint GetAdjustedTextureCacheLevel(gl::TextureTarget target, GLint level)
{
GLint adjustedLevel = level;
// If target is a cube, we need to maintain 6 images per level
if (IsCubeMapFaceTarget(target))
{
adjustedLevel *= 6;
adjustedLevel += CubeMapTextureTargetToFaceIndex(target);
}
return adjustedLevel;
}
} // namespace } // namespace
ParamCapture::ParamCapture() : type(ParamType::TGLenum), enumGroup(gl::GLenumGroup::DefaultGroup) {} ParamCapture::ParamCapture() : type(ParamType::TGLenum), enumGroup(gl::GLenumGroup::DefaultGroup) {}
...@@ -4884,14 +4898,16 @@ void FrameCaptureShared::setProgramSources(gl::ShaderProgramID id, ProgramSource ...@@ -4884,14 +4898,16 @@ void FrameCaptureShared::setProgramSources(gl::ShaderProgramID id, ProgramSource
} }
const std::vector<uint8_t> &FrameCaptureShared::retrieveCachedTextureLevel(gl::TextureID id, const std::vector<uint8_t> &FrameCaptureShared::retrieveCachedTextureLevel(gl::TextureID id,
gl::TextureTarget target,
GLint level) GLint level)
{ {
// Look up the data for the requested texture // Look up the data for the requested texture
const auto &foundTextureLevels = mCachedTextureLevelData.find(id); const auto &foundTextureLevels = mCachedTextureLevelData.find(id);
ASSERT(foundTextureLevels != mCachedTextureLevelData.end()); ASSERT(foundTextureLevels != mCachedTextureLevelData.end());
// For that texture, look up the data for the given level GLint adjustedLevel = GetAdjustedTextureCacheLevel(target, level);
const auto &foundTextureLevel = foundTextureLevels->second.find(level);
const auto &foundTextureLevel = foundTextureLevels->second.find(adjustedLevel);
ASSERT(foundTextureLevel != foundTextureLevels->second.end()); ASSERT(foundTextureLevel != foundTextureLevels->second.end());
const std::vector<uint8_t> &capturedTextureLevel = foundTextureLevel->second; const std::vector<uint8_t> &capturedTextureLevel = foundTextureLevel->second;
...@@ -4956,7 +4972,7 @@ void FrameCaptureShared::copyCachedTextureLevel(const gl::Context *context, ...@@ -4956,7 +4972,7 @@ void FrameCaptureShared::copyCachedTextureLevel(const gl::Context *context,
std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture *texture, std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture *texture,
gl::TextureTarget target, gl::TextureTarget target,
GLint level, GLint textureLevel,
EntryPoint entryPoint) EntryPoint entryPoint)
{ {
auto foundTextureLevels = mCachedTextureLevelData.find(texture->id()); auto foundTextureLevels = mCachedTextureLevelData.find(texture->id());
...@@ -4968,15 +4984,18 @@ std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture ...@@ -4968,15 +4984,18 @@ std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture
foundTextureLevels = emplaceResult.first; foundTextureLevels = emplaceResult.first;
} }
// For this texture, look up the adjusted level, which may not match 1:1 due to cubes
GLint adjustedLevel = GetAdjustedTextureCacheLevel(target, textureLevel);
TextureLevels &foundLevels = foundTextureLevels->second; TextureLevels &foundLevels = foundTextureLevels->second;
TextureLevels::iterator foundLevel = foundLevels.find(level); TextureLevels::iterator foundLevel = foundLevels.find(adjustedLevel);
if (foundLevel != foundLevels.end()) if (foundLevel != foundLevels.end())
{ {
if (entryPoint == EntryPoint::GLCompressedTexImage2D || if (entryPoint == EntryPoint::GLCompressedTexImage2D ||
entryPoint == EntryPoint::GLCompressedTexImage3D) entryPoint == EntryPoint::GLCompressedTexImage3D)
{ {
// Delete the cached entry in case the caller is respecifying the level. // Delete the cached entry in case the caller is respecifying the level.
foundLevels.erase(level); foundLevels.erase(adjustedLevel);
} }
else else
{ {
...@@ -4991,10 +5010,10 @@ std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture ...@@ -4991,10 +5010,10 @@ std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture
// Otherwise, create an appropriately sized cache for this level // Otherwise, create an appropriately sized cache for this level
// Get the format of the texture for use with the compressed block size math. // Get the format of the texture for use with the compressed block size math.
const gl::InternalFormat &format = *texture->getFormat(target, level).info; const gl::InternalFormat &format = *texture->getFormat(target, textureLevel).info;
// Divide dimensions according to block size. // Divide dimensions according to block size.
const gl::Extents &levelExtents = texture->getExtents(target, level); const gl::Extents &levelExtents = texture->getExtents(target, textureLevel);
// Calculate the size needed to store the compressed level // Calculate the size needed to store the compressed level
GLuint sizeInBytes; GLuint sizeInBytes;
...@@ -5003,7 +5022,7 @@ std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture ...@@ -5003,7 +5022,7 @@ std::vector<uint8_t> &FrameCaptureShared::getCachedTextureLevelData(gl::Texture
// Initialize texture rectangle data. Default init to zero for stability. // Initialize texture rectangle data. Default init to zero for stability.
std::vector<uint8_t> newPixelData(sizeInBytes, 0); std::vector<uint8_t> newPixelData(sizeInBytes, 0);
auto emplaceResult = foundLevels.emplace(level, std::move(newPixelData)); auto emplaceResult = foundLevels.emplace(adjustedLevel, std::move(newPixelData));
ASSERT(emplaceResult.second); ASSERT(emplaceResult.second);
// Using the level entry we just created, return the location (a byte vector) where compressed // Using the level entry we just created, return the location (a byte vector) where compressed
......
...@@ -407,7 +407,9 @@ class FrameCaptureShared final : angle::NonCopyable ...@@ -407,7 +407,9 @@ class FrameCaptureShared final : angle::NonCopyable
void setProgramSources(gl::ShaderProgramID id, ProgramSources sources); void setProgramSources(gl::ShaderProgramID id, ProgramSources sources);
// Load data from a previously stored texture level // Load data from a previously stored texture level
const std::vector<uint8_t> &retrieveCachedTextureLevel(gl::TextureID id, GLint level); const std::vector<uint8_t> &retrieveCachedTextureLevel(gl::TextureID id,
gl::TextureTarget target,
GLint level);
// Create new texture level data and copy the source into it // Create new texture level data and copy the source into it
void copyCachedTextureLevel(const gl::Context *context, void copyCachedTextureLevel(const gl::Context *context,
......
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