From 8a737c5d4089d7b5d6bfa9184ce6f7f1bd218601 Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Wed, 21 Jul 2021 16:38:05 -0600 Subject: [PATCH] Capture/Replay: Update unpack state in Shared MEC The shared context state MEC performed by CaptureSharedContextMidExecutionSetup() needs to include updating the pixel unpack state before capturing texture contents. Otherwise, computeRowPitch() will compute the wrong value, leading to a crash in memcpy() when capturing Pokemon GO. Bug: angleproject:6203 Change-Id: Id1b2d0b4f3bc79e615778ba513f50aabaeb4a56e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3044356 Commit-Queue: Tim Van Patten Reviewed-by: Cody Northrop Reviewed-by: Jamie Madill --- src/libANGLE/capture/FrameCapture.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libANGLE/capture/FrameCapture.cpp b/src/libANGLE/capture/FrameCapture.cpp index 9827fd6ed..03f77af2c 100644 --- a/src/libANGLE/capture/FrameCapture.cpp +++ b/src/libANGLE/capture/FrameCapture.cpp @@ -2418,6 +2418,15 @@ void CaptureSharedContextMidExecutionSetup(const gl::Context *context, } } + // Set a unpack alignment of 1. Otherwise, computeRowPitch() will compute the wrong value, + // leading to a crash in memcpy() when capturing the texture contents. + gl::PixelUnpackState ¤tUnpackState = replayState.getUnpackState(); + if (currentUnpackState.alignment != 1) + { + cap(CapturePixelStorei(replayState, true, GL_UNPACK_ALIGNMENT, 1)); + currentUnpackState.alignment = 1; + } + // Capture Texture setup and data. const gl::TextureManager &textures = apiState.getTextureManagerForCapture(); @@ -2982,7 +2991,8 @@ void CaptureMidExecutionSetup(const gl::Context *context, } } - // Set a unpack alignment of 1. + // Set a unpack alignment of 1. Otherwise, computeRowPitch() will compute the wrong value, + // leading to a crash in memcpy() when capturing the texture contents. gl::PixelUnpackState ¤tUnpackState = replayState.getUnpackState(); if (currentUnpackState.alignment != 1) {