David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 1 | #
|
| 2 | # Copyright (C) 2016 Valve Corporation
|
| 3 | #
|
| 4 | # Permission is hereby granted, free of charge, to any person obtaining a
|
| 5 | # copy of this software and associated documentation files (the "Software"),
|
| 6 | # to deal in the Software without restriction, including without limitation
|
| 7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
| 8 | # and/or sell copies of the Software, and to permit persons to whom the
|
| 9 | # Software is furnished to do so, subject to the following conditions:
|
| 10 | #
|
| 11 | # The above copyright notice and this permission notice shall be included
|
| 12 | # in all copies or substantial portions of the Software.
|
| 13 | #
|
| 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
| 17 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
| 19 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
| 20 | # DEALINGS IN THE SOFTWARE.
|
| 21 | #
|
| 22 | # Author: David Pinedo <david@LunarG.com>
|
| 23 | #
|
| 24 |
|
| 25 | # This Powershell script is used by the Vulkan Run Time Installer/Uninstaller to:
|
| 26 | # - Copy the most recent vulkan-<majorabi>-*.dll in C:\Windows\System32
|
| 27 | # to vulkan-<majorabi>.dll
|
| 28 | # - Copy the most recent version of vulkaninfo-<abimajor>-*.exe in
|
| 29 | # C:\Windows\System32 to vulkaninfo.exe
|
| 30 | # - Set the layer registry entries to point to the layer json files
|
| 31 | # in the Vulkan SDK associated with the most recent vulkan*dll.
|
| 32 | #
|
| 33 | # This script takes one parameter - a single number specifying the major abi version.
|
| 34 | #
|
| 35 |
|
| 36 | Param([string]$majorabi)
|
| 37 |
|
| 38 | $vulkandll = "vulkan-"+$majorabi+".dll"
|
| 39 |
|
| 40 | # The name of the versioned vulkan dll file is one of the following:
|
| 41 | #
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 42 | # vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>-<prerelease>-<prebuildno>
|
| 43 | # vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>-<prerelease>
|
| 44 | # vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>-<prebuildno>
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 45 | # vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>.dll
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 46 | #
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 47 | # <major>, <minor>, <patch>, <buildno> and <prebuildno> are 1 to 10 numeric digits.
|
| 48 | # <prerelease> is any combination of alpha and numeric characters.
|
| 49 | # If <prerelease> and/or <prebuildno> are present, this identifies a prerelease,
|
| 50 | # and the vulkan dll file will be considered less recent than one with the same
|
| 51 | # <major>, <minor>, <patch>, <buildno> numbers without the <prerelease> and/or
|
| 52 | # <prebuildno>.
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 53 |
|
| 54 |
|
| 55 | # We first create an array, with one array element for each vulkan-*dll in
|
| 56 | # C:\Windows\System32, with each element containing:
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 57 | # <major>=<minor>=<patch>=<buildno>=<prerelease>=<prebuildno>=
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 58 | # filename
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 59 | # @<major>@<minor>@<patch>@<buildno>@<prerelease>@<prebuildno>@
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 60 | # [Note that the above three lines are one element in the array.]
|
| 61 | # The build identifiers separated by "=" are suitable for sorting, i.e.
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 62 | # expanded to 10 digits with leading 0s. If <prerelease> or <prebuildno> are
|
| 63 | # not specified, "zzzzzzzzzz" is substituted for them, so that they sort
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 64 | # to a position after those that do specify them.
|
| 65 | # The build identifiers separated by "@" are the original values extracted
|
| 66 | # from the file name. They are used later to find the path to the SDK
|
| 67 | # install directory for the given filename.
|
| 68 |
|
Mark Young | a81e608 | 2016-01-15 12:35:39 -0700 | [diff] [blame^] | 69 | function UpdateVulkanSysFolder($dir)
|
| 70 | {
|
| 71 | # Push the current path on the stack and go to $dir
|
| 72 | Push-Location -Path $dir
|
| 73 |
|
| 74 | # Create a list for all the DLLs in the folder
|
| 75 | $VulkanDllList=@()
|
| 76 |
|
| 77 | # Find all DLL objects in this directory
|
| 78 | dir -name vulkan-$majorabi-*.dll |
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 79 | ForEach-Object {
|
| 80 | $major=$_.Split('-')[2]
|
| 81 | $majorOrig=$major
|
| 82 | $minor=$_.Split('-')[3]
|
| 83 | $minorOrig=$minor
|
| 84 | $patch=$_.Split('-')[4]
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 85 | $patchOrig=$patch
|
| 86 | $buildno=$_.Split('-')[5]
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 87 |
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 88 | if ($buildno -match ".dll") {
|
| 89 | # <prerelease> and <prebuildno> are not in the name
|
| 90 | $buildno=$buildno -replace ".dll",""
|
| 91 | $buildnoOrig=$buildno
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 92 | $prerelease="z"*10
|
| 93 | $prereleaseOrig=""
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 94 | $prebuildno="z"*10
|
| 95 | $prebuildnoOrig=""
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 96 | } else {
|
| 97 |
|
| 98 | # We assume we don't have more than 5 dashes
|
| 99 |
|
| 100 | $f=$_ -replace ".dll",""
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 101 | $buildno=$f.Split('-')[5]
|
David Pinedo | 5da20dd | 2016-01-13 16:22:19 -0700 | [diff] [blame] | 102 | $buildnoOrig=$buildno
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 103 | $prerelease=$f.Split('-')[6]
|
| 104 | $prebuildno=$f.Split('-')[7]
|
| 105 | if ($prebuildno.Length -eq 0) {
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 106 | if ($prerelease -match "^[0-9]") {
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 107 | # prerelease starts with a digit, it must be the prebuildno
|
| 108 | $prebuildno=$prerelease
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 109 | $prerelease=""
|
| 110 | }
|
| 111 | }
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 112 | $prereleaseOrig=$prerelease
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 113 | $prebuildnoOrig=$prebuildno
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 114 |
|
| 115 | if ($prerelease.Length -eq 0) {
|
| 116 | $prerelease="z"*10
|
| 117 | }
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 118 | if ($prebuildno.Length -eq 0) {
|
| 119 | $prebuildno="z"*10
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 120 | }
|
| 121 | }
|
| 122 |
|
| 123 | $major = $major.padleft(10,'0')
|
| 124 | $minor = $minor.padleft(10,'0')
|
| 125 | $patch = $patch.padleft(10,'0')
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 126 | $buildno = $buildno.padleft(10,'0')
|
David Pinedo | 3bdbe5d | 2016-01-12 16:14:53 -0700 | [diff] [blame] | 127 | $prerelease = $prerelease.padleft(10,'0')
|
| 128 | $prebuildno = $prebuildno.padleft(10,'0')
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 129 |
|
| 130 | # Add a new element to the $VulkanDllList array
|
David Pinedo | 5da20dd | 2016-01-13 16:22:19 -0700 | [diff] [blame] | 131 | $VulkanDllList+="$major=$minor=$patch=$buildno=$prerelease=$prebuildno= $_ @$majorOrig@$minorOrig@$patchOrig@$buildnoOrig@$prereleaseOrig@$prebuildnoOrig@"
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 132 | }
|
| 133 |
|
Mark Young | a81e608 | 2016-01-15 12:35:39 -0700 | [diff] [blame^] | 134 | # If $VulkanDllList contains at least one element, there's at least one vulkan*.dll file.
|
| 135 | # Copy the most recent vulkan*.dll (named in the last element of $VulkanDllList) to vulkan-$majorabi.dll.
|
| 136 | # TODO: In the future, also copy the corresponding vulkaninfo-*.exe to vulkaninfo.exe.
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 137 |
|
Mark Young | a81e608 | 2016-01-15 12:35:39 -0700 | [diff] [blame^] | 138 | if ($VulkanDllList.Length -gt 0) {
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 139 |
|
Mark Young | a81e608 | 2016-01-15 12:35:39 -0700 | [diff] [blame^] | 140 | # Sort the list. The most recent vulkan-*.dll will be in the last element of the list.
|
| 141 | [array]::sort($VulkanDllList)
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 142 |
|
Mark Young | a81e608 | 2016-01-15 12:35:39 -0700 | [diff] [blame^] | 143 | # Put the name of the most recent vulkan-*.dll in $mrVulkanDLL.
|
| 144 | # The most recent vulkanDLL is the second word in the last element of the
|
| 145 | # sorted $VulkanDllList. Copy it to $vulkandll.
|
| 146 | $mrVulkanDll=$VulkanDllList[-1].Split(' ')[1]
|
| 147 | copy $mrVulkanDll $vulkandll
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 148 |
|
Mark Young | a81e608 | 2016-01-15 12:35:39 -0700 | [diff] [blame^] | 149 | # Copy the most recent version of vulkaninfo-<abimajor>-*.exe to vulkaninfo.exe.
|
| 150 | # We create the source file name for the copy from $mrVulkanDll.
|
| 151 | $mrVulkaninfo=$mrVulkanDll -replace ".dll",".exe"
|
| 152 | $mrVulkaninfo=$mrVulkaninfo -replace "vulkan","vulkaninfo"
|
| 153 | copy $mrVulkaninfo vulkaninfo.exe
|
| 154 |
|
| 155 | # Create the name used in the registry for the SDK associated with $mrVulkanDll.
|
| 156 | $major=$VulkanDLLList[-1].Split('@')[1]
|
| 157 | $minor=$VulkanDLLList[-1].Split('@')[2]
|
| 158 | $patch=$VulkanDLLList[-1].Split('@')[3]
|
| 159 | $buildno=$VulkanDLLList[-1].Split('@')[4]
|
| 160 | $prerelease=$VulkanDLLList[-1].Split('@')[5]
|
| 161 | $prebuildno=$VulkanDLLList[-1].Split('@')[6]
|
| 162 | $sdkname="VulkanSDK"+$major + "." + $minor + "." + $patch + "." + $buildno
|
| 163 | if ($prerelease -ne "") {
|
| 164 | $sdkname=$sdkname + "." + $prerelease
|
| 165 | }
|
| 166 | if ($prebuildno -ne "") {
|
| 167 | $sdkname=$sdkname + "." + $prebuildno
|
| 168 | }
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 169 | }
|
Mark Young | a81e608 | 2016-01-15 12:35:39 -0700 | [diff] [blame^] | 170 |
|
| 171 | # Return to our previous folder
|
| 172 | Pop-Location
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 173 | }
|
| 174 |
|
Mark Young | a81e608 | 2016-01-15 12:35:39 -0700 | [diff] [blame^] | 175 | # Update the SYSWOW64 and SYSTEM32 Vulkan items
|
| 176 | UpdateVulkanSysFolder c:\WINDOWS\SYSWOW64
|
| 177 | UpdateVulkanSysFolder c:\WINDOWS\SYSTEM32
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 178 |
|
| 179 | # Create an array of vulkan sdk install dirs
|
| 180 |
|
| 181 | $mrVulkanDllInstallDir=""
|
| 182 | $VulkanSdkDirs=@()
|
| 183 | Get-ChildItem -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall |
|
| 184 | ForEach-Object {
|
| 185 | $regkey=$_ -replace ".*\\",""
|
| 186 | if ($_ -match "\\VulkanSDK") {
|
| 187 | # Get the install path from UninstallString
|
| 188 | $tmp=Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$regkey -Name UninstallString
|
| 189 | $tmp=$tmp -replace "\\Uninstall.exe.*",""
|
| 190 | $tmp=$tmp -replace ".*=.",""
|
| 191 | $VulkanSdkDirs+=$tmp
|
| 192 | if ($regkey -eq $sdkname) {
|
| 193 | # Save away the sdk install dir for the the most recent vulkandll
|
| 194 | $mrVulkanDllInstallDir=$tmp
|
| 195 | }
|
| 196 | }
|
| 197 | }
|
| 198 |
|
| 199 | # Add C:\Vulkan\SDK\0.9.3 to list of SDK install dirs.
|
| 200 | # We do this because there is in a bug in SDK 0.9.3 in which layer
|
| 201 | # reg entries were not removed on uninstall. So we'll try to clean up
|
| 202 | # and remove them now.
|
| 203 | # This works only if 0.9.3 was installed to the default location.
|
| 204 | # If it was not installed to the default location, those entries will
|
| 205 | # need to be cleaned up manually.
|
| 206 |
|
| 207 | $VulkanSdkDirs+="C:\VulkanSDK\0.9.3"
|
| 208 |
|
| 209 |
|
| 210 | # Remove layer registry entries associated with all installed Vulkan SDKs.
|
| 211 | # Note that we remove only those entries created by Vulkan SDKs. If other
|
| 212 | # layers were installed that are not from an SDK, we don't mess with them.
|
| 213 |
|
| 214 | Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\ExplicitLayers | Select-Object -ExpandProperty Property |
|
| 215 | ForEach-Object {
|
| 216 | $regval=$_
|
| 217 | ForEach ($sdkdir in $VulkanSdkDirs) {
|
| 218 | if ($regval -like "$sdkdir\*.json") {
|
David Pinedo | 9bb478f | 2016-01-19 21:19:11 -0700 | [diff] [blame] | 219 | Remove-ItemProperty -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers -name $regval
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 220 | }
|
| 221 | }
|
| 222 | }
|
| 223 |
|
| 224 |
|
| 225 | # Create layer registry entries associated with Vulkan SDK from which $mrVulkanDll is from
|
| 226 |
|
| 227 | if ($mrVulkanDllInstallDir -ne "") {
|
David Pinedo | 9bb478f | 2016-01-19 21:19:11 -0700 | [diff] [blame] | 228 | New-Item -Force -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers | out-null
|
David Pinedo | c21fdb9 | 2016-01-04 16:31:57 -0700 | [diff] [blame] | 229 | Get-ChildItem $mrVulkanDllInstallDir\Bin -Filter *json |
|
| 230 | ForEach-Object {
|
| 231 | New-ItemProperty -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers -Name $mrVulkanDllInstallDir\Bin\$_ -PropertyType DWord -Value 0 | out-null
|
| 232 | }
|
| 233 | }
|