D3D11: Fix program binary crash with UBO bindings.
This crash could occur when saving and loading a program with UBO
bindings that was never used in a draw operation. The fix is to
ensure the D3DLinkedUniforms are properly initialized before we
save the program binary.
BUG=angleproject:1637
Change-Id: I9691e375d19dc628f34f351ae94b68bd0f2f76b8
Reviewed-on: https://chromium-review.googlesource.com/422665
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/tests/gl_tests/ProgramBinaryTest.cpp b/src/tests/gl_tests/ProgramBinaryTest.cpp
index 304dcca..bd90ceb 100644
--- a/src/tests/gl_tests/ProgramBinaryTest.cpp
+++ b/src/tests/gl_tests/ProgramBinaryTest.cpp
@@ -225,10 +225,11 @@
class ProgramBinaryES3Test : public ANGLETest
{
+ protected:
+ void testBinaryAndUBOBlockIndexes(bool drawWithProgramFirst);
};
-// Tests that saving and loading a program perserves uniform block binding info.
-TEST_P(ProgramBinaryES3Test, UniformBlockBinding)
+void ProgramBinaryES3Test::testBinaryAndUBOBlockIndexes(bool drawWithProgramFirst)
{
// We can't run the test if no program binary formats are supported.
GLint binaryFormatCount = 0;
@@ -279,9 +280,12 @@
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
- drawQuad(program.get(), "position", 0.5f);
- ASSERT_GL_NO_ERROR();
- EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);
+ if (drawWithProgramFirst)
+ {
+ drawQuad(program.get(), "position", 0.5f);
+ ASSERT_GL_NO_ERROR();
+ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);
+ }
// Read back the binary.
GLint programLength = 0;
@@ -308,6 +312,19 @@
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);
}
+// Tests that saving and loading a program perserves uniform block binding info.
+TEST_P(ProgramBinaryES3Test, UniformBlockBindingWithDraw)
+{
+ testBinaryAndUBOBlockIndexes(true);
+}
+
+// Same as above, but does not do an initial draw with the program. Covers an ANGLE crash.
+// http://anglebug.com/1637
+TEST_P(ProgramBinaryES3Test, UniformBlockBindingNoDraw)
+{
+ testBinaryAndUBOBlockIndexes(false);
+}
+
ANGLE_INSTANTIATE_TEST(ProgramBinaryES3Test, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
class ProgramBinaryTransformFeedbackTest : public ANGLETest