Commit b7418a17 by Tobin Ehlis Committed by Commit Bot

Restore flatten invariant behavior

This was removed with a previous commit to fix behavior of invariant pragma overall, however, the flattening is still needed for the initial translation step of webGL VSs. This change restores the flattening as it previously existed, however it is now only applied to VS outputs. FS inputs are no longer flattened as the previous fixes preclude the need for that workaround any longer. Bug: 980675 Change-Id: Ia3c0471e24cae2905eb0d7bde153091e4d3829b4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1687788Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent 196cd9e7
......@@ -364,8 +364,8 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
++firstSource;
}
TParseContext parseContext(mSymbolTable, mExtensionBehavior, mShaderType, mShaderSpec, true,
&mDiagnostics, getResources());
TParseContext parseContext(mSymbolTable, mExtensionBehavior, mShaderType, mShaderSpec,
compileOptions, true, &mDiagnostics, getResources());
parseContext.setFragmentPrecisionHighOnESSL1(mResources.FragmentPrecisionHigh == 1);
......
......@@ -166,6 +166,7 @@ TParseContext::TParseContext(TSymbolTable &symt,
TExtensionBehavior &ext,
sh::GLenum type,
ShShaderSpec spec,
ShCompileOptions options,
bool checksPrecErrors,
TDiagnostics *diagnostics,
const ShBuiltInResources &resources)
......@@ -173,6 +174,7 @@ TParseContext::TParseContext(TSymbolTable &symt,
mDeferredNonEmptyDeclarationErrorCheck(false),
mShaderType(type),
mShaderSpec(spec),
mCompileOptions(options),
mShaderVersion(100),
mTreeRoot(nullptr),
mLoopNestingLevel(0),
......@@ -2447,6 +2449,28 @@ TIntermDeclaration *TParseContext::parseSingleDeclaration(
const ImmutableString &identifier)
{
TType *type = new TType(publicType);
if ((mCompileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL) &&
mDirectiveHandler.pragma().stdgl.invariantAll)
{
TQualifier qualifier = type->getQualifier();
// The directive handler has already taken care of rejecting invalid uses of this pragma
// (for example, in ESSL 3.00 fragment shaders), so at this point, flatten it into all
// affected variable declarations:
//
// 1. Built-in special variables which are inputs to the fragment shader. (These are handled
// elsewhere, in TranslatorGLSL.)
//
// 2. Outputs from vertex shaders in ESSL 1.00 and 3.00 (EvqVaryingOut and EvqVertexOut). It
// is actually less likely that there will be bugs in the handling of ESSL 3.00 shaders, but
// the way this is currently implemented we have to enable this compiler option before
// parsing the shader and determining the shading language version it uses. If this were
// implemented as a post-pass, the workaround could be more targeted.
if (qualifier == EvqVaryingOut || qualifier == EvqVertexOut)
{
type->setInvariant(true);
}
}
checkGeometryShaderInputAndSetArraySize(identifierOrTypeLocation, identifier, type);
......
......@@ -37,6 +37,7 @@ class TParseContext : angle::NonCopyable
TExtensionBehavior &ext,
sh::GLenum type,
ShShaderSpec spec,
ShCompileOptions options,
bool checksPrecErrors,
TDiagnostics *diagnostics,
const ShBuiltInResources &resources);
......@@ -597,6 +598,7 @@ class TParseContext : angle::NonCopyable
sh::GLenum mShaderType; // vertex or fragment language (future: pack or unpack)
ShShaderSpec mShaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
ShCompileOptions mCompileOptions; // Options passed to TCompiler
int mShaderVersion;
TIntermBlock *mTreeRoot; // root of parse tree being created
int mLoopNestingLevel; // 0 if outside all loops
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment