Created
December 31, 2020 21:41
-
-
Save Ed94/e98e5fd2a8ef38965fb5e2d7927358f0 to your computer and use it in GitHub Desktop.
Scoop Vulkan [Windows]: Fix registry entires for ExplicitLayers Key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ctypes; # Allows interface with low-level C API's. | |
| import os; | |
| import platform; | |
| import sys; | |
| import winreg; # Allows access to the windows registry. | |
| LocalComputer = None; | |
| RootKey_LocalMachine = None; | |
| Subkey_ImplicitLayers_Name = "ImplicitLayers"; | |
| Subkey_ImplicitLayers_Path = "Software\Khronos\Vulkan\ImplicitLayers"; | |
| Subkey_ImplicitLayers = None; | |
| Subkey_ExplicitLayers_Name = "ExplicitLayers"; | |
| Subkey_ExplicitLayers_Path = "Software\Khronos\Vulkan\ExplicitLayers"; | |
| Subkey_ExplicitLayers = None; | |
| Vulkan_EnvVar = "VULKAN_SDK"; | |
| Vulkan_Bin_Path = None; | |
| VK_Layer_Token = "VkLayer"; | |
| def is_os_64bit(): | |
| return platform.machine().endswith('64') | |
| def FixThisShit() : | |
| print("Fixing Vulkan Explicit Layers registry entries because your SDK / Driver installation may have failed to do so...\n"); | |
| RootKey_LocalMachine = winreg.ConnectRegistry(LocalComputer, winreg.HKEY_LOCAL_MACHINE); # Get the hkey for this garbo. | |
| print("Root Key: Local Machine Handle: " + str(RootKey_LocalMachine)); | |
| Subkey_ExplicitLayers = winreg.OpenKey(RootKey_LocalMachine, Subkey_ExplicitLayers_Path, 0, winreg.KEY_ALL_ACCESS) # Get the explicit layers key. | |
| print("Subkey Khronos / Vulkan / Explicit Layers, Handle: " + str(Subkey_ExplicitLayers)); | |
| Subkey_ExplicitLayer_ValueCount = winreg.QueryInfoKey(Subkey_ExplicitLayers)[1]; | |
| print("Number of currently defined values: " + str(Subkey_ExplicitLayer_ValueCount)); | |
| for index in range (Subkey_ExplicitLayer_ValueCount) : | |
| try : | |
| value = winreg.EnumKey(Subkey_ExplicitLayers, index); | |
| print(value); | |
| except : | |
| break; | |
| if (is_os_64bit()) : | |
| Vulkan_Bin_Path = os.environ[Vulkan_EnvVar] + "\Bin"; | |
| else : | |
| Vulkan_Bin_Path = os.environ[Vulkan_EnvVar] + "\Bin32"; | |
| directoryListing = os.scandir(Vulkan_Bin_Path); | |
| print(); print("Vulkan Bin Path: " + Vulkan_Bin_Path); | |
| print(); print("VK Layer files found: \n"); | |
| for entry in directoryListing : | |
| if (entry.is_file() and VK_Layer_Token in entry.name and ".json" in entry.name) : | |
| print(entry); | |
| if (Subkey_ExplicitLayer_ValueCount > 0) : | |
| print("Checking if found in explict layers..."); | |
| foundEntryInRegistry = False; | |
| for index in range (Subkey_ExplicitLayer_ValueCount) : | |
| try : | |
| value = winreg.EnumValue(Subkey_ExplicitLayers, index); | |
| if (entry.name in value[0]) : | |
| foundEntryInRegistry = True; | |
| print("Found."); | |
| except : | |
| print("Failed to get value inside of registry key."); | |
| break; | |
| if (not foundEntryInRegistry) : | |
| try : | |
| print("Did not find layer in the registry key. Adding..."); | |
| winreg.SetValueEx(Subkey_ExplicitLayers, entry.path, 0, winreg.REG_DWORD, "0"); | |
| except : | |
| print("Failed to add layer to the registry key."); | |
| break; | |
| else : | |
| print("Adding layer path to registry key..."); | |
| winreg.SetValueEx(Subkey_ExplicitLayers, str(entry.path), 0, winreg.REG_DWORD, 0); | |
| if __name__ == "__main__" : | |
| FixThisShit(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://i.imgur.com/0o7ZkCJ.png