MCPcopy Create free account
hub / github.com/LunarG/VulkanTools / LoadVUIDs

Function LoadVUIDs

vkconfig_core/setting_list.cpp:41–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41void LoadVUIDs(std::vector<NumberOrString>& value) {
42 const std::string vulkan_sdk_path(qgetenv("VULKAN_SDK").toStdString());
43 const std::string path = vulkan_sdk_path.empty() ? "/usr" : vulkan_sdk_path;
44
45 QString json_text;
46
47 if (!vulkan_sdk_path.empty() && json_text.isEmpty()) {
48 json_text = ReadAll(vulkan_sdk_path + "/share/vulkan/registry/validusage.json");
49 }
50
51 if (json_text.isEmpty()) {
52 json_text = ReadAll(":/vkconfig/validusage.json");
53 }
54
55 if (json_text.isEmpty()) {
56 return;
57 }
58
59 // Convert the text to a JSON document & validate it.
60 // It does need to be a valid json formatted file.
61 QJsonParseError json_parse_error;
62 const QJsonDocument& json_document = QJsonDocument::fromJson(json_text.toUtf8(), &json_parse_error);
63
64 const QJsonObject& json_root_object = json_document.object();
65 if (json_root_object.value("validation") == QJsonValue::Undefined) {
66 return;
67 }
68
69 const QJsonObject& json_validation_object = json_root_object.value("validation").toObject();
70
71 const QStringList& keys_depth0 = json_validation_object.keys();
72 for (int i = 0, n = keys_depth0.size(); i < n; ++i) {
73 const QJsonValue& value_depth1 = json_validation_object.value(keys_depth0[i]);
74 assert(value_depth1 != QJsonValue::Undefined);
75
76 const QJsonObject& object_depth1 = value_depth1.toObject();
77 const QStringList& keys_depth1 = object_depth1.keys();
78
79 for (int j = 0, o = keys_depth1.size(); j < o; ++j) {
80 const QJsonValue& value_depth2 = object_depth1.value(keys_depth1[j]);
81 assert(value_depth2 != QJsonValue::Undefined);
82
83 const QJsonArray& json_array = value_depth2.toArray();
84 for (int l = 0, q = json_array.size(); l < q; ++l) {
85 const QString vuid_value = json_array[l].toObject().value("vuid").toString();
86
87 NumberOrString data;
88 data.key = vuid_value.toStdString();
89 value.push_back(data);
90 }
91 }
92 }
93}
94
95// SettingMetaList
96

Callers 2

LoadMethod · 0.85
TESTFunction · 0.85

Calls 1

ReadAllFunction · 0.85

Tested by 1

TESTFunction · 0.68