Front-end: Warn for likely missed change in default precisions.
This is part of the change to have desktop shaders respect precision qualifiers on Vulkan, but since the defaults are all highp, and that's different from ES fragment shaders, detect likely cases and warn about them (but being careful to not be too noisy if it's unlikely to be a problem).
This commit is contained in:
parent
54571c2519
commit
32c169dbdf
10 changed files with 682 additions and 610 deletions
|
|
@ -144,6 +144,40 @@ protected:
|
|||
std::function<void(int, const char*)> errorCallback;
|
||||
};
|
||||
|
||||
//
|
||||
// Manage the state for when to respect precision qualifiers and when to warn about
|
||||
// the defaults being different than might be expected.
|
||||
//
|
||||
class TPrecisionManager {
|
||||
public:
|
||||
TPrecisionManager() : obey(false), warn(false), explicitIntDefault(false), explicitFloatDefault(false){ }
|
||||
virtual ~TPrecisionManager() {}
|
||||
|
||||
void respectPrecisionQualifiers() { obey = true; }
|
||||
bool respectingPrecisionQualifiers() const { return obey; }
|
||||
bool shouldWarnAboutDefaults() const { return warn; }
|
||||
void defaultWarningGiven() { warn = false; }
|
||||
void warnAboutDefaults() { warn = true; }
|
||||
void explicitIntDefaultSeen()
|
||||
{
|
||||
explicitIntDefault = true;
|
||||
if (explicitFloatDefault)
|
||||
warn = false;
|
||||
}
|
||||
void explicitFloatDefaultSeen()
|
||||
{
|
||||
explicitFloatDefault = true;
|
||||
if (explicitIntDefault)
|
||||
warn = false;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool obey; // respect precision qualifiers
|
||||
bool warn; // need to give a warning about the defaults
|
||||
bool explicitIntDefault; // user set the default for int/uint
|
||||
bool explicitFloatDefault; // user set the default for float
|
||||
};
|
||||
|
||||
//
|
||||
// GLSL-specific parse helper. Should have GLSL in the name, but that's
|
||||
// too big of a change for comparing branches at the moment, and perhaps
|
||||
|
|
@ -155,7 +189,7 @@ public:
|
|||
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
|
||||
virtual ~TParseContext();
|
||||
|
||||
bool obeyPrecisionQualifiers() const { return obeyPrecisionQualifiers_; };
|
||||
bool obeyPrecisionQualifiers() const { return precisionManager.respectingPrecisionQualifiers(); };
|
||||
void setPrecisionDefaults();
|
||||
|
||||
void setLimits(const TBuiltInResource&);
|
||||
|
|
@ -212,6 +246,8 @@ public:
|
|||
void userFunctionCallCheck(const TSourceLoc&, TIntermAggregate&);
|
||||
void samplerConstructorLocationCheck(const TSourceLoc&, const char* token, TIntermNode*);
|
||||
TFunction* handleConstructorCall(const TSourceLoc&, const TPublicType&);
|
||||
void handlePrecisionQualifier(const TSourceLoc&, TQualifier&, TPrecisionQualifier);
|
||||
void checkPrecisionQualifier(const TSourceLoc&, TPrecisionQualifier);
|
||||
|
||||
bool parseVectorFields(const TSourceLoc&, const TString&, int vecSize, TVectorFields&);
|
||||
void assignError(const TSourceLoc&, const char* op, TString left, TString right);
|
||||
|
|
@ -344,6 +380,7 @@ protected:
|
|||
const bool parsingBuiltins; // true if parsing built-in symbols/functions
|
||||
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2 * 2 * 2 * 2)); // see computeSamplerTypeIndex()
|
||||
TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex];
|
||||
TPrecisionManager precisionManager;
|
||||
bool afterEOF;
|
||||
TQualifier globalBufferDefaults;
|
||||
TQualifier globalUniformDefaults;
|
||||
|
|
@ -354,7 +391,6 @@ protected:
|
|||
TIdSetType inductiveLoopIds;
|
||||
bool anyIndexLimits;
|
||||
TVector<TIntermTyped*> needsIndexLimitationChecking;
|
||||
bool obeyPrecisionQualifiers_;
|
||||
|
||||
//
|
||||
// Geometry shader input arrays:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue