Skip to content

Commit

Permalink
installer check for Vulkan support
Browse files Browse the repository at this point in the history
  • Loading branch information
Die4Ever committed Sep 10, 2023
1 parent f49108f commit a3ba1c7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 29 deletions.
26 changes: 14 additions & 12 deletions installer/GUI/InstallerWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import webbrowser
from GUI import *
from pathlib import Path
from Install import Install, IsWindows, getDefaultPath
from Install import Install, IsWindows, CheckVulkan, getDefaultPath
import traceback
import re
except Exception as e:
Expand All @@ -17,6 +17,8 @@ def initWindow(self):
self.lastprogress = ''
self.root.title("Deus Ex Randomizer Installer")

dxvk_default = IsWindows() and CheckVulkan()

scroll = ScrollableFrame(self.root, width=self.width, height=self.height, mousescroll=1)
self.frame = scroll.frame

Expand Down Expand Up @@ -58,12 +60,13 @@ def initWindow(self):
self.speedupfixval = BooleanVar(master=self.frame, value=True)
self.speedupfix = Checkbutton(self.frame, text="Apply Engine.dll speedup fix", variable=self.speedupfixval)
self.speedupfix.grid(column=1,row=row, sticky='SW', padx=pad, pady=pad)
Hovertip(self.speedupfix, "Fixes issues with high frame rates.")
self.FixColors(self.speedupfix)
row+=1

# DXVK is also global
if IsWindows():
self.dxvkval = BooleanVar(master=self.frame, value=IsWindows())
self.dxvkval = BooleanVar(master=self.frame, value=dxvk_default)
self.dxvk = Checkbutton(self.frame, text="Apply DXVK fix for modern computers", variable=self.dxvkval)
self.dxvk.grid(column=1,row=row, sticky='SW', padx=pad, pady=pad)
Hovertip(self.dxvk, "DXVK can fix performance issues on modern systems by using Vulkan.")
Expand All @@ -72,6 +75,13 @@ def initWindow(self):
else:
self.dxvkval = DummyCheckbox()

self.ogl2val = BooleanVar(master=self.frame, value=dxvk_default)
self.ogl2 = Checkbutton(self.frame, text="Updated OpenGL 2.0 Renderer", variable=self.ogl2val)
Hovertip(self.ogl2, "Updated OpenGL Renderer for modern systems. An alternative to using D3D10 or D3D9.")
self.ogl2.grid(column=1,row=row, sticky='SW', padx=pad, pady=pad)
self.FixColors(self.ogl2)
row+=1

# TODO: option to enable telemetry? checking for updates?

# WEBSITE!
Expand Down Expand Up @@ -134,14 +144,6 @@ def InitFlavorSettings(self, f: str, row, pad) -> int:
Hovertip(r, "Hanfling's Launch stored configs and saves in the game directory.\nIf your game is in Program Files, then the game might require admin permissions to play.")
row += 1

v = BooleanVar(master=self.frame, value=False)
settings['OpenGL2'] = v
c = Checkbutton(self.frame, text="Updated OpenGL 2.0 Renderer", variable=v)
Hovertip(c, "Updated OpenGL Renderer for modern systems. An alternative to using D3D10 or D3D9.")
c.grid(column=1,row=row, sticky='SW', padx=pad*4, pady=pad)
self.FixColors(c)
row+=1

self.flavors[f] = settings
return row

Expand Down Expand Up @@ -172,13 +174,13 @@ def _Install(self):
'exetype': v.get('exe', dummy).get(),
'mirrors': v.get('mirrors', dummy).get(),
'LDDP': v.get('LDDP', dummy).get(),
'OpenGL2': v.get('OpenGL2', dummy).get(),
'downloadcallback': self.DownloadProgress,
}

speedupfix = self.speedupfixval.get()
dxvk = self.dxvkval.get()
flavors = Install.Install(self.exe, flavors, speedupfix, dxvk)
ogl2 = self.ogl2val.get()
flavors = Install.Install(self.exe, flavors, speedupfix, dxvk, ogl2)
flavorstext = ', '.join(flavors.keys())
extra = ''
if 'Vanilla' in flavors and IsWindows():
Expand Down
22 changes: 5 additions & 17 deletions installer/Install/Install.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def UnattendedInstall(installpath:str, downloadmirrors):
if downloadmirrors and 'Vanilla' in settings:
settings['Vanilla']['mirrors'] = True

ret = Install(p, settings, speedupfix=True, dxvk=IsWindows())
dxvk_default = IsWindows() and CheckVulkan()

ret = Install(p, settings, speedupfix=True, dxvk=dxvk_default, ogl2=dxvk_default)


def DetectFlavors(exe:Path) -> list:
Expand All @@ -41,7 +43,7 @@ def DetectFlavors(exe:Path) -> list:
return _DetectFlavors(system)


def Install(exe:Path, flavors:dict, speedupfix:bool, dxvk:bool) -> dict:
def Install(exe:Path, flavors:dict, speedupfix:bool, dxvk:bool, ogl2:bool=False) -> dict:
assert exe.exists(), str(exe)
assert exe.name.lower() == 'deusex.exe'
system:Path = exe.parent
Expand Down Expand Up @@ -72,6 +74,7 @@ def Install(exe:Path, flavors:dict, speedupfix:bool, dxvk:bool) -> dict:
EngineDllFix(system)

CopyDXVK(system, dxvk)
InstallOGL2(system, ogl2)

debug("Install returning", flavors)

Expand Down Expand Up @@ -161,21 +164,6 @@ def InstallVanilla(system:Path, settings:dict, speedupfix:bool):
CopyPackageFiles('vanilla', gameroot, ['DeusEx.u'])
CopyD3DRenderers(system)

Ogl = system/'OpenGLDrv.dll'
backupOgl = system/'OpenGLDrv.orig.dll'
if settings.get('OpenGL2'):
if Ogl.exists() and not backupOgl.exists():
Ogl.rename(backupOgl)
CopyTo(GetSourcePath() / '3rdParty' /'OpenGLDrv.dll', Ogl)
elif backupOgl.exists():
currMd5 = ''
if Ogl.exists():
currMd5 = MD5(Ogl.read_bytes())
backupMd5 = MD5(backupOgl.read_bytes())
info('reverting', Ogl, currMd5, 'to', backupOgl, backupMd5)
CopyTo(backupOgl, Ogl)


FemJCu = GetSourcePath() / '3rdParty' / "FemJC.u"
CopyTo(FemJCu, dxrroot / 'System' / 'FemJC.u')

Expand Down
29 changes: 29 additions & 0 deletions installer/Install/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def info(*args):
import urllib.request
import certifi
import ssl
import subprocess
except Exception as e:
info('ERROR: importing', e)
raise
Expand All @@ -53,6 +54,19 @@ def GetDryrun() -> bool:
def IsWindows() -> bool:
return os.name == 'nt'

def CheckVulkan() -> bool:
try:
info('CheckVulkan')
ret = subprocess.run(['vulkaninfo', '--summary'], text=True, capture_output=True, timeout=30)
debug(ret.stdout)
debug(ret.stderr)
info('CheckVulkan got:', not ret.returncode)
return not ret.returncode
except Exception as e:
info(e)
return False


def GetConfChanges(modname):
changes = {
'Engine.Engine': {
Expand Down Expand Up @@ -278,6 +292,21 @@ def CopyDXVK(system:Path, install:bool):
num += 1
assert num > 0, 'Found '+str(num)+' DXVK files'

def InstallOGL2(system:Path, install:bool):
Ogl = system/'OpenGLDrv.dll'
backupOgl = system/'OpenGLDrv.orig.dll'
if install:
if Ogl.exists() and not backupOgl.exists():
Ogl.rename(backupOgl)
CopyTo(GetSourcePath() / '3rdParty' /'OpenGLDrv.dll', Ogl)
elif backupOgl.exists():
currMd5 = ''
if Ogl.exists():
currMd5 = MD5(Ogl.read_bytes())
backupMd5 = MD5(backupOgl.read_bytes())
info('reverting', Ogl, currMd5, 'to', backupOgl, backupMd5)
CopyTo(backupOgl, Ogl)


def Mkdir(dir:Path, parents=False, exist_ok=False):
if GetDryrun():
Expand Down

0 comments on commit a3ba1c7

Please sign in to comment.