Browse Source

Merge pull request #86 from siliconvoodoo/auto-option-ranks

Fix a crash
siliconvoodoo 1 năm trước cách đây
mục cha
commit
d378fd41bd
2 tập tin đã thay đổi với 7 bổ sung4 xóa
  1. 1 1
      src/AzslcMain.cpp
  2. 6 3
      src/AzslcReflection.cpp

+ 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 "18"  // last change: automatic option ranks
+#define AZSLC_REVISION "19"  // last change: fix crash in option ranks analysis in case of bodiless functions
 
 namespace AZ::ShaderCompiler
 {

+ 6 - 3
src/AzslcReflection.cpp

@@ -1194,9 +1194,12 @@ namespace AZ::ShaderCompiler
                     {
                         verboseCout << " " << concrete << " non-memoized. discovering cost\n";
                         funcInfo->m_costScore = 0;
-                        using AstFDef = azslParser::HlslFunctionDefinitionContext;
-                        AnalyzeImpact(polymorphic_downcast<AstFDef*>(funcInfo->m_defNode->parent)->block(),
-                                      funcInfo->m_costScore);  // recurse and cache
+                        if (funcInfo->m_defNode)  // undefined functions can't be explored
+                        {
+                            using AstFDef = azslParser::HlslFunctionDefinitionContext;
+                            AnalyzeImpact(polymorphic_downcast<AstFDef*>(funcInfo->m_defNode->parent)->block(),
+                                          funcInfo->m_costScore);  // recurse and cache
+                        }
                     }
                     scoreAccumulator += funcInfo->m_costScore;
                     verboseCout << " " << concrete << " cost score " << funcInfo->m_costScore << " added\n";