blob: ad31cd294becd97df56c1704dcb927263139632f [file] [log] [blame]
David Pinedo1e368f72016-02-04 17:04:44 -07001# Copyright (c) 2015-2016 The Khronos Group Inc.
2# Copyright (c) 2015-2016 Valve Corporation
3# Copyright (c) 2015-2016 LunarG, Inc.
David Pinedoc21fdb92016-01-04 16:31:57 -07004#
David Pinedo1e368f72016-02-04 17:04:44 -07005# Permission is hereby granted, free of charge, to any person obtaining a copy
6# of this software and/or associated documentation files (the "Materials"), to
7# deal in the Materials without restriction, including without limitation the
8# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9# sell copies of the Materials, and to permit persons to whom the Materials are
10# furnished to do so, subject to the following conditions:
David Pinedoc21fdb92016-01-04 16:31:57 -070011#
David Pinedo1e368f72016-02-04 17:04:44 -070012# The above copyright notice(s) and this permission notice shall be included in
13# all copies or substantial portions of the Materials.
David Pinedoc21fdb92016-01-04 16:31:57 -070014#
David Pinedo1e368f72016-02-04 17:04:44 -070015# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
David Pinedoc21fdb92016-01-04 16:31:57 -070016# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
David Pinedo1e368f72016-02-04 17:04:44 -070017# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18#
19# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
22# USE OR OTHER DEALINGS IN THE MATERIALS.
David Pinedoc21fdb92016-01-04 16:31:57 -070023#
24# Author: David Pinedo <david@LunarG.com>
David Pinedo1e368f72016-02-04 17:04:44 -070025# Author: Mark Young <mark@LunarG.com>
David Pinedoc21fdb92016-01-04 16:31:57 -070026#
27
David Pinedo1e368f72016-02-04 17:04:44 -070028
David Pinedoc21fdb92016-01-04 16:31:57 -070029# This Powershell script is used by the Vulkan Run Time Installer/Uninstaller to:
30# - Copy the most recent vulkan-<majorabi>-*.dll in C:\Windows\System32
31# to vulkan-<majorabi>.dll
32# - Copy the most recent version of vulkaninfo-<abimajor>-*.exe in
33# C:\Windows\System32 to vulkaninfo.exe
Mark Young4b8b5482016-01-15 15:09:39 -070034# - The same thing is done for those files in C:\Windows\SysWOW64 on a 64-bit
35# target.
David Pinedoc21fdb92016-01-04 16:31:57 -070036# - Set the layer registry entries to point to the layer json files
37# in the Vulkan SDK associated with the most recent vulkan*dll.
38#
Mark Youngaf87f222016-01-20 16:33:18 -070039# This script takes the following parameters:
Mark Young4b8b5482016-01-15 15:09:39 -070040# $majorabi : a single string number specifying the major abi version.
Mark Youngaf87f222016-01-20 16:33:18 -070041# $ossize : an integer indicating if the target is a 64 (64) or 32 (32) bit OS.
David Pinedoc21fdb92016-01-04 16:31:57 -070042#
43
Mark Young4b8b5482016-01-15 15:09:39 -070044Param(
45 [string]$majorabi,
46 [int]$ossize
47)
David Pinedoc21fdb92016-01-04 16:31:57 -070048
49$vulkandll = "vulkan-"+$majorabi+".dll"
Mark Young71e2a402016-02-12 12:07:45 -070050$windrive = $env:SYSTEMDRIVE
51$winfolder = $env:SYSTEMROOT
David Pinedoc21fdb92016-01-04 16:31:57 -070052
53# The name of the versioned vulkan dll file is one of the following:
54#
David Pinedo3bdbe5d2016-01-12 16:14:53 -070055# vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>-<prerelease>-<prebuildno>
56# vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>-<prerelease>
57# vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>-<prebuildno>
David Pinedoc21fdb92016-01-04 16:31:57 -070058# vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>.dll
David Pinedoc21fdb92016-01-04 16:31:57 -070059#
David Pinedo3bdbe5d2016-01-12 16:14:53 -070060# <major>, <minor>, <patch>, <buildno> and <prebuildno> are 1 to 10 numeric digits.
61# <prerelease> is any combination of alpha and numeric characters.
62# If <prerelease> and/or <prebuildno> are present, this identifies a prerelease,
63# and the vulkan dll file will be considered less recent than one with the same
64# <major>, <minor>, <patch>, <buildno> numbers without the <prerelease> and/or
65# <prebuildno>.
David Pinedoc21fdb92016-01-04 16:31:57 -070066
67
68# We first create an array, with one array element for each vulkan-*dll in
Mark Young4b8b5482016-01-15 15:09:39 -070069# C:\Windows\System32 (and C:\Windows\SysWOW64 on 64-bit systems), with each element
70# containing:
David Pinedo3bdbe5d2016-01-12 16:14:53 -070071# <major>=<minor>=<patch>=<buildno>=<prerelease>=<prebuildno>=
David Pinedoc21fdb92016-01-04 16:31:57 -070072# filename
David Pinedo3bdbe5d2016-01-12 16:14:53 -070073# @<major>@<minor>@<patch>@<buildno>@<prerelease>@<prebuildno>@
David Pinedoc21fdb92016-01-04 16:31:57 -070074# [Note that the above three lines are one element in the array.]
75# The build identifiers separated by "=" are suitable for sorting, i.e.
David Pinedo3bdbe5d2016-01-12 16:14:53 -070076# expanded to 10 digits with leading 0s. If <prerelease> or <prebuildno> are
77# not specified, "zzzzzzzzzz" is substituted for them, so that they sort
David Pinedoc21fdb92016-01-04 16:31:57 -070078# to a position after those that do specify them.
79# The build identifiers separated by "@" are the original values extracted
80# from the file name. They are used later to find the path to the SDK
81# install directory for the given filename.
82
Mark Youngd6897a32016-01-20 14:48:21 -070083function UpdateVulkanSysFolder([string]$dir, [int]$writeSdkName)
Mark Younga81e6082016-01-15 12:35:39 -070084{
85 # Push the current path on the stack and go to $dir
86 Push-Location -Path $dir
David Pinedo1e368f72016-02-04 17:04:44 -070087
Mark Younga81e6082016-01-15 12:35:39 -070088 # Create a list for all the DLLs in the folder
89 $VulkanDllList=@()
David Pinedo1e368f72016-02-04 17:04:44 -070090
Mark Younga81e6082016-01-15 12:35:39 -070091 # Find all DLL objects in this directory
92 dir -name vulkan-$majorabi-*.dll |
David Pinedoc21fdb92016-01-04 16:31:57 -070093 ForEach-Object {
94 $major=$_.Split('-')[2]
95 $majorOrig=$major
96 $minor=$_.Split('-')[3]
97 $minorOrig=$minor
98 $patch=$_.Split('-')[4]
David Pinedo3bdbe5d2016-01-12 16:14:53 -070099 $patchOrig=$patch
100 $buildno=$_.Split('-')[5]
David Pinedoc21fdb92016-01-04 16:31:57 -0700101
David Pinedo3bdbe5d2016-01-12 16:14:53 -0700102 if ($buildno -match ".dll") {
103 # <prerelease> and <prebuildno> are not in the name
104 $buildno=$buildno -replace ".dll",""
105 $buildnoOrig=$buildno
David Pinedoc21fdb92016-01-04 16:31:57 -0700106 $prerelease="z"*10
107 $prereleaseOrig=""
David Pinedo3bdbe5d2016-01-12 16:14:53 -0700108 $prebuildno="z"*10
109 $prebuildnoOrig=""
David Pinedoc21fdb92016-01-04 16:31:57 -0700110 } else {
111
112 # We assume we don't have more than 5 dashes
113
114 $f=$_ -replace ".dll",""
David Pinedo3bdbe5d2016-01-12 16:14:53 -0700115 $buildno=$f.Split('-')[5]
David Pinedo5da20dd2016-01-13 16:22:19 -0700116 $buildnoOrig=$buildno
David Pinedo3bdbe5d2016-01-12 16:14:53 -0700117 $prerelease=$f.Split('-')[6]
118 $prebuildno=$f.Split('-')[7]
119 if ($prebuildno.Length -eq 0) {
David Pinedoc21fdb92016-01-04 16:31:57 -0700120 if ($prerelease -match "^[0-9]") {
David Pinedo3bdbe5d2016-01-12 16:14:53 -0700121 # prerelease starts with a digit, it must be the prebuildno
122 $prebuildno=$prerelease
David Pinedoc21fdb92016-01-04 16:31:57 -0700123 $prerelease=""
124 }
125 }
David Pinedoc21fdb92016-01-04 16:31:57 -0700126 $prereleaseOrig=$prerelease
David Pinedo3bdbe5d2016-01-12 16:14:53 -0700127 $prebuildnoOrig=$prebuildno
David Pinedoc21fdb92016-01-04 16:31:57 -0700128
129 if ($prerelease.Length -eq 0) {
130 $prerelease="z"*10
131 }
David Pinedo3bdbe5d2016-01-12 16:14:53 -0700132 if ($prebuildno.Length -eq 0) {
133 $prebuildno="z"*10
David Pinedoc21fdb92016-01-04 16:31:57 -0700134 }
135 }
136
137 $major = $major.padleft(10,'0')
138 $minor = $minor.padleft(10,'0')
139 $patch = $patch.padleft(10,'0')
David Pinedoc21fdb92016-01-04 16:31:57 -0700140 $buildno = $buildno.padleft(10,'0')
David Pinedo3bdbe5d2016-01-12 16:14:53 -0700141 $prerelease = $prerelease.padleft(10,'0')
142 $prebuildno = $prebuildno.padleft(10,'0')
David Pinedoc21fdb92016-01-04 16:31:57 -0700143
144 # Add a new element to the $VulkanDllList array
David Pinedo5da20dd2016-01-13 16:22:19 -0700145 $VulkanDllList+="$major=$minor=$patch=$buildno=$prerelease=$prebuildno= $_ @$majorOrig@$minorOrig@$patchOrig@$buildnoOrig@$prereleaseOrig@$prebuildnoOrig@"
David Pinedoc21fdb92016-01-04 16:31:57 -0700146 }
147
Mark Younga81e6082016-01-15 12:35:39 -0700148 # If $VulkanDllList contains at least one element, there's at least one vulkan*.dll file.
149 # Copy the most recent vulkan*.dll (named in the last element of $VulkanDllList) to vulkan-$majorabi.dll.
150 # TODO: In the future, also copy the corresponding vulkaninfo-*.exe to vulkaninfo.exe.
David Pinedoc21fdb92016-01-04 16:31:57 -0700151
Mark Younga81e6082016-01-15 12:35:39 -0700152 if ($VulkanDllList.Length -gt 0) {
David Pinedoc21fdb92016-01-04 16:31:57 -0700153
Mark Younga81e6082016-01-15 12:35:39 -0700154 # Sort the list. The most recent vulkan-*.dll will be in the last element of the list.
155 [array]::sort($VulkanDllList)
David Pinedoc21fdb92016-01-04 16:31:57 -0700156
Mark Younga81e6082016-01-15 12:35:39 -0700157 # Put the name of the most recent vulkan-*.dll in $mrVulkanDLL.
158 # The most recent vulkanDLL is the second word in the last element of the
159 # sorted $VulkanDllList. Copy it to $vulkandll.
160 $mrVulkanDll=$VulkanDllList[-1].Split(' ')[1]
161 copy $mrVulkanDll $vulkandll
David Pinedoc21fdb92016-01-04 16:31:57 -0700162
Mark Younga81e6082016-01-15 12:35:39 -0700163 # Copy the most recent version of vulkaninfo-<abimajor>-*.exe to vulkaninfo.exe.
164 # We create the source file name for the copy from $mrVulkanDll.
165 $mrVulkaninfo=$mrVulkanDll -replace ".dll",".exe"
166 $mrVulkaninfo=$mrVulkaninfo -replace "vulkan","vulkaninfo"
167 copy $mrVulkaninfo vulkaninfo.exe
David Pinedo1e368f72016-02-04 17:04:44 -0700168
Mark Younga81e6082016-01-15 12:35:39 -0700169 # Create the name used in the registry for the SDK associated with $mrVulkanDll.
170 $major=$VulkanDLLList[-1].Split('@')[1]
171 $minor=$VulkanDLLList[-1].Split('@')[2]
172 $patch=$VulkanDLLList[-1].Split('@')[3]
173 $buildno=$VulkanDLLList[-1].Split('@')[4]
174 $prerelease=$VulkanDLLList[-1].Split('@')[5]
175 $prebuildno=$VulkanDLLList[-1].Split('@')[6]
David Pinedo1e368f72016-02-04 17:04:44 -0700176
Mark Youngd6897a32016-01-20 14:48:21 -0700177 $sdktempname="VulkanSDK"+$major + "." + $minor + "." + $patch + "." + $buildno
Mark Younga81e6082016-01-15 12:35:39 -0700178 if ($prerelease -ne "") {
Mark Youngd6897a32016-01-20 14:48:21 -0700179 $sdktempname=$sdktempname + "." + $prerelease
Mark Younga81e6082016-01-15 12:35:39 -0700180 }
181 if ($prebuildno -ne "") {
Mark Youngd6897a32016-01-20 14:48:21 -0700182 $sdktempname=$sdktempname + "." + $prebuildno
Mark Younga81e6082016-01-15 12:35:39 -0700183 }
David Pinedoc21fdb92016-01-04 16:31:57 -0700184 }
David Pinedo1e368f72016-02-04 17:04:44 -0700185
Mark Youngd6897a32016-01-20 14:48:21 -0700186 # Return to our previous folder
187 Pop-Location
188
189 # Only update the overall script-scope SDK name if we're told to
190 if ($writeSdkName -ne 0) {
191 $script:sdkname = $sdktempname
192 }
193
194 return
David Pinedoc21fdb92016-01-04 16:31:57 -0700195}
196
Mark Young4b8b5482016-01-15 15:09:39 -0700197# We only care about SYSWOW64 if we're targeting a 64-bit OS
Mark Youngb628d162016-01-19 15:29:34 -0700198if ($ossize -eq 64) {
Mark Young4b8b5482016-01-15 15:09:39 -0700199 # Update the SYSWOW64 Vulkan DLLS/EXEs
Mark Young71e2a402016-02-12 12:07:45 -0700200 UpdateVulkanSysFolder $winfolder\SYSWOW64 0
Mark Young4b8b5482016-01-15 15:09:39 -0700201}
202
203# Update the SYSTEM32 Vulkan DLLS/EXEs
Mark Young71e2a402016-02-12 12:07:45 -0700204UpdateVulkanSysFolder $winfolder\SYSTEM32 1
David Pinedoc21fdb92016-01-04 16:31:57 -0700205
206# Create an array of vulkan sdk install dirs
207
208$mrVulkanDllInstallDir=""
209$VulkanSdkDirs=@()
David Pinedo1e368f72016-02-04 17:04:44 -0700210Get-ChildItem -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall |
David Pinedoc21fdb92016-01-04 16:31:57 -0700211 ForEach-Object {
212 $regkey=$_ -replace ".*\\",""
213 if ($_ -match "\\VulkanSDK") {
214 # Get the install path from UninstallString
215 $tmp=Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$regkey -Name UninstallString
216 $tmp=$tmp -replace "\\Uninstall.exe.*",""
217 $tmp=$tmp -replace ".*=.",""
218 $VulkanSdkDirs+=$tmp
Mark Youngd6897a32016-01-20 14:48:21 -0700219 if ($regkey -eq $script:sdkname) {
David Pinedoc21fdb92016-01-04 16:31:57 -0700220 # Save away the sdk install dir for the the most recent vulkandll
221 $mrVulkanDllInstallDir=$tmp
222 }
223 }
224 }
225
226# Add C:\Vulkan\SDK\0.9.3 to list of SDK install dirs.
227# We do this because there is in a bug in SDK 0.9.3 in which layer
228# reg entries were not removed on uninstall. So we'll try to clean up
229# and remove them now.
230# This works only if 0.9.3 was installed to the default location.
231# If it was not installed to the default location, those entries will
232# need to be cleaned up manually.
233
234$VulkanSdkDirs+="C:\VulkanSDK\0.9.3"
Mark Young71e2a402016-02-12 12:07:45 -0700235$VulkanSdkDirs+="$windrive\VulkanSDK\0.9.3"
David Pinedoc21fdb92016-01-04 16:31:57 -0700236
David Pinedoc21fdb92016-01-04 16:31:57 -0700237# Remove layer registry entries associated with all installed Vulkan SDKs.
238# Note that we remove only those entries created by Vulkan SDKs. If other
239# layers were installed that are not from an SDK, we don't mess with them.
240
241Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\ExplicitLayers | Select-Object -ExpandProperty Property |
242 ForEach-Object {
243 $regval=$_
244 ForEach ($sdkdir in $VulkanSdkDirs) {
245 if ($regval -like "$sdkdir\*.json") {
David Pinedo9bb478f2016-01-19 21:19:11 -0700246 Remove-ItemProperty -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers -name $regval
David Pinedoc21fdb92016-01-04 16:31:57 -0700247 }
248 }
249 }
Mark Youngb628d162016-01-19 15:29:34 -0700250# Remove 32-bit layer registry entries if we're targeting a 64-bit OS
251if ($ossize -eq 64) {
252 Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers | Select-Object -ExpandProperty Property |
253 ForEach-Object {
254 $regval=$_
255 ForEach ($sdkdir in $VulkanSdkDirs) {
256 if ($regval -like "$sdkdir\*.json") {
Mark Youngd6897a32016-01-20 14:48:21 -0700257 Remove-ItemProperty -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers -name $regval
Mark Youngb628d162016-01-19 15:29:34 -0700258 }
259 }
260 }
261}
David Pinedoc21fdb92016-01-04 16:31:57 -0700262
263
264# Create layer registry entries associated with Vulkan SDK from which $mrVulkanDll is from
265
266if ($mrVulkanDllInstallDir -ne "") {
Mark Youngb628d162016-01-19 15:29:34 -0700267 if ($ossize -eq 64) {
Mark Young51d35072016-02-09 15:30:34 -0700268
269 # Create registry entires in normal registry location for 64-bit items on a 64-bit OS
270 New-Item -Force -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers | out-null
271 Get-ChildItem $mrVulkanDllInstallDir\Bin -Filter VkLayer*json |
272 ForEach-Object {
273 New-ItemProperty -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers -Name $mrVulkanDllInstallDir\Bin\$_ -PropertyType DWord -Value 0 | out-null
274 }
275
276 # Create registry entires for the WOW6432Node registry location for 32-bit items on a 64-bit OS
277 New-Item -Force -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers | out-null
David Pinedo431b82a2016-02-05 09:48:26 -0700278 Get-ChildItem $mrVulkanDllInstallDir\Bin32 -Filter VkLayer*json |
Mark Youngb628d162016-01-19 15:29:34 -0700279 ForEach-Object {
Mark Youngd6897a32016-01-20 14:48:21 -0700280 New-ItemProperty -Path HKLM:\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers -Name $mrVulkanDllInstallDir\Bin32\$_ -PropertyType DWord -Value 0 | out-null
Mark Youngb628d162016-01-19 15:29:34 -0700281 }
Mark Young51d35072016-02-09 15:30:34 -0700282
283 } else {
284
285 # Create registry entires in normal registry location for 32-bit items on a 32-bit OS
286 New-Item -Force -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers | out-null
287 Get-ChildItem $mrVulkanDllInstallDir\Bin32 -Filter VkLayer*json |
288 ForEach-Object {
289 New-ItemProperty -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers -Name $mrVulkanDllInstallDir\Bin32\$_ -PropertyType DWord -Value 0 | out-null
290 }
291
Mark Youngb628d162016-01-19 15:29:34 -0700292 }
David Pinedoc21fdb92016-01-04 16:31:57 -0700293}