Only validate texture layer if texture is non-zero.

From the ES3.0 spec:
The error INVALID_VALUE is generated if texture is non-zero and layer
is negative.

BUG=765919

Change-Id: I0ac9bd0335ab4d55701d6def0158297d5add993e
Reviewed-on: https://chromium-review.googlesource.com/723741
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index 16cb742..4f9c1e1 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -1103,12 +1103,6 @@
         return false;
     }
 
-    if (layer < 0)
-    {
-        context->handleError(InvalidValue());
-        return false;
-    }
-
     if (!ValidateFramebufferTextureBase(context, target, attachment, texture, level))
     {
         return false;
@@ -1117,6 +1111,12 @@
     const gl::Caps &caps = context->getCaps();
     if (texture != 0)
     {
+        if (layer < 0)
+        {
+            context->handleError(InvalidValue());
+            return false;
+        }
+
         gl::Texture *tex = context->getTexture(texture);
         ASSERT(tex);