зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1725069 - Allow GLSL-invalid chars in shaderSource. r=gfx-reviewers,kvark
Convert u16->u8 on client. Crush to GLSL-charset and replace non-GLSL chars with boring-but-still-invalid '$'. Differential Revision: https://phabricator.services.mozilla.com/D125756
This commit is contained in:
Родитель
72152613c6
Коммит
cf16621f3a
|
@ -6020,18 +6020,8 @@ void ClientWebGLContext::ShaderSource(WebGLShaderJS& shader,
|
|||
if (IsContextLost()) return;
|
||||
if (!shader.ValidateUsable(*this, "shader")) return;
|
||||
|
||||
auto source = ToString(NS_ConvertUTF16toUTF8(sourceU16));
|
||||
const auto cleanSource = CommentsToSpaces(source);
|
||||
|
||||
const auto badChar = CheckGLSLPreprocString(mIsWebGL2, cleanSource);
|
||||
if (badChar) {
|
||||
EnqueueError(LOCAL_GL_INVALID_VALUE,
|
||||
"`source` contains illegal character 0x%x.", *badChar);
|
||||
return;
|
||||
}
|
||||
|
||||
shader.mSource = std::move(source);
|
||||
Run<RPROC(ShaderSource)>(shader.mId, cleanSource);
|
||||
shader.mSource = ToString(NS_ConvertUTF16toUTF8(sourceU16));
|
||||
Run<RPROC(ShaderSource)>(shader.mId, shader.mSource);
|
||||
}
|
||||
|
||||
// -
|
||||
|
|
|
@ -80,12 +80,8 @@ WebGLShader::~WebGLShader() {
|
|||
mContext->gl->fDeleteShader(mGLName);
|
||||
}
|
||||
|
||||
void WebGLShader::ShaderSource(const std::string& cleanSource) {
|
||||
const auto badChar =
|
||||
CheckGLSLPreprocString(mContext->IsWebGL2(), cleanSource);
|
||||
MOZ_ASSERT(!badChar);
|
||||
if (badChar) return;
|
||||
mSource = cleanSource;
|
||||
void WebGLShader::ShaderSource(const std::string& u8) {
|
||||
mSource = CrushGlslToAscii(u8);
|
||||
}
|
||||
|
||||
void WebGLShader::CompileShader() {
|
||||
|
|
|
@ -87,7 +87,7 @@ std::string CommentsToSpaces(const std::string& src) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool IsValidGLSLChar(const char c) {
|
||||
static constexpr bool IsValidGLSLChar(const char c) {
|
||||
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') ||
|
||||
('0' <= c && c <= '9')) {
|
||||
return true;
|
||||
|
@ -132,18 +132,30 @@ static bool IsValidGLSLChar(const char c) {
|
|||
}
|
||||
}
|
||||
|
||||
static constexpr bool IsValidForPreprocOrGlsl(const char c) {
|
||||
switch (c) {
|
||||
case '#':
|
||||
case '\\':
|
||||
return true;
|
||||
|
||||
default:
|
||||
return IsValidGLSLChar(c);
|
||||
}
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
Maybe<char> CheckGLSLPreprocString(const bool webgl2,
|
||||
const std::string& string) {
|
||||
for (const auto c : string) {
|
||||
if (IsValidGLSLChar(c)) continue;
|
||||
if (c == '#') continue;
|
||||
if (c == '\\' && webgl2) continue;
|
||||
static constexpr char INVALID_GLSL_CHAR = '$';
|
||||
|
||||
return Some(c);
|
||||
std::string CrushGlslToAscii(const std::string& u8) {
|
||||
static_assert(!IsValidForPreprocOrGlsl(INVALID_GLSL_CHAR));
|
||||
auto ascii = u8;
|
||||
for (auto& c : ascii) {
|
||||
if (MOZ_UNLIKELY(!IsValidForPreprocOrGlsl(c))) {
|
||||
c = INVALID_GLSL_CHAR;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
return ascii;
|
||||
}
|
||||
|
||||
Maybe<webgl::ErrorInfo> CheckGLSLVariableName(const bool webgl2,
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
namespace mozilla {
|
||||
|
||||
std::string CommentsToSpaces(const std::string& src);
|
||||
Maybe<char> CheckGLSLPreprocString(bool webgl2, const std::string& string);
|
||||
std::string CrushGlslToAscii(const std::string& u8);
|
||||
Maybe<webgl::ErrorInfo> CheckGLSLVariableName(const bool webgl2,
|
||||
const std::string& name);
|
||||
|
||||
|
|
|
@ -7733,7 +7733,6 @@ subsuite = webgl2-ext
|
|||
subsuite = webgl2-ext
|
||||
[generated/test_2_conformance__glsl__bugs__character-set.html]
|
||||
subsuite = webgl2-ext
|
||||
fail-if = 1
|
||||
[generated/test_2_conformance__glsl__bugs__compare-loop-index-to-uniform.html]
|
||||
subsuite = webgl2-ext
|
||||
[generated/test_2_conformance__glsl__bugs__complex-glsl-does-not-crash.html]
|
||||
|
@ -8365,7 +8364,6 @@ subsuite = webgl2-core
|
|||
subsuite = webgl2-core
|
||||
[generated/test_2_conformance__misc__invalid-passed-params.html]
|
||||
subsuite = webgl2-core
|
||||
fail-if = 1
|
||||
[generated/test_2_conformance__misc__is-object.html]
|
||||
subsuite = webgl2-core
|
||||
[generated/test_2_conformance__misc__null-object-behaviour.html]
|
||||
|
@ -11152,7 +11150,6 @@ subsuite = webgl1-ext
|
|||
subsuite = webgl1-ext
|
||||
[generated/test_conformance__glsl__bugs__character-set.html]
|
||||
subsuite = webgl1-ext
|
||||
fail-if = 1
|
||||
[generated/test_conformance__glsl__bugs__compare-loop-index-to-uniform.html]
|
||||
subsuite = webgl1-ext
|
||||
skip-if = (os == 'android')
|
||||
|
@ -11824,7 +11821,6 @@ subsuite = webgl1-core
|
|||
subsuite = webgl1-core
|
||||
[generated/test_conformance__misc__invalid-passed-params.html]
|
||||
subsuite = webgl1-core
|
||||
fail-if = 1
|
||||
[generated/test_conformance__misc__is-object.html]
|
||||
subsuite = webgl1-core
|
||||
[generated/test_conformance__misc__null-object-behaviour.html]
|
||||
|
|
|
@ -30,13 +30,6 @@ fail-if = 1
|
|||
####################
|
||||
# Bugs surfaced during v93 CTS update
|
||||
|
||||
[generated/test_conformance__misc__invalid-passed-params.html]
|
||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1725071
|
||||
# "context.getError() should be 0. Was 1281"
|
||||
fail-if = 1
|
||||
[generated/test_2_conformance__misc__invalid-passed-params.html]
|
||||
# Ditto
|
||||
fail-if = 1
|
||||
[generated/test_conformance__textures__misc__video-rotation.html]
|
||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1725072
|
||||
# E.g. "shouldBe 255,0,0 +/-10"
|
||||
|
@ -44,13 +37,6 @@ fail-if = 1
|
|||
[generated/test_2_conformance__textures__misc__video-rotation.html]
|
||||
# Ditto
|
||||
fail-if = 1
|
||||
[generated/test_conformance__glsl__bugs__character-set.html]
|
||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1725069
|
||||
# E.g. "getError expected: NO_ERROR. Was INVALID_VALUE : shaderSource allows Out-of-charset string '$' in identifier until compilation"
|
||||
fail-if = 1
|
||||
[generated/test_2_conformance__glsl__bugs__character-set.html]
|
||||
# Ditto
|
||||
fail-if = 1
|
||||
[generated/test_conformance__glsl__misc__shaders-with-name-conflicts.html]
|
||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1725074
|
||||
# [unexpected link status] (expected: true) using the same name for a vertex shader attribute and fragment
|
||||
|
|
Загрузка…
Ссылка в новой задаче