Implement NonSemantic.Shader.DebugInfo.100

See https://github.com/KhronosGroup/SPIRV-Registry.
This commit is contained in:
Jeremy Hayes 2021-12-09 16:26:48 -07:00
parent 9e78bc8108
commit 7a914ce926
55 changed files with 11275 additions and 96 deletions

View file

@ -3428,7 +3428,7 @@ bool HlslGrammar::acceptCompoundStatement(TIntermNode*& retStatement)
}
}
if (compoundStatement)
compoundStatement->setOperator(EOpSequence);
compoundStatement->setOperator(intermediate.getDebugInfo() ? EOpScope : EOpSequence);
retStatement = compoundStatement;

View file

@ -2442,6 +2442,11 @@ void HlslParseContext::remapNonEntryPointIO(TFunction& function)
clearUniformInputOutput(function[i].type->getQualifier());
}
TIntermNode* HlslParseContext::handleDeclare(const TSourceLoc& loc, TIntermTyped* var)
{
return intermediate.addUnaryNode(EOpDeclare, var, loc, TType(EbtVoid));
}
// Handle function returns, including type conversions to the function return type
// if necessary.
TIntermNode* HlslParseContext::handleReturnValue(const TSourceLoc& loc, TIntermTyped* value)
@ -8035,11 +8040,16 @@ TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, const TStr
if (flattenVar)
flatten(*symbol->getAsVariable(), symbolTable.atGlobalLevel());
if (initializer == nullptr)
return nullptr;
TVariable* variable = symbol->getAsVariable();
if (initializer == nullptr) {
if (intermediate.getDebugInfo())
return executeDeclaration(loc, variable);
else
return nullptr;
}
// Deal with initializer
TVariable* variable = symbol->getAsVariable();
if (variable == nullptr) {
error(loc, "initializer requires a variable, not a member", identifier.c_str(), "");
return nullptr;
@ -8106,6 +8116,24 @@ TVariable* HlslParseContext::declareNonArray(const TSourceLoc& loc, const TStrin
return nullptr;
}
// Return a declaration of a temporary variable
//
// This is used to force a variable to be declared in the correct scope
// when debug information is being generated.
TIntermNode* HlslParseContext::executeDeclaration(const TSourceLoc& loc, TVariable* variable)
{
//
// Identifier must be of type temporary.
//
TStorageQualifier qualifier = variable->getType().getQualifier().storage;
if (qualifier != EvqTemporary)
return nullptr;
TIntermSymbol* intermSymbol = intermediate.addSymbol(*variable, loc);
return handleDeclare(loc, intermSymbol);
}
//
// Handle all types of initializers from the grammar.
//

View file

@ -87,6 +87,7 @@ public:
void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node);
void remapEntryPointIO(TFunction& function, TVariable*& returnValue, TVector<TVariable*>& inputs, TVector<TVariable*>& outputs);
void remapNonEntryPointIO(TFunction& function);
TIntermNode* handleDeclare(const TSourceLoc&, TIntermTyped*);
TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right);
@ -243,6 +244,7 @@ protected:
TIntermSymbol* makeInternalVariableNode(const TSourceLoc&, const char* name, const TType&) const;
TVariable* declareNonArray(const TSourceLoc&, const TString& identifier, const TType&, bool track);
void declareArray(const TSourceLoc&, const TString& identifier, const TType&, TSymbol*&, bool track);
TIntermNode* executeDeclaration(const TSourceLoc&, TVariable* variable);
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer, TIntermTyped* scalarInit);
bool isScalarConstructor(const TIntermNode*);