Browse Source

fixup of inconvenience in emission: over-generation of sharp-line directives. (notably for each srg constants)

Signed-off-by: Vivien Oddou <[email protected]>
Vivien Oddou 2 years ago
parent
commit
a2fb7f3a8f
2 changed files with 10 additions and 6 deletions
  1. 9 5
      src/AzslcEmitter.cpp
  2. 1 1
      src/AzslcMain.cpp

+ 9 - 5
src/AzslcEmitter.cpp

@@ -117,11 +117,6 @@ namespace AZ::ShaderCompiler
             const QualifiedNameView iteratedSymbolName = iteratedSymbolUid.GetName();
             const Kind iteratedSymbolKind = m_ir->GetKind(iteratedSymbolUid);
 
-            if (IsTopLevelThroughTranslation(iteratedSymbolUid))
-            {
-                EmitPreprocessorLineDirective(iteratedSymbolName);
-            }
-
             switch (iteratedSymbolKind)
             {
                 // top-level enums, structs and classes, as well as immediate-type-declaration enum/structs (`struct S{} s;`)
@@ -132,6 +127,8 @@ namespace AZ::ShaderCompiler
             {
                 if (IsTopLevelThroughTranslation(iteratedSymbolUid))
                 {
+                    EmitPreprocessorLineDirective(iteratedSymbolName);
+
                     auto* classInfo = m_ir->GetSymbolSubAs<ClassInfo>(iteratedSymbolName);
                     iteratedSymbolKind == Kind::Enum ?
                           EmitEnum(iteratedSymbolUid, *classInfo, options)
@@ -144,6 +141,8 @@ namespace AZ::ShaderCompiler
             {
                 if (IsTopLevelThroughTranslation(iteratedSymbolUid))
                 {
+                    EmitPreprocessorLineDirective(iteratedSymbolName);
+
                     auto* aliasInfo = m_ir->GetSymbolSubAs<TypeAliasInfo>(iteratedSymbolName);
                     EmitTypeAlias(iteratedSymbolUid, *aliasInfo, options);
                 }
@@ -175,6 +174,7 @@ namespace AZ::ShaderCompiler
                         break;
                     }
 
+                    EmitPreprocessorLineDirective(iteratedSymbolName);
                     EmitVariableDeclaration(*varInfo, iteratedSymbolUid, options, VarDeclHasFlag(VarDeclHas::Initializer));
                     m_out << ";\n";
                 }
@@ -183,6 +183,8 @@ namespace AZ::ShaderCompiler
                 // SRG
             case Kind::ShaderResourceGroup:
             {
+                EmitPreprocessorLineDirective(iteratedSymbolName);
+
                 auto* srgSub = m_ir->GetSymbolSubAs<SRGInfo>(iteratedSymbolName);
                 EmitSRG(*srgSub, iteratedSymbolUid, options, rootSig);
                 break;
@@ -190,6 +192,8 @@ namespace AZ::ShaderCompiler
                 // function
             case Kind::Function:
             {
+                EmitPreprocessorLineDirective(iteratedSymbolName);
+
                 auto* funcSub = m_ir->GetSymbolSubAs<FunctionInfo>(iteratedSymbolName);
                 const bool alreadyDeclared = AlreadyEmittedFunctionDeclaration(iteratedSymbolUid);
                 assert(!funcSub->IsEmpty());

+ 1 - 1
src/AzslcMain.cpp

@@ -23,7 +23,7 @@ namespace StdFs = std::filesystem;
 // For large features or milestones. Minor version allows for breaking changes. Existing tests can change.
 #define AZSLC_MINOR "8"   // last change: introduction of class inheritance
 // For small features or bug fixes. They cannot introduce breaking changes. Existing tests shouldn't change.
-#define AZSLC_REVISION "9"  // last change: resource unbounded arrays support
+#define AZSLC_REVISION "12"  // last change: reduce useless sharp-line directives
 
 
 namespace AZ::ShaderCompiler