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 <timvp@google.com>
Reviewed-by: Cody Northrop <cnorthrop@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/capture/FrameCapture.cpp b/src/libANGLE/capture/FrameCapture.cpp
index 9827fd6..03f77af 100644
--- a/src/libANGLE/capture/FrameCapture.cpp
+++ b/src/libANGLE/capture/FrameCapture.cpp
@@ -2418,6 +2418,15 @@
         }
     }
 
+    // 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 &currentUnpackState = 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 @@
         }
     }
 
-    // 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 &currentUnpackState = replayState.getUnpackState();
     if (currentUnpackState.alignment != 1)
     {