Skip to content

Commit

Permalink
fix: add vulkan sdk to pre build and embed vulkan dll / ubuntu package
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Aug 26, 2024
1 parent 4c38dfb commit 928255b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 39 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/linux_special.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ jobs:
large-packages: true
docker-images: true
swap-storage: true

- name: Prepare Vulkan SDK for Windows
run: |
C:\msys64\usr\bin\wget.exe https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanSDK-1.3.290.0-Installer.exe -O vulkan.exe
.\vulkan.exe --root C:\vulkan --accept-licenses --default-answer --confirm-command install
echo "VULKAN_SDK=C:\vulkan" >> $env:GITHUB_ENV
Copy-Item -Path "C:\vulkan\Bin\*.dll" -Destination "." -Recurse
if: ${{ contains(matrix.platform, 'windows') && contains(matrix.args, 'vulkan') }}

- name: Prepare Vulkan SDK for Ubuntu 24.04
run: |
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ jobs:
run: bun install
working-directory: ./desktop

- name: Prepare Vulkan SDK for Windows
run: |
C:\msys64\usr\bin\wget.exe https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanSDK-1.3.290.0-Installer.exe -O vulkan.exe
.\vulkan.exe --root C:\vulkan --accept-licenses --default-answer --confirm-command install
echo "VULKAN_SDK=C:\vulkan" >> $env:GITHUB_ENV
Copy-Item -Path "C:\vulkan\Bin\*.dll" -Destination "." -Recurse
if: ${{ contains(matrix.platform, 'windows') && contains(matrix.args, 'vulkan') }}

- name: Prepare Vulkan SDK for Ubuntu 22.04
run: |
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/test_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ jobs:
sudo apt update
sudo apt install -y rocm
- name: Prepare Vulkan SDK for Windows
run: |
C:\msys64\usr\bin\wget.exe https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanSDK-1.3.290.0-Installer.exe -O vulkan.exe
.\vulkan.exe --root C:\vulkan --accept-licenses --default-answer --confirm-command install
echo "VULKAN_SDK=C:\vulkan" >> $env:GITHUB_ENV
if: ${{ contains(matrix.args, 'vulkan') && contains(matrix.platform, 'windows') }}

- name: Prepare Vulkan SDK for Linux
run: |
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/windows_special.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

- name: Prepare Vulkan SDK for Windows
run: |
C:\msys64\usr\bin\wget.exe https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanSDK-1.3.290.0-Installer.exe -O vulkan.exe
.\vulkan.exe --root C:\vulkan --accept-licenses --default-answer --confirm-command install
echo "VULKAN_SDK=C:\vulkan" >> $env:GITHUB_ENV
Copy-Item -Path "C:\vulkan\Bin\*.dll" -Destination "." -Recurse
if: ${{ contains(matrix.platform, 'windows') && contains(matrix.args, 'vulkan') }}

- name: Prepare Vulkan SDK for Linux
run: |
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ openblas/
.env
!samples/*
clblast/
vulkan_sdk/
vulkan_runtime/
schemas/
node_modules/
.DS_Store
Expand Down
8 changes: 0 additions & 8 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ _Vulkan (Linux)_
sudo apt-get install -y mesa-vulkan-drivers
```

_Vulkan (Windows)_

Download from [vulkan.lunarg.com](https://vulkan.lunarg.com/) and set environment variable

```console
$env:VULKAN_SDK = "C:\VulkanSDK\<version>"
```

## Build

Install dependencies from `desktop` folder
Expand Down
49 changes: 49 additions & 0 deletions scripts/pre_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const config = {
ffmpegRealname: 'ffmpeg',
openblasRealname: 'openblas',
clblastRealname: 'clblast',
vulkanRuntimeRealName: 'vulkan_runtime',
vulkanSdkRealName: 'vulkan_sdk',
windows: {
ffmpegName: 'ffmpeg-7.0-windows-desktop-vs2022-default',
ffmpegUrl: 'https://unlimited.dl.sourceforge.net/project/avbuild/windows-desktop/ffmpeg-7.0-windows-desktop-vs2022-default.7z?viasf=1',
Expand All @@ -31,6 +33,10 @@ const config = {
clblastName: 'CLBlast-1.6.2-windows-x64',
clblastUrl: 'https://github.com/CNugteren/CLBlast/releases/download/1.6.2/CLBlast-1.6.2-windows-x64.zip',

vulkanRuntimeName: 'VulkanRT-1.3.290.0-Components',
vulkanRuntimeUrl: 'https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanRT-1.3.290.0-Components.zip',
vulkanSdkName: 'VulkanSDK-1.3.290.0-Installer',
vulkanSdkUrl: 'https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanSDK-1.3.290.0-Installer.exe',
vcpkgPackages: [],
},
linux: {
Expand Down Expand Up @@ -118,6 +124,20 @@ if (platform == 'windows') {
await $`rm ${config.windows.clblastName}.7z`
}

// Setup Vulkan
if (!(await fs.exists(config.vulkanSdkRealName)) && hasFeature('vulkan')) {
await $`C:\\msys64\\usr\\bin\\wget.exe -nc --show-progress ${config.windows.vulkanSdkUrl} -O ${config.windows.vulkanSdkName}.exe`
let executable = path.join(cwd, `${config.windows.vulkanSdkName}.exe`)
let vulkanSdkRoot = path.join(cwd, config.vulkanSdkRealName)
await $`${executable} --root ${vulkanSdkRoot} --accept-licenses --default-answer --confirm-command install`

await $`C:\\msys64\\usr\\bin\\wget.exe -nc --show-progress ${config.windows.vulkanRuntimeUrl} -O ${config.windows.vulkanRuntimeName}.zip`
await $`"C:\\Program Files\\7-Zip\\7z.exe" x ${config.windows.vulkanRuntimeName}.zip` // 7z file inside
await $`mv ${config.windows.vulkanRuntimeName} ${config.vulkanRuntimeRealName}`
await $`rm ${config.windows.vulkanSdkName}.exe`
await $`rm ${config.windows.vulkanRuntimeName}.zip`
}

// Setup vcpkg packages
if (config.windows.vcpkgPackages.length > 0) {
await $`C:\\vcpkg\\vcpkg.exe install ${config.windows.vcpkgPackages}`.quiet()
Expand Down Expand Up @@ -182,6 +202,26 @@ if (hasFeature('openblas')) {
}
}

// Vulkan
let vulkanPath = path.join(cwd, config.vulkanSdkRealName)
let vulkanRuntimePath = path.join(cwd, config.vulkanRuntimeRealName)
if (hasFeature('vulkan')) {
if (platform === 'windows') {
const tauriConfigContent = await fs.readFile('tauri.windows.conf.json', { encoding: 'utf-8' })
const tauriConfig = JSON.parse(tauriConfigContent)
tauriConfig.bundle.resources['vulkan_runtime\\x64\\*.dll'] = './'
await fs.writeFile('tauri.windows.conf.json', JSON.stringify(tauriConfig, null, 4))
}
if (platform === 'linux') {
// Add vulkan depends
const tauriConfigContent = await fs.readFile('tauri.linux.conf.json', { encoding: 'utf-8' })
const tauriConfig = JSON.parse(tauriConfigContent)
tauriConfig.bundle.linux.deb.depends.push('libvulkan1')
tauriConfig.bundle.linux.deb.depends.push('mesa-vulkan-drivers')
await fs.writeFile('tauri.linux.conf.json', JSON.stringify(tauriConfig, null, 4))
}
}

// ROCM
let rocmPath = '/opt/rocm'
if (hasFeature('rocm')) {
Expand Down Expand Up @@ -241,6 +281,11 @@ if (!process.env.GITHUB_ENV) {
if (hasFeature('portable')) {
console.log('$env:WINDOWS_PORTABLE=1')
}

if (hasFeature('vulkan')) {
console.log(`$env:VULKAN_SDK = "${vulkanPath}"`)
console.log(`$env:PATH += "${vulkanRuntimePath}"`)
}
}
if (platform == 'macos') {
console.log(`export FFMPEG_DIR="${exports.ffmpeg}"`)
Expand Down Expand Up @@ -285,6 +330,10 @@ if (process.env.GITHUB_ENV) {
console.log('Adding ENV', windowsPortable)
await fs.appendFile(process.env.GITHUB_ENV, windowsPortable)
}

if (hasFeature('vulkan')) {
await fs.appendFile(process.env.GITHUB_ENV, `VULKAN_SDK=${vulkanPath}\n`)
}
}
}

Expand Down

0 comments on commit 928255b

Please sign in to comment.