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.
This commit is contained in:
wolfbeast 2020-01-16 01:40:30 +01:00 committed by Roy Tam
commit 9f7f1d457f
4 changed files with 30 additions and 0 deletions

View file

@ -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;