Commit ed14b79d by Zhenyao Mo

Shaders should fail compile if a boolean's precision is specified

Tested and no regression on WebGL conformance 1.0.3 BUG=angle:628 BUG=368874 TEST=http://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/boolean_precision.html Change-Id: Ie74616c3ab846eea19f4bd4a041fc0f00d55f151 Reviewed-on: https://chromium-review.googlesource.com/198884Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Tested-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent 7b827596
...@@ -289,6 +289,11 @@ inline bool IsShadowSampler(TBasicType type) ...@@ -289,6 +289,11 @@ inline bool IsShadowSampler(TBasicType type)
return false; return false;
} }
inline bool SupportsPrecision(TBasicType type)
{
return type == EbtFloat || type == EbtInt || type == EbtUInt || IsSampler(type);
}
// //
// Qualifiers and built-ins. These are mainly used to see what can be read // Qualifiers and built-ins. These are mainly used to see what can be read
// or written, and by the machine dependent translator to know which registers // or written, and by the machine dependent translator to know which registers
......
...@@ -377,7 +377,7 @@ public: ...@@ -377,7 +377,7 @@ public:
void dump(TInfoSink &infoSink) const; void dump(TInfoSink &infoSink) const;
bool setDefaultPrecision(const TPublicType& type, TPrecision prec) { bool setDefaultPrecision(const TPublicType& type, TPrecision prec) {
if (!supportsPrecision(type.type)) if (!SupportsPrecision(type.type))
return false; return false;
if (type.isAggregate()) if (type.isAggregate())
return false; // Not allowed to set for aggregate types return false; // Not allowed to set for aggregate types
...@@ -389,7 +389,7 @@ public: ...@@ -389,7 +389,7 @@ public:
// Searches down the precisionStack for a precision qualifier for the specified TBasicType // Searches down the precisionStack for a precision qualifier for the specified TBasicType
TPrecision getDefaultPrecision( TBasicType type){ TPrecision getDefaultPrecision( TBasicType type){
if (!supportsPrecision(type)) if (!SupportsPrecision(type))
return EbpUndefined; return EbpUndefined;
// unsigned integers use the same precision as signed // unsigned integers use the same precision as signed
...@@ -413,11 +413,6 @@ public: ...@@ -413,11 +413,6 @@ public:
private: private:
ESymbolLevel currentLevel() const { return static_cast<ESymbolLevel>(table.size() - 1); } ESymbolLevel currentLevel() const { return static_cast<ESymbolLevel>(table.size() - 1); }
bool supportsPrecision(TBasicType type) {
// Only supports precision for int, float, and sampler types.
return type == EbtFloat || type == EbtInt || type == EbtUInt || IsSampler(type);
}
std::vector<TSymbolTableLevel*> table; std::vector<TSymbolTableLevel*> table;
typedef TMap<TBasicType, TPrecision> PrecisionStackLevel; typedef TMap<TBasicType, TPrecision> PrecisionStackLevel;
std::vector< PrecisionStackLevel*> precisionStack; std::vector< PrecisionStackLevel*> precisionStack;
......
...@@ -1254,6 +1254,11 @@ type_specifier ...@@ -1254,6 +1254,11 @@ type_specifier
| precision_qualifier type_specifier_no_prec { | precision_qualifier type_specifier_no_prec {
$$ = $2; $$ = $2;
$$.precision = $1; $$.precision = $1;
if (!SupportsPrecision($2.type) {
context->error(@1, "illegal type for precision qualifier", getBasicString($2.type));
context->recover();
}
} }
; ;
......
...@@ -3937,6 +3937,11 @@ yyreduce: ...@@ -3937,6 +3937,11 @@ yyreduce:
{ {
(yyval.interm.type) = (yyvsp[(2) - (2)].interm.type); (yyval.interm.type) = (yyvsp[(2) - (2)].interm.type);
(yyval.interm.type).precision = (yyvsp[(1) - (2)].interm.precision); (yyval.interm.type).precision = (yyvsp[(1) - (2)].interm.precision);
if (!SupportsPrecision((yyvsp[(2) - (2)].interm.type).type)) {
context->error((yylsp[(1) - (1)]), "illegal type for precision qualifier", getBasicString((yyvsp[(2) - (2)].interm.type).type));
context->recover();
}
} }
break; break;
......
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