ES31: Fix the issue for relink rendering/compute program.
When link or relink fails, if we try to install the unsuccessfully linked
program (via UseProgram) and start rendering or dispatch compute, We can
not always report INVALID_OPERATION for rendering/compute pipeline.
The result depends on the previous state: Whether a valid program has been
installed in pipeline before. If a valid program has been installed, it
should be OK to use the old executable residing in the GL state to start
rendering or dispatch compute. No error should be reported.
This change also add unit tests for unsuccessfully linked/relinked program
for rendering pipeline to avoid potential error.
If a program successfully relinks when it is in use, the program might
change from a rendering program to a compute program in theory,
or vice versa.
BUG=angleproject:2266
Change-Id: I4726112af2bc74f5beef25e35d2fcaa9f31e0768
Reviewed-on: https://chromium-review.googlesource.com/784273
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/Program.cpp b/src/libANGLE/Program.cpp
index 09cb57e..4582b51 100644
--- a/src/libANGLE/Program.cpp
+++ b/src/libANGLE/Program.cpp
@@ -977,6 +977,8 @@
setUniformValuesFromBindingQualifiers();
+ // According to GLES 3.0/3.1 spec for LinkProgram and UseProgram,
+ // Only successfully linked program can replace the executables.
ASSERT(mLinked);
updateLinkedShaderStages();
@@ -999,6 +1001,8 @@
void Program::updateLinkedShaderStages()
{
+ mState.mLinkedShaderStages.reset();
+
if (mState.mAttachedVertexShader)
{
mState.mLinkedShaderStages.set(SHADER_VERTEX);
@@ -1036,7 +1040,6 @@
mState.mSamplerBindings.clear();
mState.mImageBindings.clear();
mState.mNumViews = -1;
- mState.mLinkedShaderStages.reset();
mValidated = false;