From 2c5b3d64af2cce0f02b7ddcac0fd3254e55b5f92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Srbeck=C3=BD?= <dsrbecky@gmail.com>
Date: Mon, 4 Sep 2017 17:33:04 +0100
Subject: [PATCH] Add support for GL_OES_EGL_image_external_essl3

---
 Test/100samplerExternal.frag                 |  41 ++++
 Test/300samplerExternal.frag                 |  41 ++++
 Test/baseResults/100samplerExternal.frag.out | 172 ++++++++++++++++
 Test/baseResults/300samplerExternal.frag.out | 197 +++++++++++++++++++
 glslang/MachineIndependent/Initialize.cpp    |  21 +-
 glslang/MachineIndependent/ParseHelper.cpp   |  10 +
 glslang/MachineIndependent/Scan.cpp          |   4 +-
 glslang/MachineIndependent/Versions.cpp      |   2 +
 glslang/MachineIndependent/Versions.h        |   1 +
 gtests/AST.FromFile.cpp                      |   2 +
 10 files changed, 487 insertions(+), 4 deletions(-)
 create mode 100644 Test/100samplerExternal.frag
 create mode 100644 Test/300samplerExternal.frag
 create mode 100644 Test/baseResults/100samplerExternal.frag.out
 create mode 100644 Test/baseResults/300samplerExternal.frag.out

diff --git a/Test/100samplerExternal.frag b/Test/100samplerExternal.frag
new file mode 100644
index 000000000..9f6f397e0
--- /dev/null
+++ b/Test/100samplerExternal.frag
@@ -0,0 +1,41 @@
+#version 100
+
+#extension GL_OES_EGL_image_external : enable
+
+uniform samplerExternalOES sExt;
+precision mediump samplerExternalOES;
+uniform samplerExternalOES mediumExt;
+uniform highp samplerExternalOES highExt;
+
+void main()
+{
+    texture2D(sExt, vec2(0.2));
+    texture2D(mediumExt, vec2(0.2));
+    texture2D(highExt, vec2(0.2));
+    texture2DProj(sExt, vec3(0.3));
+    texture2DProj(sExt, vec4(0.3));
+
+    int lod = 0;
+    highp float bias = 0.01;
+    textureSize(sExt, lod);  // ERROR
+    texture(sExt, vec2(0.2));  // ERROR
+    texture(sExt, vec2(0.2), bias);  // ERROR
+    textureProj(sExt, vec3(0.2));  // ERROR
+    textureProj(sExt, vec3(0.2), bias);  // ERROR
+    textureProj(sExt, vec4(0.2));  // ERROR
+    textureProj(sExt, vec4(0.2), bias);  // ERROR
+    texelFetch(sExt, ivec2(4), lod);  // ERROR
+
+    texture3D(sExt, vec3(0.3));  // ERROR
+    texture2DProjLod(sExt, vec3(0.3), 0.3);  // ERROR
+    texture(sExt, vec3(0.3));  // ERROR
+    textureProjLod(sExt, vec3(0.3), 0.3);  // ERROR
+}
+
+#extension GL_OES_EGL_image_external : disable
+
+#extension GL_OES_EGL_image_external_essl3 : enable
+uniform samplerExternalOES badExt;  // ERROR
+#extension GL_OES_EGL_image_external_essl3 : disable
+
+uniform samplerExternalOES badExt;  // ERROR
diff --git a/Test/300samplerExternal.frag b/Test/300samplerExternal.frag
new file mode 100644
index 000000000..3724f8e0a
--- /dev/null
+++ b/Test/300samplerExternal.frag
@@ -0,0 +1,41 @@
+#version 300 es
+
+#extension GL_OES_EGL_image_external_essl3 : enable
+
+uniform samplerExternalOES sExt;
+precision mediump samplerExternalOES;
+uniform samplerExternalOES mediumExt;
+uniform highp samplerExternalOES highExt;
+
+void main()
+{
+    texture2D(sExt, vec2(0.2));  // ERROR
+    texture2D(mediumExt, vec2(0.2));  // ERROR
+    texture2D(highExt, vec2(0.2));  // ERROR
+    texture2DProj(sExt, vec3(0.3));  // ERROR
+    texture2DProj(sExt, vec4(0.3));  // ERROR
+
+    int lod = 0;
+    highp float bias = 0.01;
+    textureSize(sExt, lod);
+    texture(sExt, vec2(0.2));
+    texture(sExt, vec2(0.2), bias);
+    textureProj(sExt, vec3(0.2));
+    textureProj(sExt, vec3(0.2), bias);
+    textureProj(sExt, vec4(0.2));
+    textureProj(sExt, vec4(0.2), bias);
+    texelFetch(sExt, ivec2(4), lod);
+
+    texture3D(sExt, vec3(0.3));  // ERROR
+    texture2DProjLod(sExt, vec3(0.3), 0.3);  // ERROR
+    texture(sExt, vec3(0.3));  // ERROR
+    textureProjLod(sExt, vec3(0.3), 0.3);  // ERROR
+}
+
+#extension GL_OES_EGL_image_external_essl3 : disable
+
+#extension GL_OES_EGL_image_external : enable
+uniform samplerExternalOES badExt;  // ERROR
+#extension GL_OES_EGL_image_external : disable
+
+uniform samplerExternalOES badExt;  // ERROR
diff --git a/Test/baseResults/100samplerExternal.frag.out b/Test/baseResults/100samplerExternal.frag.out
new file mode 100644
index 000000000..8b689c761
--- /dev/null
+++ b/Test/baseResults/100samplerExternal.frag.out
@@ -0,0 +1,172 @@
+100samplerExternal.frag
+ERROR: 0:20: 'textureSize' : no matching overloaded function found 
+ERROR: 0:21: 'texture' : no matching overloaded function found 
+ERROR: 0:22: 'texture' : no matching overloaded function found 
+ERROR: 0:23: 'textureProj' : no matching overloaded function found 
+ERROR: 0:24: 'textureProj' : no matching overloaded function found 
+ERROR: 0:25: 'textureProj' : no matching overloaded function found 
+ERROR: 0:26: 'textureProj' : no matching overloaded function found 
+ERROR: 0:27: 'texelFetch' : no matching overloaded function found 
+ERROR: 0:29: 'texture3D' : no matching overloaded function found 
+ERROR: 0:30: 'texture2DProjLod' : no matching overloaded function found 
+ERROR: 0:31: 'texture' : no matching overloaded function found 
+ERROR: 0:32: 'textureProjLod' : no matching overloaded function found 
+ERROR: 0:38: 'samplerExternalOES' : required extension not requested: GL_OES_EGL_image_external
+ERROR: 0:41: '' :  syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
+ERROR: 14 compilation errors.  No code generated.
+
+
+Shader version: 100
+Requested GL_OES_EGL_image_external
+Requested GL_OES_EGL_image_external_essl3
+ERROR: node is still EOpNull!
+0:10  Function Definition: main( ( global void)
+0:10    Function Parameters: 
+0:12    Sequence
+0:12      texture ( global lowp 4-component vector of float)
+0:12        'sExt' ( uniform lowp samplerExternalOES)
+0:12        Constant:
+0:12          0.200000
+0:12          0.200000
+0:13      texture ( global mediump 4-component vector of float)
+0:13        'mediumExt' ( uniform mediump samplerExternalOES)
+0:13        Constant:
+0:13          0.200000
+0:13          0.200000
+0:14      texture ( global highp 4-component vector of float)
+0:14        'highExt' ( uniform highp samplerExternalOES)
+0:14        Constant:
+0:14          0.200000
+0:14          0.200000
+0:15      textureProj ( global lowp 4-component vector of float)
+0:15        'sExt' ( uniform lowp samplerExternalOES)
+0:15        Constant:
+0:15          0.300000
+0:15          0.300000
+0:15          0.300000
+0:16      textureProj ( global lowp 4-component vector of float)
+0:16        'sExt' ( uniform lowp samplerExternalOES)
+0:16        Constant:
+0:16          0.300000
+0:16          0.300000
+0:16          0.300000
+0:16          0.300000
+0:18      Sequence
+0:18        move second child to first child ( temp mediump int)
+0:18          'lod' ( temp mediump int)
+0:18          Constant:
+0:18            0 (const int)
+0:19      Sequence
+0:19        move second child to first child ( temp highp float)
+0:19          'bias' ( temp highp float)
+0:19          Constant:
+0:19            0.010000
+0:20      Constant:
+0:20        0.000000
+0:21      Constant:
+0:21        0.000000
+0:22      Constant:
+0:22        0.000000
+0:23      Constant:
+0:23        0.000000
+0:24      Constant:
+0:24        0.000000
+0:25      Constant:
+0:25        0.000000
+0:26      Constant:
+0:26        0.000000
+0:27      Constant:
+0:27        0.000000
+0:29      Constant:
+0:29        0.000000
+0:30      Constant:
+0:30        0.000000
+0:31      Constant:
+0:31        0.000000
+0:32      Constant:
+0:32        0.000000
+0:?   Linker Objects
+0:?     'sExt' ( uniform lowp samplerExternalOES)
+0:?     'mediumExt' ( uniform mediump samplerExternalOES)
+0:?     'highExt' ( uniform highp samplerExternalOES)
+0:?     'badExt' ( uniform mediump samplerExternalOES)
+
+
+Linked fragment stage:
+
+
+Shader version: 100
+Requested GL_OES_EGL_image_external
+Requested GL_OES_EGL_image_external_essl3
+ERROR: node is still EOpNull!
+0:10  Function Definition: main( ( global void)
+0:10    Function Parameters: 
+0:12    Sequence
+0:12      texture ( global lowp 4-component vector of float)
+0:12        'sExt' ( uniform lowp samplerExternalOES)
+0:12        Constant:
+0:12          0.200000
+0:12          0.200000
+0:13      texture ( global mediump 4-component vector of float)
+0:13        'mediumExt' ( uniform mediump samplerExternalOES)
+0:13        Constant:
+0:13          0.200000
+0:13          0.200000
+0:14      texture ( global highp 4-component vector of float)
+0:14        'highExt' ( uniform highp samplerExternalOES)
+0:14        Constant:
+0:14          0.200000
+0:14          0.200000
+0:15      textureProj ( global lowp 4-component vector of float)
+0:15        'sExt' ( uniform lowp samplerExternalOES)
+0:15        Constant:
+0:15          0.300000
+0:15          0.300000
+0:15          0.300000
+0:16      textureProj ( global lowp 4-component vector of float)
+0:16        'sExt' ( uniform lowp samplerExternalOES)
+0:16        Constant:
+0:16          0.300000
+0:16          0.300000
+0:16          0.300000
+0:16          0.300000
+0:18      Sequence
+0:18        move second child to first child ( temp mediump int)
+0:18          'lod' ( temp mediump int)
+0:18          Constant:
+0:18            0 (const int)
+0:19      Sequence
+0:19        move second child to first child ( temp highp float)
+0:19          'bias' ( temp highp float)
+0:19          Constant:
+0:19            0.010000
+0:20      Constant:
+0:20        0.000000
+0:21      Constant:
+0:21        0.000000
+0:22      Constant:
+0:22        0.000000
+0:23      Constant:
+0:23        0.000000
+0:24      Constant:
+0:24        0.000000
+0:25      Constant:
+0:25        0.000000
+0:26      Constant:
+0:26        0.000000
+0:27      Constant:
+0:27        0.000000
+0:29      Constant:
+0:29        0.000000
+0:30      Constant:
+0:30        0.000000
+0:31      Constant:
+0:31        0.000000
+0:32      Constant:
+0:32        0.000000
+0:?   Linker Objects
+0:?     'sExt' ( uniform lowp samplerExternalOES)
+0:?     'mediumExt' ( uniform mediump samplerExternalOES)
+0:?     'highExt' ( uniform highp samplerExternalOES)
+0:?     'badExt' ( uniform mediump samplerExternalOES)
+
diff --git a/Test/baseResults/300samplerExternal.frag.out b/Test/baseResults/300samplerExternal.frag.out
new file mode 100644
index 000000000..9074552e8
--- /dev/null
+++ b/Test/baseResults/300samplerExternal.frag.out
@@ -0,0 +1,197 @@
+300samplerExternal.frag
+ERROR: 0:12: 'texture2D' : no matching overloaded function found 
+ERROR: 0:13: 'texture2D' : no matching overloaded function found 
+ERROR: 0:14: 'texture2D' : no matching overloaded function found 
+ERROR: 0:15: 'texture2DProj' : no matching overloaded function found 
+ERROR: 0:16: 'texture2DProj' : no matching overloaded function found 
+ERROR: 0:29: 'texture3D' : no matching overloaded function found 
+ERROR: 0:30: 'texture2DProjLod' : no matching overloaded function found 
+ERROR: 0:31: 'texture' : no matching overloaded function found 
+ERROR: 0:32: 'textureProjLod' : no matching overloaded function found 
+ERROR: 0:38: 'samplerExternalOES' : required extension not requested: GL_OES_EGL_image_external_essl3
+ERROR: 0:41: '' :  syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
+ERROR: 11 compilation errors.  No code generated.
+
+
+Shader version: 300
+Requested GL_OES_EGL_image_external
+Requested GL_OES_EGL_image_external_essl3
+ERROR: node is still EOpNull!
+0:10  Function Definition: main( ( global void)
+0:10    Function Parameters: 
+0:12    Sequence
+0:12      Constant:
+0:12        0.000000
+0:13      Constant:
+0:13        0.000000
+0:14      Constant:
+0:14        0.000000
+0:15      Constant:
+0:15        0.000000
+0:16      Constant:
+0:16        0.000000
+0:18      Sequence
+0:18        move second child to first child ( temp mediump int)
+0:18          'lod' ( temp mediump int)
+0:18          Constant:
+0:18            0 (const int)
+0:19      Sequence
+0:19        move second child to first child ( temp highp float)
+0:19          'bias' ( temp highp float)
+0:19          Constant:
+0:19            0.010000
+0:20      textureSize ( global highp 2-component vector of int, operation at mediump)
+0:20        'sExt' ( uniform lowp samplerExternalOES)
+0:20        'lod' ( temp mediump int)
+0:21      texture ( global lowp 4-component vector of float)
+0:21        'sExt' ( uniform lowp samplerExternalOES)
+0:21        Constant:
+0:21          0.200000
+0:21          0.200000
+0:22      texture ( global lowp 4-component vector of float, operation at highp)
+0:22        'sExt' ( uniform lowp samplerExternalOES)
+0:22        Constant:
+0:22          0.200000
+0:22          0.200000
+0:22        'bias' ( temp highp float)
+0:23      textureProj ( global lowp 4-component vector of float)
+0:23        'sExt' ( uniform lowp samplerExternalOES)
+0:23        Constant:
+0:23          0.200000
+0:23          0.200000
+0:23          0.200000
+0:24      textureProj ( global lowp 4-component vector of float, operation at highp)
+0:24        'sExt' ( uniform lowp samplerExternalOES)
+0:24        Constant:
+0:24          0.200000
+0:24          0.200000
+0:24          0.200000
+0:24        'bias' ( temp highp float)
+0:25      textureProj ( global lowp 4-component vector of float)
+0:25        'sExt' ( uniform lowp samplerExternalOES)
+0:25        Constant:
+0:25          0.200000
+0:25          0.200000
+0:25          0.200000
+0:25          0.200000
+0:26      textureProj ( global lowp 4-component vector of float, operation at highp)
+0:26        'sExt' ( uniform lowp samplerExternalOES)
+0:26        Constant:
+0:26          0.200000
+0:26          0.200000
+0:26          0.200000
+0:26          0.200000
+0:26        'bias' ( temp highp float)
+0:27      textureFetch ( global lowp 4-component vector of float, operation at mediump)
+0:27        'sExt' ( uniform lowp samplerExternalOES)
+0:27        Constant:
+0:27          4 (const int)
+0:27          4 (const int)
+0:27        'lod' ( temp mediump int)
+0:29      Constant:
+0:29        0.000000
+0:30      Constant:
+0:30        0.000000
+0:31      Constant:
+0:31        0.000000
+0:32      Constant:
+0:32        0.000000
+0:?   Linker Objects
+0:?     'sExt' ( uniform lowp samplerExternalOES)
+0:?     'mediumExt' ( uniform mediump samplerExternalOES)
+0:?     'highExt' ( uniform highp samplerExternalOES)
+0:?     'badExt' ( uniform mediump samplerExternalOES)
+
+
+Linked fragment stage:
+
+
+Shader version: 300
+Requested GL_OES_EGL_image_external
+Requested GL_OES_EGL_image_external_essl3
+ERROR: node is still EOpNull!
+0:10  Function Definition: main( ( global void)
+0:10    Function Parameters: 
+0:12    Sequence
+0:12      Constant:
+0:12        0.000000
+0:13      Constant:
+0:13        0.000000
+0:14      Constant:
+0:14        0.000000
+0:15      Constant:
+0:15        0.000000
+0:16      Constant:
+0:16        0.000000
+0:18      Sequence
+0:18        move second child to first child ( temp mediump int)
+0:18          'lod' ( temp mediump int)
+0:18          Constant:
+0:18            0 (const int)
+0:19      Sequence
+0:19        move second child to first child ( temp highp float)
+0:19          'bias' ( temp highp float)
+0:19          Constant:
+0:19            0.010000
+0:20      textureSize ( global highp 2-component vector of int, operation at mediump)
+0:20        'sExt' ( uniform lowp samplerExternalOES)
+0:20        'lod' ( temp mediump int)
+0:21      texture ( global lowp 4-component vector of float)
+0:21        'sExt' ( uniform lowp samplerExternalOES)
+0:21        Constant:
+0:21          0.200000
+0:21          0.200000
+0:22      texture ( global lowp 4-component vector of float, operation at highp)
+0:22        'sExt' ( uniform lowp samplerExternalOES)
+0:22        Constant:
+0:22          0.200000
+0:22          0.200000
+0:22        'bias' ( temp highp float)
+0:23      textureProj ( global lowp 4-component vector of float)
+0:23        'sExt' ( uniform lowp samplerExternalOES)
+0:23        Constant:
+0:23          0.200000
+0:23          0.200000
+0:23          0.200000
+0:24      textureProj ( global lowp 4-component vector of float, operation at highp)
+0:24        'sExt' ( uniform lowp samplerExternalOES)
+0:24        Constant:
+0:24          0.200000
+0:24          0.200000
+0:24          0.200000
+0:24        'bias' ( temp highp float)
+0:25      textureProj ( global lowp 4-component vector of float)
+0:25        'sExt' ( uniform lowp samplerExternalOES)
+0:25        Constant:
+0:25          0.200000
+0:25          0.200000
+0:25          0.200000
+0:25          0.200000
+0:26      textureProj ( global lowp 4-component vector of float, operation at highp)
+0:26        'sExt' ( uniform lowp samplerExternalOES)
+0:26        Constant:
+0:26          0.200000
+0:26          0.200000
+0:26          0.200000
+0:26          0.200000
+0:26        'bias' ( temp highp float)
+0:27      textureFetch ( global lowp 4-component vector of float, operation at mediump)
+0:27        'sExt' ( uniform lowp samplerExternalOES)
+0:27        Constant:
+0:27          4 (const int)
+0:27          4 (const int)
+0:27        'lod' ( temp mediump int)
+0:29      Constant:
+0:29        0.000000
+0:30      Constant:
+0:30        0.000000
+0:31      Constant:
+0:31        0.000000
+0:32      Constant:
+0:32        0.000000
+0:?   Linker Objects
+0:?     'sExt' ( uniform lowp samplerExternalOES)
+0:?     'mediumExt' ( uniform mediump samplerExternalOES)
+0:?     'highExt' ( uniform highp samplerExternalOES)
+0:?     'badExt' ( uniform mediump samplerExternalOES)
+
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index e71ec5ef0..5b4e9c00b 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -1324,10 +1324,25 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
 
     if (profile == EEsProfile) {
         if (spvVersion.spv == 0) {
+            if (version < 300) {
+                commonBuiltins.append(
+                    "vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external
+                    "vec4 texture2DProj(samplerExternalOES, vec3);"   // GL_OES_EGL_image_external
+                    "vec4 texture2DProj(samplerExternalOES, vec4);"   // GL_OES_EGL_image_external
+                "\n");
+            } else {
+                commonBuiltins.append(
+                    "highp ivec2 textureSize(samplerExternalOES, int lod);"   // GL_OES_EGL_image_external_essl3
+                    "vec4 texture(samplerExternalOES, vec2);"                 // GL_OES_EGL_image_external_essl3
+                    "vec4 texture(samplerExternalOES, vec2, float bias);"     // GL_OES_EGL_image_external_essl3
+                    "vec4 textureProj(samplerExternalOES, vec3);"             // GL_OES_EGL_image_external_essl3
+                    "vec4 textureProj(samplerExternalOES, vec3, float bias);" // GL_OES_EGL_image_external_essl3
+                    "vec4 textureProj(samplerExternalOES, vec4);"             // GL_OES_EGL_image_external_essl3
+                    "vec4 textureProj(samplerExternalOES, vec4, float bias);" // GL_OES_EGL_image_external_essl3
+                    "vec4 texelFetch(samplerExternalOES, ivec2, int lod);"    // GL_OES_EGL_image_external_essl3
+                "\n");
+            }
             commonBuiltins.append(
-                "vec4 texture2D(samplerExternalOES, vec2 coord);"  // GL_OES_EGL_image_external, caught by keyword check
-                "vec4 texture2DProj(samplerExternalOES, vec3);"    // GL_OES_EGL_image_external, caught by keyword check
-                "vec4 texture2DProj(samplerExternalOES, vec4);"    // GL_OES_EGL_image_external, caught by keyword check
                 "vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);"      // GL_EXT_shader_texture_lod
                 "vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);"  // GL_EXT_shader_texture_lod
                 "vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);"  // GL_EXT_shader_texture_lod
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 6decfea72..e9012a72b 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -2457,6 +2457,16 @@ void TParseContext::boolCheck(const TSourceLoc& loc, const TPublicType& pType)
 
 void TParseContext::samplerCheck(const TSourceLoc& loc, const TType& type, const TString& identifier, TIntermTyped* /*initializer*/)
 {
+    // Check that the appropriate extension is enabled if external sampler is used.
+    // There are two extensions. The correct one must be used based on GLSL version.
+    if (type.getBasicType() == EbtSampler && type.getSampler().external) {
+        if (version < 300) {
+            requireExtensions(loc, 1, &E_GL_OES_EGL_image_external, "samplerExternalOES");
+        } else {
+            requireExtensions(loc, 1, &E_GL_OES_EGL_image_external_essl3, "samplerExternalOES");
+        }
+    }
+
     if (type.getQualifier().storage == EvqUniform)
         return;
 
diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp
index 25122eec1..68d1500b4 100644
--- a/glslang/MachineIndependent/Scan.cpp
+++ b/glslang/MachineIndependent/Scan.cpp
@@ -1152,7 +1152,9 @@ int TScanContext::tokenizeIdentifier()
 
     case SAMPLEREXTERNALOES:
         afterType = true;
-        if (parseContext.symbolTable.atBuiltInLevel() || parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external))
+        if (parseContext.symbolTable.atBuiltInLevel() ||
+            parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external) ||
+            parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external_essl3))
             return keyword;
         return identifierOrType();
 
diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp
index 531aa159f..d8f00618f 100644
--- a/glslang/MachineIndependent/Versions.cpp
+++ b/glslang/MachineIndependent/Versions.cpp
@@ -154,6 +154,7 @@ void TParseVersions::initializeExtensionBehavior()
     extensionBehavior[E_GL_OES_standard_derivatives]         = EBhDisable;
     extensionBehavior[E_GL_EXT_frag_depth]                   = EBhDisable;
     extensionBehavior[E_GL_OES_EGL_image_external]           = EBhDisable;
+    extensionBehavior[E_GL_OES_EGL_image_external_essl3]     = EBhDisable;
     extensionBehavior[E_GL_EXT_shader_texture_lod]           = EBhDisable;
     extensionBehavior[E_GL_EXT_shadow_samplers]              = EBhDisable;
     extensionBehavior[E_GL_ARB_texture_rectangle]            = EBhDisable;
@@ -260,6 +261,7 @@ void TParseVersions::getPreamble(std::string& preamble)
             "#define GL_OES_standard_derivatives 1\n"
             "#define GL_EXT_frag_depth 1\n"
             "#define GL_OES_EGL_image_external 1\n"
+            "#define GL_OES_EGL_image_external_essl3 1\n"
             "#define GL_EXT_shader_texture_lod 1\n"
             "#define GL_EXT_shadow_samplers 1\n"
 
diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h
index 78a9b2865..3b223540e 100644
--- a/glslang/MachineIndependent/Versions.h
+++ b/glslang/MachineIndependent/Versions.h
@@ -107,6 +107,7 @@ const char* const E_GL_OES_texture_3D                   = "GL_OES_texture_3D";
 const char* const E_GL_OES_standard_derivatives         = "GL_OES_standard_derivatives";
 const char* const E_GL_EXT_frag_depth                   = "GL_EXT_frag_depth";
 const char* const E_GL_OES_EGL_image_external           = "GL_OES_EGL_image_external";
+const char* const E_GL_OES_EGL_image_external_essl3     = "GL_OES_EGL_image_external_essl3";
 const char* const E_GL_EXT_shader_texture_lod           = "GL_EXT_shader_texture_lod";
 const char* const E_GL_EXT_shadow_samplers              = "GL_EXT_shadow_samplers";
 
diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp
index ed6a13e85..fbbf81b51 100644
--- a/gtests/AST.FromFile.cpp
+++ b/gtests/AST.FromFile.cpp
@@ -62,6 +62,7 @@ INSTANTIATE_TEST_CASE_P(
         "versionsErrors.frag",
         "versionsErrors.vert",
         "100.frag",
+        "100samplerExternal.frag",
         "120.vert",
         "120.frag",
         "130.vert",
@@ -93,6 +94,7 @@ INSTANTIATE_TEST_CASE_P(
         "300layout.frag",
         "300operations.frag",
         "300block.frag",
+        "300samplerExternal.frag",
         "310.comp",
         "310.vert",
         "310.geom",
-- 
GitLab