Reviewers: Ken Russell, Zhenyao Mo, bajones, yunchao
CL:
https://codereview.chromium.org/2082483002/Message:
PTAL.
https://codereview.chromium.org/2082483002/diff/60001/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cppFile
third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
(right):
https://codereview.chromium.org/2082483002/diff/60001/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp#newcode5473third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp:5473:
if (isWebGL2OrHigher() && string[i] == '\\')
This isn't very accurate to say WebGL 2.0 here. WebGL 2.0 + GLSL ES 1.00
doesn't
support line-continuation, while WebGL 2.0 + GLSL ES 3.00 supports
line-continuation. So, it should check shader version. But no shader
version
detecting in Blink side. Here we assume ANGLE or driver will do the
final validation.
Another problem is that ANGLE may change shader version according which
GL
context is used, see GetShaderOutputLanguageForContext
(
https://cs.chromium.org/chromium/src/gpu/command_buffer/service/shader_translator.cc?l=112).
Different visions of GLSL may have different supports on
line-continuation. For
example, it's supported in GLSL ES 3.00.4, but it's not supported in
GLSL 3.30.6.
Description:
Support line-continuation character in WebGL 2.0
BUG=295792
TEST=deqp/data/gles3/shaders/preprocessor.html
CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel
Base URL:
https://chromium.googlesource.com/chromium/src.git@masterAffected files (+11, -0 lines):
M third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index 1c7cf0f6b1bd990e571bc530520c1ecd66fd4eb4..9f8d01d1b3b05d186ef42053be7af4dafa0dd8b1 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -448,6 +448,14 @@ void StripComments::process(UChar c)
break;
case InSingleLineComment:
+ // Handle line-continuation character in single line comment.
+ // Advance string to next nonspace character and eat it.
+ if (c == '\\') {
+ while (peek(temp) && WTF::isASCIISpace(temp))
+ advance();
+ advance();
+ }
+
// The newline code at the top of this function takes care
// of resetting our state when we get out of the
// single-line comment. Swallow all other characters.
@@ -5461,6 +5469,9 @@ bool WebGLRenderingContextBase::validateSize(const char* functionName, GLint x,
bool WebGLRenderingContextBase::validateString(const char* functionName, const String& string)
{
for (size_t i = 0; i < string.length(); ++i) {
+ // line-continuation character \ is supported in WebGL 2.0.
+ if (isWebGL2OrHigher() && string[i] == '\\')
+ continue;
if (!validateCharacter(string[i])) {
synthesizeGLError(GL_INVALID_VALUE, functionName, "string not ASCII");
return false;