diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-16 01:40:30 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-16 01:40:30 +0100 |
commit | 7007ec9e42bf443566846296aa70aba47ee9feb3 (patch) | |
tree | ad5cae07003480fdf2de3ffbd80af5f8644ab39d /dom/canvas/WebGLShaderValidator.cpp | |
parent | 058105eec0564943dd872a7ae43cd8a5b94f0abf (diff) | |
download | UXP-7007ec9e42bf443566846296aa70aba47ee9feb3.tar UXP-7007ec9e42bf443566846296aa70aba47ee9feb3.tar.gz UXP-7007ec9e42bf443566846296aa70aba47ee9feb3.tar.lz UXP-7007ec9e42bf443566846296aa70aba47ee9feb3.tar.xz UXP-7007ec9e42bf443566846296aa70aba47ee9feb3.zip |
Issue #1354 - Don't allow glsl[130,400] unless we have gpu_shader5
- Teach GLContext about gpu_shader5
- Downgrade shader language version if gpu_shader5 support isn't found.
Diffstat (limited to 'dom/canvas/WebGLShaderValidator.cpp')
-rw-r--r-- | dom/canvas/WebGLShaderValidator.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/dom/canvas/WebGLShaderValidator.cpp b/dom/canvas/WebGLShaderValidator.cpp index fda31e212..d574d9a65 100644 --- a/dom/canvas/WebGLShaderValidator.cpp +++ b/dom/canvas/WebGLShaderValidator.cpp @@ -5,6 +5,7 @@ #include "WebGLShaderValidator.h" +#include <algorithm> #include "angle/ShaderLang.h" #include "gfxPrefs.h" #include "GLContext.h" @@ -112,6 +113,16 @@ ShaderOutput(gl::GLContext* gl) return SH_ESSL_OUTPUT; } else { uint32_t version = gl->ShadingLanguageVersion(); + + // Version 130 starts to require integral constant expressions for loop indices, + // instead of "constant-index-expression". + // Both version 400 and gpu_shader5 remove this restrictions. + // gpu_shader5 went core in 400, so we can just check for the GLFeature. + // If we're compiling for webglsl1, even for webgl2, we need gpu_shader5, or GLSL_COMPAT. + if (!gl->IsSupported(gl::GLFeature::gpu_shader5)) { + version = std::min<uint32_t>(version, 120); + } + switch (version) { case 100: return SH_GLSL_COMPATIBILITY_OUTPUT; case 120: return SH_GLSL_COMPATIBILITY_OUTPUT; |