-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetupVulkan.py
71 lines (58 loc) · 2.51 KB
/
SetupVulkan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os
import sys
import subprocess
from pathlib import Path
import Utils
from io import BytesIO
from urllib.request import urlopen
class VulkanConfiguration:
requiredVulkanVersion = "1.3."
installVulkanVersion = "1.3.296.0"
vulkanDirectory = "StarEngine/vendor/VulkanSDK"
@classmethod
def Validate(cls):
if (not cls.CheckVulkanSDK()):
print("Vulkan SDK not installed correctly.")
return
if (not cls.CheckVulkanSDKDebugLibs()):
print("\nNo Vulkan SDK debug libs found. Install Vulkan SDK with debug libs.")
print("(see docs.hazelengine.com/GettingStarted for more info).")
print("Debug configuration disabled.")
@classmethod
def CheckVulkanSDK(cls):
vulkanSDK = os.environ.get("VULKAN_SDK")
if (vulkanSDK is None):
print("\nYou don't have the Vulkan SDK installed!")
cls.__InstallVulkanSDK()
return False
else:
print(f"\nLocated Vulkan SDK at {vulkanSDK}")
if (cls.requiredVulkanVersion not in vulkanSDK):
print(f"You don't have the correct Vulkan SDK version! (Engine requires {cls.requiredVulkanVersion})")
cls.__InstallVulkanSDK()
return False
print(f"Correct Vulkan SDK located at {vulkanSDK}")
return True
@classmethod
def __InstallVulkanSDK(cls):
permissionGranted = False
while not permissionGranted:
reply = str(input("Would you like to install VulkanSDK {0:s}? [Y/N]: ".format(cls.installVulkanVersion))).lower().strip()[:1]
if reply == 'n':
return
permissionGranted = (reply == 'y')
vulkanInstallURL = f"https://sdk.lunarg.com/sdk/download/{cls.installVulkanVersion}/windows/VulkanSDK-{cls.installVulkanVersion}-Installer.exe"
vulkanPath = f"{cls.vulkanDirectory}/VulkanSDK-{cls.installVulkanVersion}-Installer.exe"
print("Downloading {0:s} to {1:s}".format(vulkanInstallURL, vulkanPath))
Utils.DownloadFile(vulkanInstallURL, vulkanPath)
print("Running Vulkan SDK installer...")
os.startfile(os.path.abspath(vulkanPath))
print("Re-run this script after installation!")
quit()
@classmethod
def CheckVulkanSDKDebugLibs(cls):
vulkanSDK = os.environ.get("VULKAN_SDK")
shadercdLib = Path(f"{vulkanSDK}/Lib/shaderc_sharedd.lib")
return shadercdLib.exists()
if __name__ == "__main__":
VulkanConfiguration.Validate()