зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1325238 - Use ShCompileOptions type instead of int. - r=daoshengmu
Also only use SH_LIMIT_CALL_STACK_DEPTH if we have resources.MaxCallStackDepth. MozReview-Commit-ID: DXhw7A7gCjF
This commit is contained in:
Родитель
6091cfeb6e
Коммит
35a5dbc87a
|
@ -28,38 +28,21 @@ IdentifierHashFunc(const char* name, size_t len)
|
||||||
return hash[0];
|
return hash[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static ShCompileOptions
|
||||||
ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
|
ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
|
||||||
const mozilla::gl::GLContext* gl)
|
const mozilla::gl::GLContext* gl)
|
||||||
{
|
{
|
||||||
int options = SH_VARIABLES |
|
ShCompileOptions options = SH_VARIABLES |
|
||||||
SH_ENFORCE_PACKING_RESTRICTIONS |
|
SH_ENFORCE_PACKING_RESTRICTIONS |
|
||||||
SH_OBJECT_CODE |
|
SH_OBJECT_CODE |
|
||||||
SH_LIMIT_CALL_STACK_DEPTH |
|
|
||||||
SH_INIT_GL_POSITION;
|
SH_INIT_GL_POSITION;
|
||||||
|
|
||||||
if (resources.MaxExpressionComplexity > 0) {
|
|
||||||
options |= SH_LIMIT_EXPRESSION_COMPLEXITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sampler arrays indexed with non-constant expressions are forbidden in
|
// Sampler arrays indexed with non-constant expressions are forbidden in
|
||||||
// GLSL 1.30 and later.
|
// GLSL 1.30 and later.
|
||||||
// ESSL 3 requires constant-integral-expressions for this as well.
|
// ESSL 3 requires constant-integral-expressions for this as well.
|
||||||
// Just do it universally.
|
// Just do it universally.
|
||||||
options |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX;
|
options |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX;
|
||||||
|
|
||||||
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
|
#ifndef XP_MACOSX
|
||||||
// We want to do this everywhere, but to do this on Mac, we need
|
// We want to do this everywhere, but to do this on Mac, we need
|
||||||
// to do it only on Mac OSX > 10.6 as this causes the shader
|
// to do it only on Mac OSX > 10.6 as this causes the shader
|
||||||
|
@ -79,6 +62,30 @@ ChooseValidatorCompileOptions(const ShBuiltInResources& resources,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (gfxPrefs::WebGLAllANGLEOptions()) {
|
||||||
|
options = -1;
|
||||||
|
|
||||||
|
options ^= SH_INTERMEDIATE_TREE;
|
||||||
|
options ^= SH_LINE_DIRECTIVES;
|
||||||
|
options ^= SH_SOURCE_PATH;
|
||||||
|
|
||||||
|
options ^= SH_LIMIT_EXPRESSION_COMPLEXITY;
|
||||||
|
options ^= SH_LIMIT_CALL_STACK_DEPTH;
|
||||||
|
|
||||||
|
options ^= SH_EXPAND_SELECT_HLSL_INTEGER_POW_EXPRESSIONS;
|
||||||
|
options ^= SH_HLSL_GET_DIMENSIONS_IGNORES_BASE_LEVEL;
|
||||||
|
|
||||||
|
options ^= SH_DONT_REMOVE_INVARIANT_FOR_FRAGMENT_INPUT;
|
||||||
|
options ^= SH_REMOVE_INVARIANT_AND_CENTROID_FOR_ESSL3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resources.MaxExpressionComplexity > 0) {
|
||||||
|
options |= SH_LIMIT_EXPRESSION_COMPLEXITY;
|
||||||
|
}
|
||||||
|
if (resources.MaxCallStackDepth > 0) {
|
||||||
|
options |= SH_LIMIT_CALL_STACK_DEPTH;
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,8 +173,7 @@ WebGLContext::CreateShaderValidator(GLenum shaderType) const
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int compileOptions = webgl::ChooseValidatorCompileOptions(resources, gl);
|
const auto compileOptions = webgl::ChooseValidatorCompileOptions(resources, gl);
|
||||||
|
|
||||||
return webgl::ShaderValidator::Create(shaderType, spec, outputLanguage, resources,
|
return webgl::ShaderValidator::Create(shaderType, spec, outputLanguage, resources,
|
||||||
compileOptions);
|
compileOptions);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +185,8 @@ namespace webgl {
|
||||||
/*static*/ ShaderValidator*
|
/*static*/ ShaderValidator*
|
||||||
ShaderValidator::Create(GLenum shaderType, ShShaderSpec spec,
|
ShaderValidator::Create(GLenum shaderType, ShShaderSpec spec,
|
||||||
ShShaderOutput outputLanguage,
|
ShShaderOutput outputLanguage,
|
||||||
const ShBuiltInResources& resources, int compileOptions)
|
const ShBuiltInResources& resources,
|
||||||
|
ShCompileOptions compileOptions)
|
||||||
{
|
{
|
||||||
ShHandle handle = ShConstructCompiler(shaderType, spec, outputLanguage, &resources);
|
ShHandle handle = ShConstructCompiler(shaderType, spec, outputLanguage, &resources);
|
||||||
if (!handle)
|
if (!handle)
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace webgl {
|
||||||
class ShaderValidator final
|
class ShaderValidator final
|
||||||
{
|
{
|
||||||
const ShHandle mHandle;
|
const ShHandle mHandle;
|
||||||
const int mCompileOptions;
|
const ShCompileOptions mCompileOptions;
|
||||||
const int mMaxVaryingVectors;
|
const int mMaxVaryingVectors;
|
||||||
bool mHasRun;
|
bool mHasRun;
|
||||||
|
|
||||||
|
@ -25,10 +25,11 @@ public:
|
||||||
static ShaderValidator* Create(GLenum shaderType, ShShaderSpec spec,
|
static ShaderValidator* Create(GLenum shaderType, ShShaderSpec spec,
|
||||||
ShShaderOutput outputLanguage,
|
ShShaderOutput outputLanguage,
|
||||||
const ShBuiltInResources& resources,
|
const ShBuiltInResources& resources,
|
||||||
int compileOptions);
|
ShCompileOptions compileOptions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ShaderValidator(ShHandle handle, int compileOptions, int maxVaryingVectors)
|
ShaderValidator(ShHandle handle, ShCompileOptions compileOptions,
|
||||||
|
int maxVaryingVectors)
|
||||||
: mHandle(handle)
|
: mHandle(handle)
|
||||||
, mCompileOptions(compileOptions)
|
, mCompileOptions(compileOptions)
|
||||||
, mMaxVaryingVectors(maxVaryingVectors)
|
, mMaxVaryingVectors(maxVaryingVectors)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче