introduce new --dump-builtin-symbols command line
add corresponding EShMsgBuiltinSymbolTable TSymbol::dump functions have option to do "complete" print bugfix in TType::getCompleteString, structure can be null for block
This commit is contained in:
parent
0527c9db81
commit
55ba3eaf89
@ -162,6 +162,7 @@ const char* shaderStageName = nullptr;
|
|||||||
const char* variableName = nullptr;
|
const char* variableName = nullptr;
|
||||||
bool HlslEnable16BitTypes = false;
|
bool HlslEnable16BitTypes = false;
|
||||||
bool HlslDX9compatible = false;
|
bool HlslDX9compatible = false;
|
||||||
|
bool DumpBuiltinSymbols = false;
|
||||||
std::vector<std::string> IncludeDirectoryList;
|
std::vector<std::string> IncludeDirectoryList;
|
||||||
|
|
||||||
// Source environment
|
// Source environment
|
||||||
@ -494,6 +495,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
|
|||||||
Error("--client expects vulkan100 or opengl100");
|
Error("--client expects vulkan100 or opengl100");
|
||||||
}
|
}
|
||||||
bumpArg();
|
bumpArg();
|
||||||
|
} else if (lowerword == "dump-builtin-symbols") {
|
||||||
|
DumpBuiltinSymbols = true;
|
||||||
} else if (lowerword == "entry-point") {
|
} else if (lowerword == "entry-point") {
|
||||||
entryPointName = argv[1];
|
entryPointName = argv[1];
|
||||||
if (argc <= 1)
|
if (argc <= 1)
|
||||||
@ -833,6 +836,8 @@ void SetMessageOptions(EShMessages& messages)
|
|||||||
messages = (EShMessages)(messages | EShMsgHlslLegalization);
|
messages = (EShMessages)(messages | EShMsgHlslLegalization);
|
||||||
if (HlslDX9compatible)
|
if (HlslDX9compatible)
|
||||||
messages = (EShMessages)(messages | EShMsgHlslDX9Compatible);
|
messages = (EShMessages)(messages | EShMsgHlslDX9Compatible);
|
||||||
|
if (DumpBuiltinSymbols)
|
||||||
|
messages = (EShMessages)(messages | EShMsgBuiltinSymbolTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1520,6 +1525,7 @@ void usage()
|
|||||||
" --auto-map-locations | --aml automatically locate input/output lacking\n"
|
" --auto-map-locations | --aml automatically locate input/output lacking\n"
|
||||||
" 'location' (fragile, not cross stage)\n"
|
" 'location' (fragile, not cross stage)\n"
|
||||||
" --client {vulkan<ver>|opengl<ver>} see -V and -G\n"
|
" --client {vulkan<ver>|opengl<ver>} see -V and -G\n"
|
||||||
|
" --dump-builtin-symbols prints builint symbol table prior each stage\n"
|
||||||
" -dumpfullversion | -dumpversion print bare major.minor.patchlevel\n"
|
" -dumpfullversion | -dumpversion print bare major.minor.patchlevel\n"
|
||||||
" --flatten-uniform-arrays | --fua flatten uniform texture/sampler arrays to\n"
|
" --flatten-uniform-arrays | --fua flatten uniform texture/sampler arrays to\n"
|
||||||
" scalars\n"
|
" scalars\n"
|
||||||
|
@ -2018,7 +2018,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add struct/block members
|
// Add struct/block members
|
||||||
if (isStruct()) {
|
if (isStruct() && structure) {
|
||||||
appendStr("{");
|
appendStr("{");
|
||||||
for (size_t i = 0; i < structure->size(); ++i) {
|
for (size_t i = 0; i < structure->size(); ++i) {
|
||||||
if (! (*structure)[i].type->hiddenMember()) {
|
if (! (*structure)[i].type->hiddenMember()) {
|
||||||
|
@ -377,6 +377,8 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
|
|||||||
infoSink, commonTable, symbolTables);
|
infoSink, commonTable, symbolTables);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,6 +476,14 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
|
|||||||
glslang::ReleaseGlobalLock();
|
glslang::ReleaseGlobalLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to Print all builtins
|
||||||
|
void DumpBuiltinSymbolTable(TInfoSink& infoSink, const TSymbolTable& symbolTable)
|
||||||
|
{
|
||||||
|
infoSink.debug << "BuiltinSymbolTable {\n";
|
||||||
|
symbolTable.dump(infoSink, true);
|
||||||
|
infoSink.debug << "}\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Return true if the shader was correctly specified for version/profile/stage.
|
// Return true if the shader was correctly specified for version/profile/stage.
|
||||||
bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNotFirst, int defaultVersion,
|
bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNotFirst, int defaultVersion,
|
||||||
EShSource source, int& version, EProfile& profile, const SpvVersion& spvVersion)
|
EShSource source, int& version, EProfile& profile, const SpvVersion& spvVersion)
|
||||||
@ -905,6 +915,10 @@ bool ProcessDeferred(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (messages & EShMsgBuiltinSymbolTable) {
|
||||||
|
DumpBuiltinSymbolTable(compiler->infoSink, *symbolTable);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now we can process the full shader under proper symbols and rules.
|
// Now we can process the full shader under proper symbols and rules.
|
||||||
//
|
//
|
||||||
|
@ -176,37 +176,78 @@ void TType::buildMangledName(TString& mangledName) const
|
|||||||
// Dump functions.
|
// Dump functions.
|
||||||
//
|
//
|
||||||
|
|
||||||
void TVariable::dump(TInfoSink& infoSink) const
|
void TSymbol::dumpExtensions(TInfoSink &infoSink) const
|
||||||
{
|
{
|
||||||
infoSink.debug << getName().c_str() << ": " << type.getStorageQualifierString() << " " << type.getBasicTypeString();
|
int numExtensions = getNumExtensions();
|
||||||
if (type.isArray()) {
|
if (numExtensions)
|
||||||
infoSink.debug << "[0]";
|
{
|
||||||
|
infoSink.debug << " <";
|
||||||
|
for (int i = 0; i < numExtensions; i++)
|
||||||
|
{
|
||||||
|
infoSink.debug << getExtensions()[i] << ",";
|
||||||
|
}
|
||||||
|
infoSink.debug << ">";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TVariable::dump(TInfoSink &infoSink, bool complete) const
|
||||||
|
{
|
||||||
|
if (complete)
|
||||||
|
{
|
||||||
|
infoSink.debug << getName().c_str() << ": " << type.getCompleteString();
|
||||||
|
dumpExtensions(infoSink);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
infoSink.debug << getName().c_str() << ": " << type.getStorageQualifierString() << " "
|
||||||
|
<< type.getBasicTypeString();
|
||||||
|
if (type.isArray())
|
||||||
|
{
|
||||||
|
infoSink.debug << "[0]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
infoSink.debug << "\n";
|
infoSink.debug << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFunction::dump(TInfoSink& infoSink) const
|
void TFunction::dump(TInfoSink &infoSink, bool complete) const
|
||||||
{
|
{
|
||||||
infoSink.debug << getName().c_str() << ": " << returnType.getBasicTypeString() << " " << getMangledName().c_str() << "\n";
|
if (complete)
|
||||||
|
{
|
||||||
|
infoSink.debug << getName().c_str() << ": " << returnType.getCompleteString() << " " << getName().c_str() << "(";
|
||||||
|
int numParams = getParamCount();
|
||||||
|
for (int i = 0; i < numParams; i++){
|
||||||
|
const TParameter& param = parameters[i];
|
||||||
|
infoSink.debug << param.type->getCompleteString() << " " << (param.name ? param.name->c_str() : "") << (i < numParams-1 ? "," : "");
|
||||||
|
}
|
||||||
|
infoSink.debug << ")";
|
||||||
|
dumpExtensions(infoSink);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
infoSink.debug << getName().c_str() << ": " << returnType.getBasicTypeString() << " "
|
||||||
|
<< getMangledName().c_str() << "n";
|
||||||
|
}
|
||||||
|
|
||||||
|
infoSink.debug << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TAnonMember::dump(TInfoSink& TInfoSink) const
|
void TAnonMember::dump(TInfoSink &TInfoSink, bool complete) const
|
||||||
{
|
{
|
||||||
TInfoSink.debug << "anonymous member " << getMemberNumber() << " of " << getAnonContainer().getName().c_str() << "\n";
|
TInfoSink.debug << "anonymous member " << getMemberNumber() << " of " << getAnonContainer().getName().c_str()
|
||||||
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSymbolTableLevel::dump(TInfoSink &infoSink) const
|
void TSymbolTableLevel::dump(TInfoSink &infoSink, bool complete) const
|
||||||
{
|
{
|
||||||
tLevel::const_iterator it;
|
tLevel::const_iterator it;
|
||||||
for (it = level.begin(); it != level.end(); ++it)
|
for (it = level.begin(); it != level.end(); ++it)
|
||||||
(*it).second->dump(infoSink);
|
(*it).second->dump(infoSink, complete);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSymbolTable::dump(TInfoSink &infoSink) const
|
void TSymbolTable::dump(TInfoSink &infoSink, bool complete) const
|
||||||
{
|
{
|
||||||
for (int level = currentLevel(); level >= 0; --level) {
|
for (int level = currentLevel(); level >= 0; --level) {
|
||||||
infoSink.debug << "LEVEL " << level << "\n";
|
infoSink.debug << "LEVEL " << level << "\n";
|
||||||
table[level]->dump(infoSink);
|
table[level]->dump(infoSink, complete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,8 @@ public:
|
|||||||
}
|
}
|
||||||
virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); }
|
virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); }
|
||||||
virtual const char** getExtensions() const { return extensions->data(); }
|
virtual const char** getExtensions() const { return extensions->data(); }
|
||||||
virtual void dump(TInfoSink &infoSink) const = 0;
|
virtual void dump(TInfoSink &infoSink, bool pretty = false) const = 0;
|
||||||
|
void dumpExtensions(TInfoSink &infoSink) const;
|
||||||
|
|
||||||
virtual bool isReadOnly() const { return ! writable; }
|
virtual bool isReadOnly() const { return ! writable; }
|
||||||
virtual void makeReadOnly() { writable = false; }
|
virtual void makeReadOnly() { writable = false; }
|
||||||
@ -192,7 +193,7 @@ public:
|
|||||||
}
|
}
|
||||||
virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); }
|
virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); }
|
||||||
|
|
||||||
virtual void dump(TInfoSink &infoSink) const;
|
virtual void dump(TInfoSink &infoSink, bool complete = false) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit TVariable(const TVariable&);
|
explicit TVariable(const TVariable&);
|
||||||
@ -313,7 +314,7 @@ public:
|
|||||||
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
|
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
|
||||||
virtual const TParameter& operator[](int i) const { return parameters[i]; }
|
virtual const TParameter& operator[](int i) const { return parameters[i]; }
|
||||||
|
|
||||||
virtual void dump(TInfoSink &infoSink) const override;
|
virtual void dump(TInfoSink &infoSink, bool complete = false) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit TFunction(const TFunction&);
|
explicit TFunction(const TFunction&);
|
||||||
@ -373,7 +374,7 @@ public:
|
|||||||
virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); }
|
virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); }
|
||||||
|
|
||||||
virtual int getAnonId() const { return anonId; }
|
virtual int getAnonId() const { return anonId; }
|
||||||
virtual void dump(TInfoSink &infoSink) const override;
|
virtual void dump(TInfoSink &infoSink, bool complete = false) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit TAnonMember(const TAnonMember&);
|
explicit TAnonMember(const TAnonMember&);
|
||||||
@ -541,7 +542,7 @@ public:
|
|||||||
|
|
||||||
void relateToOperator(const char* name, TOperator op);
|
void relateToOperator(const char* name, TOperator op);
|
||||||
void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
|
void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
|
||||||
void dump(TInfoSink &infoSink) const;
|
void dump(TInfoSink &infoSink, bool complete = false) const;
|
||||||
TSymbolTableLevel* clone() const;
|
TSymbolTableLevel* clone() const;
|
||||||
void readOnly();
|
void readOnly();
|
||||||
|
|
||||||
@ -842,7 +843,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getMaxSymbolId() { return uniqueId; }
|
int getMaxSymbolId() { return uniqueId; }
|
||||||
void dump(TInfoSink &infoSink) const;
|
void dump(TInfoSink &infoSink, bool complete = false) const;
|
||||||
void copyTable(const TSymbolTable& copyOf);
|
void copyTable(const TSymbolTable& copyOf);
|
||||||
|
|
||||||
void setPreviousDefaultPrecisions(TPrecisionQualifier *p) { table[currentLevel()]->setPreviousDefaultPrecisions(p); }
|
void setPreviousDefaultPrecisions(TPrecisionQualifier *p) { table[currentLevel()]->setPreviousDefaultPrecisions(p); }
|
||||||
|
@ -234,6 +234,7 @@ enum EShMessages {
|
|||||||
EShMsgHlslEnable16BitTypes = (1 << 11), // enable use of 16-bit types in SPIR-V for HLSL
|
EShMsgHlslEnable16BitTypes = (1 << 11), // enable use of 16-bit types in SPIR-V for HLSL
|
||||||
EShMsgHlslLegalization = (1 << 12), // enable HLSL Legalization messages
|
EShMsgHlslLegalization = (1 << 12), // enable HLSL Legalization messages
|
||||||
EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (right now only for samplers)
|
EShMsgHlslDX9Compatible = (1 << 13), // enable HLSL DX9 compatible mode (right now only for samplers)
|
||||||
|
EShMsgBuiltinSymbolTable = (1 << 14), // print the builtin symbol table
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user