TextureD3D: Mark images dirty after deleting the texture storage.

When a texture storage is deleted, it copies its mip levels back into
images and marks them clean.  Marking the images dirty before deleting the
texture storage would have no effect.

BUG=705865

Change-Id: Ib4c0fc9bea1236fc31963d1b7db814785bc54abc
Reviewed-on: https://chromium-review.googlesource.com/486107
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/MipmapTest.cpp b/src/tests/gl_tests/MipmapTest.cpp
index b1b2dab..ca4f711 100644
--- a/src/tests/gl_tests/MipmapTest.cpp
+++ b/src/tests/gl_tests/MipmapTest.cpp
@@ -1153,6 +1153,32 @@
     EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 2, getWindowHeight() / 2, GLColor::green);
 }
 
+// A native version of the WebGL2 test tex-base-level-bug.html
+TEST_P(MipmapTestES3, BaseLevelTextureBug)
+{
+    if (IsOpenGL() && IsWindows() && IsAMD())
+    {
+        std::cout << "Test skipped on Windows AMD OpenGL." << std::endl;
+        return;
+    }
+
+    glBindTexture(GL_TEXTURE_2D, mTexture);
+    glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, &GLColor::red);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 2);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    ASSERT_GL_NO_ERROR();
+
+    drawQuad(m2DProgram, "position", 0.5f);
+    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
+
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
+    ASSERT_GL_NO_ERROR();
+
+    drawQuad(m2DProgram, "position", 0.5f);
+    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
+}
+
 // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
 // Note: we run these tests against 9_3 on WARP due to hardware driver issues on Win7
 ANGLE_INSTANTIATE_TEST(MipmapTest,