Skip to content

Commit aebb5fe

Browse files
committed
Move DXVK version detection into its own function
1 parent b4f1e86 commit aebb5fe

File tree

1 file changed

+46
-33
lines changed

1 file changed

+46
-33
lines changed

src/backend/tools.ts

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ import {
1212
import { exec, spawn } from 'child_process'
1313

1414
import { execAsync, getWineFromProton } from './utils'
15-
import { execOptions, toolsPath, isMac, isWindows, userHome } from './constants'
15+
import {
16+
execOptions,
17+
toolsPath,
18+
isMac,
19+
isWindows,
20+
userHome,
21+
isLinux
22+
} from './constants'
1623
import { logError, logInfo, LogPrefix, logWarning } from './logger/logger'
1724
import i18next from 'i18next'
1825
import { dirname, join } from 'path'
@@ -48,36 +55,7 @@ export const DXVK = {
4855
},
4956
{
5057
name: 'dxvk',
51-
url: () => {
52-
if (any_gpu_supports_version([1, 3, 0])) {
53-
const instance_version = get_vulkan_instance_version()
54-
if (
55-
instance_version &&
56-
semverLt(instance_version.join('.'), '1.3.0')
57-
) {
58-
// FIXME: How does the instance version matter? Even with 1.2, newer DXVK seems to work fine
59-
logWarning(
60-
'Vulkan 1.3 is supported by GPUs in this system, but instance version is outdated',
61-
LogPrefix.DXVKInstaller
62-
)
63-
}
64-
return 'https://api.github.com/repos/doitsujin/dxvk/releases/latest'
65-
}
66-
if (any_gpu_supports_version([1, 1, 0])) {
67-
logInfo(
68-
'The GPU(s) in this system only support Vulkan 1.1/1.2, falling back to DXVK 1.10.3',
69-
LogPrefix.DXVKInstaller
70-
)
71-
return 'https://api.github.com/repos/doitsujin/dxvk/releases/tags/v1.10.3'
72-
}
73-
logWarning(
74-
'No GPU with Vulkan 1.1 support found, DXVK will not work',
75-
LogPrefix.DXVKInstaller
76-
)
77-
// FIXME: We currently lack a "Don't download at all" option here, but
78-
// that would also need bigger changes in the frontend
79-
return 'https://api.github.com/repos/doitsujin/dxvk/releases/latest'
80-
},
58+
url: getDxvkUrl(),
8159
extractCommand: 'tar -xf',
8260
os: 'linux'
8361
},
@@ -94,10 +72,9 @@ export const DXVK = {
9472
return
9573
}
9674

97-
const download_url = typeof tool.url === 'string' ? tool.url : tool.url()
9875
const {
9976
data: { assets }
100-
} = await axios.get(download_url)
77+
} = await axios.get(tool.url)
10178

10279
const { name, browser_download_url: downloadUrl } = assets[0]
10380
const pkg = name.replace('.tar.gz', '').replace('.tar.xz', '')
@@ -507,3 +484,39 @@ export const Winetricks = {
507484
)
508485
}
509486
}
487+
488+
/**
489+
* Figures out the right DXVK version to use, taking the user's hardware
490+
* (specifically their Vulkan support) into account
491+
*/
492+
function getDxvkUrl(): string {
493+
if (!isLinux) {
494+
return ''
495+
}
496+
497+
if (any_gpu_supports_version([1, 3, 0])) {
498+
const instance_version = get_vulkan_instance_version()
499+
if (instance_version && semverLt(instance_version.join('.'), '1.3.0')) {
500+
// FIXME: How does the instance version matter? Even with 1.2, newer DXVK seems to work fine
501+
logWarning(
502+
'Vulkan 1.3 is supported by GPUs in this system, but instance version is outdated',
503+
LogPrefix.DXVKInstaller
504+
)
505+
}
506+
return 'https://api.github.com/repos/doitsujin/dxvk/releases/latest'
507+
}
508+
if (any_gpu_supports_version([1, 1, 0])) {
509+
logInfo(
510+
'The GPU(s) in this system only support Vulkan 1.1/1.2, falling back to DXVK 1.10.3',
511+
LogPrefix.DXVKInstaller
512+
)
513+
return 'https://api.github.com/repos/doitsujin/dxvk/releases/tags/v1.10.3'
514+
}
515+
logWarning(
516+
'No GPU with Vulkan 1.1 support found, DXVK will not work',
517+
LogPrefix.DXVKInstaller
518+
)
519+
// FIXME: We currently lack a "Don't download at all" option here, but
520+
// that would also need bigger changes in the frontend
521+
return 'https://api.github.com/repos/doitsujin/dxvk/releases/latest'
522+
}

0 commit comments

Comments
 (0)