Skip to content

Commit 255dc67

Browse files
ShabbyXAngle LUCI CQ
authored andcommitted
Translator: Validate ESSL 100 limitations during parse
Validating the shape of the for loop as specifically required by WebGL (per ESSL 100 spec, Appendix A) is more easily done during parse, where the shape of the input GLSL is exactly known. Bug: angleproject:349994211 Change-Id: I05a9b1b6915dbc1f6c74bb9159f6cc85fefc7b67 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/7022355 Reviewed-by: Yuxin Hu <[email protected]> Commit-Queue: Shahbaz Youssefi <[email protected]> Reviewed-by: Geoff Lang <[email protected]>
1 parent 84b0cf1 commit 255dc67

File tree

13 files changed

+419
-538
lines changed

13 files changed

+419
-538
lines changed

scripts/code_generation_hashes/ANGLE_shader_translator.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"src/compiler/translator/glslang.l":
77
"9b7c272139d0def4b42e2fd93ae9538d",
88
"src/compiler/translator/glslang.y":
9-
"681b62aa1258b36ee27a1b543b40b683",
9+
"b887792a6d04aa7525cf3869961b6d06",
1010
"src/compiler/translator/glslang_lex_autogen.cpp":
1111
"14c0f0593c173936c5be7f87a05a20b9",
1212
"src/compiler/translator/glslang_tab_autogen.cpp":
13-
"17444c0966c581523495dd27c4067778",
13+
"e10f1917b2cbca9fbd15170da044387d",
1414
"src/compiler/translator/glslang_tab_autogen.h":
1515
"028bdaebf359aefbcdaafae466993ebe",
1616
"tools/flex-bison/linux/bison.sha1":

src/compiler.gni

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ angle_translator_sources = [
100100
"src/compiler/translator/ValidateAST.h",
101101
"src/compiler/translator/ValidateGlobalInitializer.cpp",
102102
"src/compiler/translator/ValidateGlobalInitializer.h",
103-
"src/compiler/translator/ValidateLimitations.cpp",
104-
"src/compiler/translator/ValidateLimitations.h",
105103
"src/compiler/translator/ValidateOutputs.cpp",
106104
"src/compiler/translator/ValidateOutputs.h",
107105
"src/compiler/translator/ValidateSwitch.cpp",

src/compiler/translator/Compiler.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "compiler/translator/OutputTree.h"
2727
#include "compiler/translator/ParseContext.h"
2828
#include "compiler/translator/SizeClipCullDistance.h"
29-
#include "compiler/translator/ValidateLimitations.h"
3029
#include "compiler/translator/ValidateOutputs.h"
3130
#include "compiler/translator/ValidateTypeSizeLimitations.h"
3231
#include "compiler/translator/ValidateVaryingLocations.h"
@@ -882,12 +881,6 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
882881
}
883882
}
884883

885-
if (shouldRunLoopAndIndexingValidation(compileOptions) &&
886-
!ValidateLimitations(root, mShaderType, &mSymbolTable, &mDiagnostics))
887-
{
888-
return false;
889-
}
890-
891884
// Fold expressions that could not be folded before validation that was done as a part of
892885
// parsing.
893886
if (!FoldExpressions(this, root, &mDiagnostics))
@@ -1036,7 +1029,6 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
10361029
}
10371030
}
10381031

1039-
// Clamping uniform array bounds needs to happen after validateLimitations pass.
10401032
if (compileOptions.clampIndirectArrayBounds)
10411033
{
10421034
if (!ClampIndirectIndices(this, root, &mSymbolTable))
@@ -1233,7 +1225,6 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
12331225
return false;
12341226
}
12351227

1236-
// Built-in function emulation needs to happen after validateLimitations pass.
12371228
GetGlobalPoolAllocator()->lock();
12381229
initBuiltInFunctionEmulator(&mBuiltInFunctionEmulator, compileOptions);
12391230
GetGlobalPoolAllocator()->unlock();

src/compiler/translator/DirectiveHandler.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "common/debug.h"
1313
#include "compiler/translator/Common.h"
1414
#include "compiler/translator/Diagnostics.h"
15+
#include "compiler/translator/ParseContext.h"
1516

1617
namespace sh
1718
{
@@ -36,11 +37,11 @@ static TBehavior getBehavior(const std::string &str)
3637

3738
TDirectiveHandler::TDirectiveHandler(TExtensionBehavior &extBehavior,
3839
TDiagnostics &diagnostics,
39-
int &shaderVersion,
40+
TParseContext &context,
4041
sh::GLenum shaderType)
4142
: mExtensionBehavior(extBehavior),
4243
mDiagnostics(diagnostics),
43-
mShaderVersion(shaderVersion),
44+
mContext(context),
4445
mShaderType(shaderType)
4546
{}
4647

@@ -63,7 +64,7 @@ void TDirectiveHandler::handlePragma(const angle::pp::SourceLocation &loc,
6364

6465
if (name == kInvariant && value == kAll)
6566
{
66-
if (mShaderVersion == 300 && mShaderType == GL_FRAGMENT_SHADER)
67+
if (mContext.getShaderVersion() == 300 && mShaderType == GL_FRAGMENT_SHADER)
6768
{
6869
// ESSL 3.00.4 section 4.6.1
6970
mDiagnostics.error(
@@ -151,7 +152,8 @@ void TDirectiveHandler::handleExtension(const angle::pp::SourceLocation &loc,
151152
}
152153

153154
TExtensionBehavior::iterator iter = mExtensionBehavior.find(GetExtensionByName(name.c_str()));
154-
if (iter != mExtensionBehavior.end() && CheckExtensionVersion(iter->first, mShaderVersion))
155+
if (iter != mExtensionBehavior.end() &&
156+
CheckExtensionVersion(iter->first, mContext.getShaderVersion()))
155157
{
156158
iter->second = behaviorVal;
157159
// OVR_multiview is implicitly enabled when OVR_multiview2 is enabled
@@ -308,7 +310,7 @@ void TDirectiveHandler::handleVersion(const angle::pp::SourceLocation &loc,
308310
{
309311
if (version == 100 || version == 300 || version == 310 || version == 320)
310312
{
311-
mShaderVersion = version;
313+
mContext.onShaderVersionDeclared(version);
312314

313315
// Add macros for supported extensions
314316
for (const auto &iter : mExtensionBehavior)

src/compiler/translator/DirectiveHandler.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
namespace sh
1818
{
1919
class TDiagnostics;
20+
class TParseContext;
2021

2122
class TDirectiveHandler : public angle::pp::DirectiveHandler, angle::NonCopyable
2223
{
2324
public:
2425
TDirectiveHandler(TExtensionBehavior &extBehavior,
2526
TDiagnostics &diagnostics,
26-
int &shaderVersion,
27+
TParseContext &context,
2728
sh::GLenum shaderType);
2829
~TDirectiveHandler() override;
2930

@@ -50,7 +51,7 @@ class TDirectiveHandler : public angle::pp::DirectiveHandler, angle::NonCopyable
5051
TPragma mPragma;
5152
TExtensionBehavior &mExtensionBehavior;
5253
TDiagnostics &mDiagnostics;
53-
int &mShaderVersion;
54+
TParseContext &mContext;
5455
sh::GLenum mShaderType;
5556
};
5657

0 commit comments

Comments
 (0)