D3D11: Use blit SRV format for blits

blitSRVFormat stores the format that is used with ANGLE's internal
blit shaders. By default, it is the same as the normal SRV format.
For integer textures with a red channel, the RTV format is used
instead. This makes it possible to change the storage format and the
SRV format for the integer textures without affecting the blit format.

The blitSRVFormat is used when doing blits in Blit11::copyTexture().

An exception is made for depth/stencil renderbuffer blit - in these cases
it is okay to assume that the regular SRV format works for blitting.

In the future the regular SRV format for integer textures will be changed
to be different from their blit SRV format.

TEST=angle_end2end_tests
     dEQP-GLES3.functional.fbo.blit.* (no regression)
     dEQP-GLES3.functional.texture.swizzle.* (no regression)
BUG=angleproject:1244

Change-Id: Ie0e790e58ec054b64ef5983a09dbfc7754f269ca
Reviewed-on: https://chromium-review.googlesource.com/327104
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/tests/gl_tests/SwizzleTest.cpp b/src/tests/gl_tests/SwizzleTest.cpp
index bc5afb7..946dae0 100644
--- a/src/tests/gl_tests/SwizzleTest.cpp
+++ b/src/tests/gl_tests/SwizzleTest.cpp
@@ -85,12 +85,10 @@
         );
 
         mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
-        if (mProgram == 0)
-        {
-            FAIL() << "shader compilation failed.";
-        }
+        ASSERT_NE(0u, mProgram);
 
         mTextureUniformLocation = glGetUniformLocation(mProgram, "tex");
+        ASSERT_NE(-1, mTextureUniformLocation);
 
         glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
         ASSERT_GL_NO_ERROR();
@@ -202,6 +200,54 @@
     std::vector<swizzlePermutation> mPermutations;
 };
 
+class SwizzleIntegerTest : public SwizzleTest
+{
+  protected:
+    void SetUp() override
+    {
+        ANGLETest::SetUp();
+
+        const std::string vertexShaderSource =
+            "#version 300 es\n"
+            "precision highp float;\n"
+            "in vec4 position;\n"
+            "out vec2 texcoord;\n"
+            "\n"
+            "void main()\n"
+            "{\n"
+            "    gl_Position = position;\n"
+            "    texcoord = (position.xy * 0.5) + 0.5;\n"
+            "}\n";
+
+        const std::string fragmentShaderSource =
+            "#version 300 es\n"
+            "precision highp float;\n"
+            "precision highp usampler2D;\n"
+            "uniform usampler2D tex;\n"
+            "in vec2 texcoord;\n"
+            "out vec4 my_FragColor;\n"
+            "\n"
+            "void main()\n"
+            "{\n"
+            "    uvec4 s = texture(tex, texcoord);\n"
+            "    if (s[0] == 1u) s[0] = 255u;\n"
+            "    if (s[1] == 1u) s[1] = 255u;\n"
+            "    if (s[2] == 1u) s[2] = 255u;\n"
+            "    if (s[3] == 1u) s[3] = 255u;\n"
+            "    my_FragColor = vec4(s) / 255.0;\n"
+            "}\n";
+
+        mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
+        ASSERT_NE(0u, mProgram);
+
+        mTextureUniformLocation = glGetUniformLocation(mProgram, "tex");
+        ASSERT_NE(-1, mTextureUniformLocation);
+
+        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+        ASSERT_GL_NO_ERROR();
+    }
+};
+
 TEST_P(SwizzleTest, RGBA8_2D)
 {
     GLubyte data[] = { 1, 64, 128, 200 };
@@ -346,7 +392,19 @@
     runTest2D();
 }
 
+TEST_P(SwizzleIntegerTest, RGB8UI_2D)
+{
+    GLubyte data[] = {77, 66, 55};
+    init2DTexture(GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, data);
+    runTest2D();
+}
+
 // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
 ANGLE_INSTANTIATE_TEST(SwizzleTest, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGL(3, 3), ES3_OPENGLES());
+ANGLE_INSTANTIATE_TEST(SwizzleIntegerTest,
+                       ES3_D3D11(),
+                       ES3_OPENGL(),
+                       ES3_OPENGL(3, 3),
+                       ES3_OPENGLES());
 
 } // namespace