瀏覽代碼

Output the cost to JSON

Signed-off-by: Vivien Oddou <[email protected]>
Vivien Oddou 2 年之前
父節點
當前提交
8d2ed81a7a
共有 3 個文件被更改,包括 4 次插入2 次删除
  1. 1 0
      src/AzslcBackend.cpp
  2. 1 0
      src/AzslcKindInfo.h
  3. 2 2
      src/AzslcReflection.cpp

+ 1 - 0
src/AzslcBackend.cpp

@@ -449,6 +449,7 @@ namespace AZ::ShaderCompiler
             // We reserve the right to change it in the future so we make it explicit attribute here
             shaderOption["order"] = optionOrder;
             optionOrder++;
+            shaderOption["costImpact"] = varInfo->m_estimatedCostImpact;
 
             bool isUdt = IsUserDefined(varInfo->GetTypeClass());
             assert(isUdt || IsPredefinedType(varInfo->GetTypeClass()));

+ 1 - 0
src/AzslcKindInfo.h

@@ -399,6 +399,7 @@ namespace AZ::ShaderCompiler
         ConstNumericVal            m_constVal;   // (attempted folded) initializer value for simple scalars
         optional<SamplerStateDesc> m_samplerState;
         ExtendedTypeInfo           m_typeInfoExt;
+        int                        m_estimatedCostImpact = -1;  //!< Cached value calculated by AnalyzeOptionRanks
     };
 
     // VarInfo methods definitions

+ 2 - 2
src/AzslcReflection.cpp

@@ -629,9 +629,9 @@ namespace AZ::ShaderCompiler
 
     void CodeReflection::DumpVariantList(const Options& options) const
     {
+        AnalyzeOptionRanks();
         m_out << GetVariantList(options);
         m_out << "\n";
-        AnalyzeOptionRanks();
     }
 
     static void ReflectBinding(Json::Value& output, const RootSigDesc::SrgParamDesc& bindInfo)
@@ -1060,7 +1060,7 @@ namespace AZ::ShaderCompiler
                     impactScore += AnalyzeImpact(ref.m_where)  // dependent code that may be skipped depending on the value of that ref
                         + 1;  // by virtue of being mentioned (seenat), we count the reference as an access of cost 1.
                 }
-                m_out << "Option " << uid.GetName() << " has impact " << impactScore << "\n";
+                varInfo->m_estimatedCostImpact = impactScore;
             }
         }
     }