Skip to content

Commit

Permalink
Fix ShaderModel::Get() when entry does not exist in hashToIdxMap (#4678)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-odonnell-epic committed Sep 21, 2022
1 parent 8b8956f commit 581cc5a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/DXIL/DxilShaderModel.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion utils/hct/hctdb_instrhelp.py
Expand Up @@ -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
Expand Down

0 comments on commit 581cc5a

Please sign in to comment.