+++ /dev/null
-# Copyright (c) 2015-2016 The Khronos Group Inc.\r
-# Copyright (c) 2015-2016 Valve Corporation\r
-# Copyright (c) 2015-2016 LunarG, Inc.\r
-#\r
-# Licensed under the Apache License, Version 2.0 (the "License");\r
-# you may not use this file except in compliance with the License.\r
-# You may obtain a copy of the License at\r
-#\r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-#\r
-# Unless required by applicable law or agreed to in writing, software\r
-# distributed under the License is distributed on an "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# See the License for the specific language governing permissions and\r
-# limitations under the License.\r
-#\r
-# Author: David Pinedo <david@LunarG.com>\r
-# Author: Mark Young <mark@LunarG.com>\r
-#\r
-\r
-\r
-# This Powershell script is used by the Vulkan Run Time Installer/Uninstaller to:\r
-# - Copy the most recent vulkan-<majorabi>-*.dll in C:\Windows\System32\r
-# to vulkan-<majorabi>.dll\r
-# - Copy the most recent version of vulkaninfo-<abimajor>-*.exe in\r
-# C:\Windows\System32 to vulkaninfo.exe\r
-# - The same thing is done for those files in C:\Windows\SysWOW64 on a 64-bit\r
-# target.\r
-# - Set the layer registry entries to point to the layer json files\r
-# in the Vulkan SDK associated with the most recent vulkan*dll.\r
-#\r
-# This script can be called with the following two parameters:\r
-# $majorabi : a single string number specifying the major abi version.\r
-# $ossize : an integer indicating if the target is a 64 (64) or 32 (32) bit OS.\r
-#\r
-\r
-# majorabi and ossize are either prepended to this script or specificied as args\r
-Param(\r
- [string]$majorabiarg,\r
- [int]$ossizearg\r
-)\r
-if ($majorabi -eq $null) {\r
- $majorabi=$majorabiarg\r
-}\r
-if ($ossize -eq $null) {\r
- $ossize=$ossizearg\r
-}\r
-\r
-function WriteToLog ($x) {\r
- echo $x | Out-File -encoding ascii -append -filepath $script:log\r
-}\r
-\r
-function notNumeric ($x) {\r
- try {\r
- 0 + $x | Out-Null\r
- return $false\r
- } catch {\r
- return $true\r
- }\r
-}\r
-\r
-function setScriptReturnValue($rvalue) {\r
- if ($script:scriptReturnValue -eq 0) {\r
- $script:scriptReturnValue = $rvalue\r
- }\r
-}\r
-\r
-# Clear any pre-existing errors and set default return value\r
-$Error.Clear();\r
-$script:scriptReturnValue=0\r
-\r
-# Start logging\r
-$script:log=$Env:Temp+"\ConfigLayersAndVulkanDLL.log"\r
-Remove-Item $script:log\r
-\r
-# Ignore errors related to log file\r
-$Error.Clear();\r
-\r
-WriteToLog "ConfigLayersAndVulkanDLL.ps1 called with inputs of : $majorabi $ossize"\r
-$startTime=Get-Date\r
-WriteToLog "Start time : $startTime"\r
-WriteToLog "Poweshell Version information:"\r
-WriteToLog $PsVersionTable\r
-\r
-$vulkandll = "vulkan-"+$majorabi+".dll"\r
-$windrive = $env:SYSTEMDRIVE\r
-$winfolder = $env:SYSTEMROOT\r
-$script:VulkanDllList=@()\r
-\r
-# The name of the versioned vulkan dll file is one of the following:\r
-#\r
-# vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>-<prerelease>-<prebuildno>\r
-# vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>-<prerelease>\r
-# vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>-<prebuildno>\r
-# vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>.dll\r
-#\r
-# <major>, <minor>, <patch>, <buildno> and <prebuildno> are 1 to 10 numeric digits.\r
-# <prerelease> is any combination of alpha and numeric characters.\r
-# If <prerelease> and/or <prebuildno> are present, this identifies a prerelease,\r
-# and the vulkan dll file will be considered less recent than one with the same\r
-# <major>, <minor>, <patch>, <buildno> numbers without the <prerelease> and/or\r
-# <prebuildno>.\r
-\r
-\r
-# We first create an array, with one array element for each vulkan-*dll in\r
-# C:\Windows\System32 (and C:\Windows\SysWOW64 on 64-bit systems), with each element\r
-# containing:\r
-# <major>=<minor>=<patch>=<buildno>=<prebuildno>=<prerelease>=\r
-# filename\r
-# @<major>@<minor>@<patch>@<buildno>@<prerelease>@<prebuildno>@\r
-# [Note that the above three lines are one element in the array.]\r
-# The build identifiers separated by "=" are suitable for sorting, i.e.\r
-# expanded to 10 digits with leading 0s. If <prerelease> or <prebuildno> are\r
-# not specified, "zzzzzzzzzz" is substituted for them, so that they sort\r
-# to a position after those that do specify them. Note that <prerelease>\r
-# is "less significant" in the sort than <prebuildno>, and that <prerelease> is\r
-# always treated as an alpha string, even though it may contain numeric characters.\r
-# The build identifiers separated by "@" are the original values extracted\r
-# from the file name. They are used later to find the path to the SDK\r
-# install directory for the given filename.\r
-\r
-\r
-function UpdateVulkanSysFolder([string]$dir, [int]$writeSdkName)\r
-{\r
- WriteToLog "UpdateVulkanSysFolder $dir $writeSdkName"\r
-\r
- # Push the current path on the stack and go to $dir\r
- Push-Location -Path $dir\r
-\r
- # Create a list for all the DLLs in the folder.\r
- # First Initialize the list to empty\r
- $script:VulkanDllList = @()\r
-\r
- # Find all vulkan dll files in this directory\r
- dir -name vulkan-$majorabi-*.dll |\r
- ForEach-Object {\r
- WriteToLog "File $_"\r
- if ($_ -match "=" -or\r
- $_ -match "@" -or\r
- $_ -match " " -or\r
- ($_.Split('-').count -lt 6) -or\r
- ($_.Split('-').count -gt 8) -or\r
- !$?)\r
- {\r
- # If a file name contains "=", "@", or " ", or it contains less then 5 dashes or more than\r
- # 7 dashes, it wasn't installed by the Vulkan Run Time.\r
- # Note that we need to use return inside of ForEach-Object is to continue with iteration.\r
- WriteToLog "Ignoring $_ - bad format"\r
-\r
- # Not a real error, so just clear it for now.\r
- $Error.Clear();\r
-\r
- # NOTE: Inside a ForEach-Object block, the 'return' call behaves like a 'continue' for a For loop\r
- return\r
- }\r
-\r
- # If the corresponding vulkaninfo is not present, it wasn't installed by the Vulkan Run Time\r
- $vulkaninfo=$_ -replace ".dll",".exe"\r
- $vulkaninfo=$vulkaninfo -replace "vulkan","vulkaninfo"\r
- if (-not (Test-Path $vulkaninfo) -or\r
- !$?) {\r
- WriteToLog "Rejected $_ - $vulkaninfo not present"\r
-\r
- # Not a real error, so just clear it for now.\r
- $Error.Clear();\r
-\r
- # NOTE: Inside a ForEach-Object block, the 'return' call behaves like a 'continue' for a For loop\r
- return\r
- }\r
-\r
- $major=$_.Split('-')[2]\r
- $majorOrig=$major\r
- $minor=$_.Split('-')[3]\r
- $minorOrig=$minor\r
- $patch=$_.Split('-')[4]\r
- $patchOrig=$patch\r
- $buildno=$_.Split('-')[5]\r
-\r
- if ($buildno -match ".dll") {\r
- # prerelease and prebuildno are not in the name\r
- # Extract buildno, and set prerelease and prebuildno to "z"s\r
- $buildno=$buildno -replace ".dll",""\r
- $buildnoOrig=$buildno\r
- $prerelease="z"*10\r
- $prereleaseOrig=""\r
- $prebuildno="z"*10\r
- $prebuildnoOrig=""\r
- } else {\r
- # Extract buildno, prerelease, and prebuildno\r
- $f=$_ -replace ".dll",""\r
- $buildno=$f.Split('-')[5]\r
- $buildnoOrig=$buildno\r
- $prerelease=$f.Split('-')[6]\r
- $prebuildno=$f.Split('-')[7]\r
- if ($prebuildno.Length -eq 0) {\r
- if ($prerelease -match "^[0-9]") {\r
- # prerelease starts with a digit, it must be the prebuildno\r
- $prebuildno=$prerelease\r
- $prerelease=""\r
- }\r
- }\r
- $prereleaseOrig=$prerelease\r
- $prebuildnoOrig=$prebuildno\r
-\r
- if ($prerelease.Length -eq 0) {\r
- $prerelease="z"*10\r
- }\r
- if ($prebuildno.Length -eq 0) {\r
- $prebuildno="z"*10\r
- }\r
- }\r
- WriteToLog "Version $majorOrig $minorOrig $patchOrig $buildnoOrig $prereleaseOrig $prebuildnoOrig"\r
- if (!$?) {\r
- WriteToLog "Ignoring version $majorOrig $minorOrig $patchOrig $buildnoOrig $prereleaseOrig $prebuildnoOrig"\r
-\r
- # Not a real error, so just clear it for now.\r
- $Error.Clear();\r
-\r
- # NOTE: Inside a ForEach-Object block, the 'return' call behaves like a 'continue' for a For loop\r
- return\r
- }\r
-\r
- # Make sure fields that are supposed to be numbers are numbers\r
- if (notNumeric($major)) {\r
- WriteToLog "Ignoring $_ - bad major"\r
-\r
- # Not a real error, so just clear it for now.\r
- $Error.Clear();\r
-\r
- # NOTE: Inside a ForEach-Object block, the 'return' call behaves like a 'continue' for a For loop\r
- return\r
- }\r
- if (notNumeric($minor)) {\r
- WriteToLog "Ignoring $_ - bad minor"\r
-\r
- # Not a real error, so just clear it for now.\r
- $Error.Clear();\r
-\r
- # NOTE: Inside a ForEach-Object block, the 'return' call behaves like a 'continue' for a For loop\r
- return\r
- }\r
- if (notNumeric($patch)) {\r
- WriteToLog "Ignoring $_ - bad patch"\r
-\r
- # Not a real error, so just clear it for now.\r
- $Error.Clear();\r
-\r
- # NOTE: Inside a ForEach-Object block, the 'return' call behaves like a 'continue' for a For loop\r
- return\r
- }\r
- if (notNumeric($buildno)) {\r
- WriteToLog "Ignoring $_ - bad buildno"\r
-\r
- # Not a real error, so just clear it for now.\r
- $Error.Clear();\r
-\r
- # NOTE: Inside a ForEach-Object block, the 'return' call behaves like a 'continue' for a For loop\r
- return\r
- }\r
- if (notNumeric($prebuildno)) {\r
- if ($prebuildno -ne "z"*10) {\r
- WriteToLog "Ignoring $_ - bad prebuildno"\r
-\r
- # Not a real error, so just clear it for now.\r
- $Error.Clear();\r
-\r
- # NOTE: Inside a ForEach-Object block, the 'return' call behaves like a 'continue' for a For loop\r
- return\r
- }\r
- }\r
-\r
- $major = $major.padleft(10,'0')\r
- $minor = $minor.padleft(10,'0')\r
- $patch = $patch.padleft(10,'0')\r
- $buildno = $buildno.padleft(10,'0')\r
- $prerelease = $prerelease.padright(10,'z')\r
- $prebuildno = $prebuildno.padleft(10,'0')\r
-\r
- # Add a new element to the $VulkanDllList array\r
- WriteToLog "Adding $_ to Vulkan dll list "\r
- $script:VulkanDllList+="$major=$minor=$patch=$buildno=$prebuildno=$prerelease= $_ @$majorOrig@$minorOrig@$patchOrig@$buildnoOrig@$prereleaseOrig@$prebuildnoOrig@"\r
- if (!$?) {\r
- WriteToLog "Error: UpdateVulkanSysFolder adding DLL $_ to list"\r
- setScriptReturnValue(10)\r
- }\r
- }\r
-\r
- # If $VulkanDllList contains at least one element, there's at least one vulkan*.dll file.\r
- # Copy the most recent vulkan*.dll (named in the last element of $VulkanDllList) to vulkan-$majorabi.dll.\r
-\r
- if ($script:VulkanDllList.Length -gt 0) {\r
-\r
- # Sort the list. The most recent vulkan-*.dll will be in the last element of the list.\r
- [array]::sort($script:VulkanDllList)\r
- if (!$?) {\r
- WriteToLog "Error: UpdateVulkanSysFolder sorting DLL list" \r
- setScriptReturnValue(20)\r
- }\r
-\r
- # Put the name of the most recent vulkan-*.dll in $mrVulkanDLL.\r
- # The most recent vulkanDLL is the second word in the last element of the\r
- # sorted $VulkanDllList. Copy it to $vulkandll.\r
- $mrVulkanDll=$script:VulkanDllList[-1].Split(' ')[1]\r
- WriteToLog "Copying $mrVulkanDll $vulkandll"\r
- Copy-Item $mrVulkanDll $vulkandll -force\r
- if (!$?) {\r
- WriteToLog "Error: UpdateVulkanSysFolder encountered error during copy $mrVulkanDll $vulkandll"\r
- setScriptReturnValue(30)\r
- }\r
-\r
- # Copy the most recent version of vulkaninfo-<abimajor>-*.exe to vulkaninfo.exe.\r
- # We create the source file name for the copy from $mrVulkanDll.\r
- $mrVulkaninfo=$mrVulkanDll -replace ".dll",".exe"\r
- $mrVulkaninfo=$mrVulkaninfo -replace "vulkan","vulkaninfo"\r
- WriteToLog "Copying $mrVulkaninfo vulkaninfo.exe"\r
- Copy-Item $mrVulkaninfo vulkaninfo.exe -force\r
- if (!$?) {\r
- WriteToLog "Error: UpdateVulkanSysFolder encountered error during copy $mrVulkaninfo vulkaninfo.exe"\r
- setScriptReturnValue(40)\r
- }\r
-\r
- # Create the name used in the registry for the SDK associated with $mrVulkanDll.\r
- $major=$script:VulkanDllList[-1].Split('@')[1]\r
- $minor=$script:VulkanDllList[-1].Split('@')[2]\r
- $patch=$script:VulkanDllList[-1].Split('@')[3]\r
- $buildno=$script:VulkanDllList[-1].Split('@')[4]\r
- $prerelease=$script:VulkanDllList[-1].Split('@')[5]\r
- $prebuildno=$script:VulkanDllList[-1].Split('@')[6]\r
-\r
- $sdktempname="VulkanSDK"+$major + "." + $minor + "." + $patch + "." + $buildno\r
- if ($prerelease -ne "") {\r
- $sdktempname=$sdktempname + "." + $prerelease\r
- }\r
- if ($prebuildno -ne "") {\r
- $sdktempname=$sdktempname + "." + $prebuildno\r
- }\r
-\r
- WriteToLog "sdkname = $sdktempname"\r
- if (!$?) {\r
- WriteToLog "Error: UpdateVulkanSysFolder encountered error generating SDK name"\r
- setScriptReturnValue(50)\r
- }\r
- }\r
-\r
- # Return to our previous folder\r
- Pop-Location\r
- if (!$?) {\r
- WriteToLog "Error: UpdateVulkanSysFolder popping location"\r
- setScriptReturnValue(60)\r
- }\r
-\r
- # Only update the overall script-scope SDK name if we're told to\r
- if ($writeSdkName -ne 0) {\r
- $script:sdkname = $sdktempname\r
- }\r
-\r
- return\r
-}\r
-\r
-# We only care about SYSWOW64 if we're targeting a 64-bit OS\r
-if ($ossize -eq 64) {\r
-\r
- # Update the SYSWOW64 Vulkan DLLS/EXEs\r
- WriteToLog "Calling UpdateVulkanSysFolder $winfolder\SYSWOW64 0"\r
- UpdateVulkanSysFolder $winfolder\SYSWOW64 0\r
- if (!$?) {\r
- WriteToLog "Error: Calling UpdateVulkanSysFolder for 64-bit OS" \r
- setScriptReturnValue(70)\r
- }\r
-}\r
-\r
-# If this is a 64 bit OS and a 32 bit powershell\r
-if (($ossize -eq 64 ) -and ([IntPtr]::size -eq 4)) {\r
-\r
- # Update the SYSTEM32 Vulkan DLLS/EXEs\r
- WriteToLog "Calling UpdateVulkanSysFolder $winfolder\SYSTEM32 1"\r
- UpdateVulkanSysFolder $winfolder\SYSNATIVE 1\r
- if (!$?) {\r
- WriteToLog "Error: Calling UpdateVulkanSysFolder for all OS"\r
- setScriptReturnValue(80)\r
- }\r
-\r
-} else {\r
-\r
- # Update the SYSTEM32 Vulkan DLLS/EXEs\r
- WriteToLog "Calling UpdateVulkanSysFolder $winfolder\SYSTEM32 1"\r
- UpdateVulkanSysFolder $winfolder\SYSTEM32 1\r
- if (!$?) {\r
- WriteToLog "Error: Calling UpdateVulkanSysFolder for all OS"\r
- setScriptReturnValue(81)\r
- }\r
-}\r
-\r
-# Create an array of vulkan sdk install dirs\r
-\r
-WriteToLog "Creating array of of Vulkan SDK Install dirs"\r
-$mrVulkanDllInstallDir=""\r
-$VulkanSdkDirs=@()\r
-$installSDKRegs = @(Get-ChildItem -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall)\r
-if ($installSDKRegs -ne $null) {\r
- ForEach ($curSDKReg in $installSDKRegs) {\r
- if ($curSDKReg -ne $null) {\r
- $regkey=$curSDKReg -replace ".*\\",""\r
- if ($regkey -match "VulkanSDK") {\r
- # Get the install path from UninstallString\r
- $tmp=Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$regkey -Name UninstallString\r
- if (!$? -or $tmp -eq $null) {\r
- WriteToLog "Error: Get-ItemProperty failed for Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$regkey"\r
- $Error.Clear();\r
- continue;\r
- }\r
- $tmp=$tmp -replace "\\Uninstall.exe.*",""\r
- $tmp=$tmp -replace ".*=.",""\r
- WriteToLog "Adding $tmp to VulkanSDKDirs"\r
- $VulkanSdkDirs+=$tmp\r
- if ($regkey -eq $script:sdkname) {\r
- # Save away the sdk install dir for the the most recent vulkandll\r
- WriteToLog "Setting mrVulkanDllInstallDir to $tmp"\r
- $mrVulkanDllInstallDir=$tmp\r
- }\r
- }\r
- }\r
- }\r
-}\r
-if (!$?) {\r
- WriteToLog "Error: Failed creating array of of Vulkan SDK Install dirs"\r
- setScriptReturnValue(90)\r
-}\r
-\r
-\r
-# Search list of sdk install dirs for an sdk compatible with $script:sdkname.\r
-# We go backwards through VulkanDllList to generate SDK names, because we want the most recent SDK.\r
-\r
-if ($mrVulkanDllInstallDir -eq "" -and $script:VulkanDllList.Length -gt 0) {\r
- WriteToLog "Searching VulkanDllList"\r
- ForEach ($idx in ($script:VulkanDllList.Length-1)..0) {\r
- $tmp=$script:VulkanDllList[$idx]\r
- $vulkanDllMajor=$script:VulkanDllList[$idx].Split('@')[1]\r
- $vulkanDllMinor=$script:VulkanDllList[$idx].Split('@')[2]\r
- $vulkanDllPatch=$script:VulkanDllList[$idx].Split('@')[3]\r
- $vulkanDllBuildno=$script:VulkanDllList[$idx].Split('@')[4]\r
- $vulkanDllPrerelease=$script:VulkanDllList[$idx].Split('@')[5]\r
- $vulkanDllPrebuildno=$script:VulkanDllList[$idx].Split('@')[6]\r
- $regEntry="VulkanSDK"+$vulkanDllMajor+"."+$vulkanDllMinor+"."+$vulkanDllPatch+"."+$vulkanDllBuildno\r
- if ($vulkanDllPrerelease) {\r
- $regEntry=$regEntry+"."+$vulkanDllPrerelease\r
- }\r
- if ($vulkanDllPrebuildno) {\r
- $regEntry=$regEntry+"."+$vulkanDllPrebuildno\r
- }\r
- WriteToLog "Comparing $regEntry"\r
- $rval=Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$regEntry -ErrorAction SilentlyContinue\r
- if (!$? -or $rval -eq $null) {\r
- WriteToLog "Ignoring $regEntry - corresponding SDK registry entry does not exist"\r
- $Error.Clear();\r
- continue\r
- }\r
- $instDir=$rval\r
- $instDir=$instDir -replace "\\Uninstall.exe.*",""\r
- $instDir=$instDir -replace ".*=.",""\r
- if ($rval) {\r
- $rval=$rval -replace ".* DisplayVersion=",""\r
- $rval=$rval -replace ";.*",""\r
- $reMajor=$rval.Split('.')[0]\r
- $reMinor=$rval.Split('.')[1]\r
- $rePatch=$rval.Split('.')[2]\r
- if ($reMajor+$reMinor+$rePatch -eq $vulkanDllMajor+$vulkanDllMinor+$vulkanDllPatch) {\r
- WriteToLog "Setting mrVulkanDllInstallDir to $instDir"\r
- $mrVulkanDllInstallDir=$instDir\r
- break\r
- }\r
- }\r
- }\r
- if (!$?) {\r
- WriteToLog "Failed searching VulkanDLLList"\r
- $Error.Clear();\r
- }\r
-}\r
-\r
-# Add C:\Vulkan\SDK\0.9.3 to list of SDK install dirs.\r
-# We do this because there is in a bug in SDK 0.9.3 in which layer\r
-# reg entries were not removed on uninstall. So we'll try to clean up\r
-# and remove them now.\r
-# This works only if 0.9.3 was installed to the default location.\r
-# If it was not installed to the default location, those entries will\r
-# need to be cleaned up manually.\r
-\r
-$VulkanSdkDirs+="C:\VulkanSDK\0.9.3"\r
-$VulkanSdkDirs+="$windrive\VulkanSDK\0.9.3"\r
-\r
-# Remove layer registry values associated with all installed Vulkan SDKs.\r
-# Note that we remove only those entries created by Vulkan SDKs. If other\r
-# layers were installed that are not from an SDK, we don't mess with them.\r
-\r
-WriteToLog "Removing old layer registry values from HKLM\SOFTWARE\Khronos\Vulkan\ExplicitLayers"\r
-$regkeys = @(Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\ExplicitLayers | Select-Object -ExpandProperty Property)\r
-if ($regkeys -ne $null) {\r
- ForEach ($regval in $regkeys) {\r
- if ($regval -ne $null) {\r
- ForEach ($sdkdir in $VulkanSdkDirs) {\r
- if ($regval -like "$sdkdir\*.json") {\r
- Remove-ItemProperty -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers -name $regval\r
- if (!$?) {\r
- WriteToLog "Error: Remove-ItemProperty failed for -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers -name $regval"\r
- } else {\r
- WriteToLog "Removed registry value $regval"\r
- }\r
- }\r
- }\r
- }\r
- }\r
-}\r
-\r
-if (!$?) {\r
- WriteToLog "Error: Failed Removing old layer registry values from HKLM\SOFTWARE\Khronos\Vulkan\ExplicitLayers"\r
- setScriptReturnValue(100)\r
-}\r
-\r
-# Remove 32-bit layer registry value if we're targeting a 64-bit OS\r
-if ($ossize -eq 64) {\r
- $regkeys = @(Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers | Select-Object -ExpandProperty Property)\r
- if ($regkeys -ne $null) {\r
- ForEach ($regval in $regkeys) {\r
- if ($regval -ne $null) {\r
- ForEach ($sdkdir in $VulkanSdkDirs) {\r
- if ($regval -like "$sdkdir\*.json") {\r
- Remove-ItemProperty -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers -name $regval\r
- if (!$?) {\r
- WriteToLog "Error: Remove-ItemProperty failed for -Path HKLM:\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers -name $regval"\r
- } else {\r
- WriteToLog "Removed WOW6432Node registry value $regval"\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- if (!$?) {\r
- WriteToLog "Error: Failed Removing old layer registry values from HKLM\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers"\r
- setScriptReturnValue(110)\r
- }\r
-}\r
-\r
-\r
-# Create layer registry values associated with Vulkan SDK from which $mrVulkanDll is from\r
-\r
-WriteToLog "Creating new layer registry values"\r
-if ($mrVulkanDllInstallDir -ne "") {\r
-\r
- # Create registry keys if they don't exist\r
- if (-not (Test-Path -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers)) {\r
- WriteToLog "Creating new registry key HKLM\SOFTWARE\Khronos\Vulkan\ExplicitLayers"\r
- New-Item -Force -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers | out-null\r
- if (!$?) {\r
- WriteToLog "Error: Failed creating HKLM\SOFTWARE\Khronos\Vulkan\ExplicitLayers"\r
- setScriptReturnValue(120)\r
- }\r
- }\r
- if ($ossize -eq 64) {\r
- if (-not (Test-Path -Path HKLM:\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers)) {\r
- WriteToLog "Creating new registry key HKLM\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers"\r
- New-Item -Force -ErrorAction SilentlyContinue -Path HKLM:\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers | out-null\r
- if (!$?) {\r
- WriteToLog "Error: Failed creating HKLM\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers"\r
- setScriptReturnValue(130)\r
- }\r
- }\r
- }\r
-\r
-\r
- if ($ossize -eq 64) {\r
- # Create registry values in normal registry location for 64-bit items on a 64-bit OS\r
- Get-ChildItem $mrVulkanDllInstallDir\Bin -Filter VkLayer*json |\r
- ForEach-Object {\r
- WriteToLog "Creating registry value $mrVulkanDllInstallDir\Bin\$_"\r
- New-ItemProperty -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers -Name $mrVulkanDllInstallDir\Bin\$_ -PropertyType DWord -Value 0 | out-null\r
- if (!$?) {\r
- WriteToLog "Error: Failed creating $mrVulkanDllInstallDir\Bin\$_"\r
- setScriptReturnValue(140)\r
- }\r
- }\r
- if (!$?) {\r
- WriteToLog "Error: Failed Get-ChildItem $mrVulkanDllInstallDir\Bin | ForEach-Object "\r
- setScriptReturnValue(150)\r
- }\r
-\r
- # Create registry values for the WOW6432Node registry location for 32-bit items on a 64-bit OS\r
- Get-ChildItem $mrVulkanDllInstallDir\Bin32 -Filter VkLayer*json |\r
- ForEach-Object {\r
- WriteToLog "Creating WOW6432Node registry value $mrVulkanDllInstallDir\Bin32\$_"\r
- New-ItemProperty -Path HKLM:\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers -Name $mrVulkanDllInstallDir\Bin32\$_ -PropertyType DWord -Value 0 | out-null\r
- if (!$?) {\r
- WriteToLog "Error: Failed creating $mrVulkanDllInstallDir\Bin32\$_"\r
- setScriptReturnValue(160)\r
- }\r
- }\r
- if (!$?) {\r
- WriteToLog "Error: Failed Get-ChildItem $mrVulkanDllInstallDir\Bin32 | ForEach-Object "\r
- setScriptReturnValue(170)\r
- }\r
- } else {\r
- # Create registry values in normal registry location for 32-bit items on a 32-bit OS\r
- Get-ChildItem $mrVulkanDllInstallDir\Bin32 -Filter VkLayer*json |\r
- ForEach-Object {\r
- WriteToLog "Creating registry value $mrVulkanDllInstallDir\Bin\$_"\r
- New-ItemProperty -Path HKLM:\SOFTWARE\Khronos\Vulkan\ExplicitLayers -Name $mrVulkanDllInstallDir\Bin32\$_ -PropertyType DWord -Value 0 | out-null\r
- if (!$?) {\r
- WriteToLog "Error: Failed creating $mrVulkanDllInstallDir\Bin\$_"\r
- setScriptReturnValue(180)\r
- }\r
- }\r
- if (!$?) {\r
- WriteToLog "Error: Failed Get-ChildItem $mrVulkanDllInstallDir\Bin32 | ForEach-Object "\r
- setScriptReturnValue(190)\r
- }\r
- }\r
-}\r
-\r
-# Debug - for testing handling of script failure in installer\r
-#setScriptReturnValue(200)\r
-\r
-# Final log output\r
-WriteToLog "ConfigLayersAndVulkanDLL.ps1 completed, return status is $script:scriptReturnValue"\r
-$endTime=Get-Date\r
-WriteToLog "End time: $endTime"\r
-\r
-# Since InstallerRT.nsi runs this script by piping it to powershell.exe, the exit status\r
-# doesn't seem to be available. So we put in it a file where InstallRT.nsi can retrieve it.\r
-$statusfile=$Env:Temp+"\ConfigLayersAndVulkanDLL.stat"\r
-echo $script:scriptReturnValue | Out-File -encoding ascii -filepath $statusfile\r
-\r
-exit $script:scriptReturnValue\r