@@ -1293,7 +1293,7 @@ def get_num_shader_models():
1293
1293
1294
1294
def build_shader_model_hash_idx_map ():
1295
1295
#must match get_shader_models.
1296
- result = "const static std::unordered_map <unsigned, unsigned> hashToIdxMap = {\n "
1296
+ result = "const static std::pair <unsigned, unsigned> hashToIdxMap[] = {\n "
1297
1297
count = 0
1298
1298
for profile in shader_profiles :
1299
1299
min_sm = profile .start_sm
@@ -1386,11 +1386,12 @@ def get_dxil_version():
1386
1386
return result
1387
1387
1388
1388
def get_shader_model_get ():
1389
- # const static std::unordered_map <unsigned, unsigned> hashToIdxMap = {};
1389
+ # const static std::pair <unsigned, unsigned> hashToIdxMap[] = {};
1390
1390
result = build_shader_model_hash_idx_map ()
1391
1391
result += "unsigned hash = (unsigned)Kind << 16 | Major << 8 | Minor;\n "
1392
- result += "auto it = hashToIdxMap.find(hash);\n "
1393
- result += "if (it == hashToIdxMap.end())\n "
1392
+ result += "auto pred = [](const std::pair<unsigned, unsigned>& elem, unsigned val){ return elem.first < val;};\n "
1393
+ result += "auto it = std::lower_bound(std::begin(hashToIdxMap), std::end(hashToIdxMap), hash, pred);\n "
1394
+ result += "if (it == std::end(hashToIdxMap))\n "
1394
1395
result += " return GetInvalid();\n "
1395
1396
result += "return &ms_ShaderModels[it->second];"
1396
1397
return result
0 commit comments