Commit daf56572 by Zhenyao Mo

For SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS, assign precision to temp variables.

Otherwise on Windows or other platforms with GLES backend, using this workaround will trigger shader compile failure. For the moment, to simplify the workaround, for any missing precisions in float, we always assign the highest available precion to it. BUG=angle:695 TEST=webgl conformance tests Change-Id: I810579442bc7fc61d6a52b76aff31a779046fa22 Reviewed-on: https://chromium-review.googlesource.com/211253Tested-by: 's avatarZhenyao Mo <zmo@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org>
parent cef06ff2
...@@ -258,7 +258,8 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -258,7 +258,8 @@ bool TCompiler::compile(const char* const shaderStrings[],
if (success && (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS)) if (success && (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS))
{ {
ScalarizeVecAndMatConstructorArgs scalarizer; ScalarizeVecAndMatConstructorArgs scalarizer(
shaderType, fragmentPrecisionHigh);
root->traverse(&scalarizer); root->traverse(&scalarizer);
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <algorithm> #include <algorithm>
#include "angle_gl.h"
#include "common/angleutils.h" #include "common/angleutils.h"
namespace namespace
...@@ -249,6 +250,16 @@ TString ScalarizeVecAndMatConstructorArgs::createTempVariable(TIntermTyped *orig ...@@ -249,6 +250,16 @@ TString ScalarizeVecAndMatConstructorArgs::createTempVariable(TIntermTyped *orig
TType type = original->getType(); TType type = original->getType();
type.setQualifier(EvqTemporary); type.setQualifier(EvqTemporary);
if (mShaderType == GL_FRAGMENT_SHADER &&
type.getBasicType() == EbtFloat &&
type.getPrecision() == EbpUndefined)
{
// We use the highest available precision for the temporary variable
// to avoid computing the actual precision using the rules defined
// in GLSL ES 1.0 Section 4.5.2.
type.setPrecision(mFragmentPrecisionHigh ? EbpHigh : EbpMedium);
}
TIntermBinary *init = new TIntermBinary(EOpInitialize); TIntermBinary *init = new TIntermBinary(EOpInitialize);
TIntermSymbol *symbolNode = new TIntermSymbol(-1, tempVarName, type); TIntermSymbol *symbolNode = new TIntermSymbol(-1, tempVarName, type);
init->setLeft(symbolNode); init->setLeft(symbolNode);
......
...@@ -12,8 +12,11 @@ ...@@ -12,8 +12,11 @@
class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser
{ {
public: public:
ScalarizeVecAndMatConstructorArgs() ScalarizeVecAndMatConstructorArgs(sh::GLenum shaderType,
: mTempVarCount(0) {} bool fragmentPrecisionHigh)
: mTempVarCount(0),
mShaderType(shaderType),
mFragmentPrecisionHigh(fragmentPrecisionHigh) {}
protected: protected:
virtual bool visitAggregate(Visit visit, TIntermAggregate *node); virtual bool visitAggregate(Visit visit, TIntermAggregate *node);
...@@ -36,6 +39,9 @@ class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser ...@@ -36,6 +39,9 @@ class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser
std::vector<TIntermSequence> mSequenceStack; std::vector<TIntermSequence> mSequenceStack;
int mTempVarCount; int mTempVarCount;
sh::GLenum mShaderType;
bool mFragmentPrecisionHigh;
}; };
#endif // COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_ #endif // COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_
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