Browse Source

Fix ShaderModel::Get() when entry does not exist in hashToIdxMap (#4678)

Yuriy O'Donnell 3 years ago
parent
commit
581cc5aee6
2 changed files with 2 additions and 2 deletions
  1. 1 1
      lib/DXIL/DxilShaderModel.cpp
  2. 1 1
      utils/hct/hctdb_instrhelp.py

+ 1 - 1
lib/DXIL/DxilShaderModel.cpp

@@ -171,7 +171,7 @@ const ShaderModel *ShaderModel::Get(Kind Kind, unsigned Major, unsigned Minor) {
   unsigned hash = (unsigned)Kind << 16 | Major << 8 | Minor;
   auto pred = [](const std::pair<unsigned, unsigned>& elem, unsigned val){ return elem.first < val;};
   auto it = std::lower_bound(std::begin(hashToIdxMap), std::end(hashToIdxMap), hash, pred);
-  if (it == std::end(hashToIdxMap))
+  if (it == std::end(hashToIdxMap) || it->first != hash)
     return GetInvalid();
   return &ms_ShaderModels[it->second];
   // VALRULE-TEXT:END

+ 1 - 1
utils/hct/hctdb_instrhelp.py

@@ -1391,7 +1391,7 @@ def get_shader_model_get():
     result += "unsigned hash = (unsigned)Kind << 16 | Major << 8 | Minor;\n"
     result += "auto pred = [](const std::pair<unsigned, unsigned>& elem, unsigned val){ return elem.first < val;};\n"
     result += "auto it = std::lower_bound(std::begin(hashToIdxMap), std::end(hashToIdxMap), hash, pred);\n"
-    result += "if (it == std::end(hashToIdxMap))\n"
+    result += "if (it == std::end(hashToIdxMap) || it->first != hash)\n"
     result += "  return GetInvalid();\n"
     result += "return &ms_ShaderModels[it->second];"
     return result