Skip to content

Commit 408563b

Browse files
hocheung-chromiumAngle LUCI CQ
authored andcommitted
Fix GL_WEBGL_video_texture shader compilation on OpenGL backend
When ESSL 100 shaders using GL_WEBGL_video_texture run on the OpenGL backend (desktop GL), compilation fails with "no function with name 'texture2D'" error. Root cause: textureVideoWEBGL() was always translated to texture2D() regardless of the target GLSL version. When targeting GLSL 130+, texture2D() doesn't exist (replaced by texture()), causing the error. Bug: angleproject:466412253 Change-Id: I1480e30c863bdfaf3bfc06dc85ff22ec4e96b55d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/7252470 Reviewed-by: Shahbaz Youssefi <[email protected]> Reviewed-by: Yuxin Hu <[email protected]> Commit-Queue: Yuxin Hu <[email protected]>
1 parent eb9614e commit 408563b

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/compiler/translator/glsl/OutputESSL.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ ImmutableString TOutputESSL::translateTextureFunction(const ImmutableString &nam
4444
}
4545
else
4646
{
47-
// Default translating textureVideoWEBGL to texture2D.
48-
return ImmutableString("texture2D");
47+
// For ESSL 300+ (ES 3.0+), use "texture" instead of "texture2D" to match the
48+
// translation of samplerVideoWEBGL to sampler2D and the ESSL version's texture
49+
// function naming. ESSL 100 (ES 2.0) still uses texture2D.
50+
return (getShaderVersion() >= 300) ? ImmutableString("texture")
51+
: ImmutableString("texture2D");
4952
}
5053
}
5154

src/compiler/translator/glsl/OutputGLSL.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ ImmutableString TOutputGLSL::translateTextureFunction(const ImmutableString &nam
7979
}
8080
else
8181
{
82-
// Default translating textureVideoWEBGL to texture2D.
83-
return ImmutableString("texture2D");
82+
// For GLSL 130+, use "texture" instead of "texture2D" to match the translation
83+
// of samplerVideoWEBGL to sampler2D and the GLSL version's texture function naming.
84+
return sh::IsGLSL130OrNewer(getShaderOutput()) ? ImmutableString("texture")
85+
: ImmutableString("texture2D");
8486
}
8587
}
8688

src/compiler/translator/glsl/OutputGLSLBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class TOutputGLSLBase : public TIntermTraverser
9090
const char *mapQualifierToString(TQualifier qualifier);
9191

9292
sh::GLenum getShaderType() const { return mShaderType; }
93+
int getShaderVersion() const { return mShaderVersion; }
9394
bool isHighPrecisionSupported() const { return mHighPrecisionSupported; }
9495
const char *getIndentPrefix(int extraIndentDepth = 0);
9596

src/tests/angle_end2end_tests_expectations.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
42266349 VULKAN : MultithreadingTestES3.UnsynchronizedTextureReads2/* = SKIP
3030
377614665 VULKAN : GLSLValidationTest.StructSamplerVsComma/* = SKIP
3131
410584007 VULKAN : ImageTestES31.UseSourceTextureAsStorageImage/* = SKIP
32-
// GL_WEBGL_video_texture extension doesn't work correctly with ESSL 100 on OpenGL backend.
33-
466412253 OPENGL : GLSLValidationExtensionDirectiveTest_ES3.SamplerVideoWEBGL_ESSL100/* = SKIP
3432
// Incorrectly handled pretty much in all backends
3533
42266871 : CopyTexImageTestES3.RedefineSameLevel/* = SKIP
3634
// Fails in Android with EGL_BAD_ALLOC

0 commit comments

Comments
 (0)