Merge remote-tracking branch 'origin/master' into custom

This commit is contained in:
Roy Tam 2020-01-17 09:24:31 +08:00
commit 969d239b65
407 changed files with 91582 additions and 305 deletions

View file

@ -5,6 +5,7 @@
#include "WebGLShaderValidator.h"
#include <algorithm>
#include "angle/ShaderLang.h"
#include "gfxPrefs.h"
#include "GLContext.h"
@ -32,14 +33,14 @@ static int
ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
const mozilla::gl::GLContext* gl)
{
int options = SH_VARIABLES |
SH_ENFORCE_PACKING_RESTRICTIONS |
int options = SH_VARIABLES |
SH_ENFORCE_PACKING_RESTRICTIONS |
SH_INIT_VARYINGS_WITHOUT_STATIC_USE |
SH_OBJECT_CODE |
SH_INIT_GL_POSITION;
if (resources.MaxExpressionComplexity > 0) {
options |= SH_LIMIT_EXPRESSION_COMPLEXITY;
SH_OBJECT_CODE |
SH_INIT_GL_POSITION;
if (resources.MaxExpressionComplexity > 0) {
options |= SH_LIMIT_EXPRESSION_COMPLEXITY;
}
// Sampler arrays indexed with non-constant expressions are forbidden in
// GLSL 1.30 and later.
@ -50,17 +51,17 @@ ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
// Needed for driver bug detection
options |= SH_EMULATE_BUILT_IN_FUNCTIONS;
if (gfxPrefs::WebGLAllANGLEOptions()) {
return options |
SH_VALIDATE_LOOP_INDEXING |
SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX |
SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX |
SH_CLAMP_INDIRECT_ARRAY_BOUNDS |
SH_UNFOLD_SHORT_CIRCUIT |
SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS |
SH_INIT_OUTPUT_VARIABLES |
SH_REGENERATE_STRUCT_NAMES;
}
if (gfxPrefs::WebGLAllANGLEOptions()) {
return options |
SH_VALIDATE_LOOP_INDEXING |
SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX |
SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX |
SH_CLAMP_INDIRECT_ARRAY_BOUNDS |
SH_UNFOLD_SHORT_CIRCUIT |
SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS |
SH_INIT_OUTPUT_VARIABLES |
SH_REGENERATE_STRUCT_NAMES;
}
#ifndef XP_MACOSX
// We want to do this everywhere, but to do this on Mac, we need
@ -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;