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

Function LoadRegistrySystemLayers

vkconfig_core/registry.cpp:118–199  ·  view source on GitHub ↗

This is for Windows only. It looks for device specific layers in the Windows registry.

Source from the content-addressed store, hash-verified

116
117/// This is for Windows only. It looks for device specific layers in the Windows registry.
118std::vector<Path> LoadRegistrySystemLayers(const char *input_path) {
119 std::vector<Path> layers_paths;
120
121 QString path(input_path);
122
123 QString root_string = path.section('\\', 0, 0);
124 static QHash<QString, HKEY> root_keys = {
125 {"HKEY_CLASSES_ROOT", HKEY_CLASSES_ROOT},
126 {"HKEY_CURRENT_CONFIG", HKEY_CURRENT_CONFIG},
127 {"HKEY_CURRENT_USER", HKEY_CURRENT_USER},
128 {"HKEY_LOCAL_MACHINE", HKEY_LOCAL_MACHINE},
129 {"HKEY_USERS", HKEY_USERS},
130 };
131
132 HKEY root = HKEY_CURRENT_USER;
133 for (auto label : root_keys.keys()) {
134 if (label == root_string) {
135 root = root_keys[label];
136 break;
137 }
138 }
139
140 static const QString DISPLAY_GUID = "{4d36e968-e325-11ce-bfc1-08002be10318}";
141 static const QString SOFTWARE_COMPONENT_GUID = "{5c4c3332-344d-483c-8739-259e934c9cc8}";
142 static const ULONG FLAGS = CM_GETIDLIST_FILTER_CLASS | CM_GETIDLIST_FILTER_PRESENT;
143
144 ULONG device_names_size;
145 wchar_t *device_names = nullptr;
146 do {
147 CM_Get_Device_ID_List_SizeW(&device_names_size, (LPCWSTR)DISPLAY_GUID.utf16(), FLAGS);
148 if (device_names != nullptr) {
149 delete[] device_names;
150 }
151 device_names = new wchar_t[device_names_size];
152 } while (CM_Get_Device_ID_ListW((LPCWSTR)DISPLAY_GUID.utf16(), device_names, device_names_size, FLAGS) == CR_BUFFER_SMALL);
153
154 if (device_names != nullptr) {
155 QString entry;
156 // This has already been set by now
157 if (path.endsWith("VulkanExplicitLayers")) {
158 entry = "VulkanExplicitLayers";
159 // type = LAYER_TYPE_EXPLICIT;
160 } else if (path.endsWith("VulkanImplicitLayers")) {
161 entry = "VulkanImplicitLayers";
162 // type = LAYER_TYPE_IMPLICIT;
163 }
164
165 for (wchar_t *device_name = device_names; device_name[0] != '\0'; device_name += wcslen(device_name) + 1) {
166 DEVINST device_id;
167 if (CM_Locate_DevNodeW(&device_id, device_name, CM_LOCATE_DEVNODE_NORMAL) != CR_SUCCESS) {
168 continue;
169 }
170 LoadDeviceRegistry(device_id, entry, layers_paths);
171
172 DEVINST child_id;
173 if (CM_Get_Child(&child_id, device_id, 0) != CR_SUCCESS) {
174 continue;
175 }

Callers 2

GetImplicitLayerPathsFunction · 0.85
GetExplicitLayerPathsFunction · 0.85

Calls 1

LoadDeviceRegistryFunction · 0.85

Tested by

no test coverage detected