diff --git a/.github/workflows/backends.yml b/.github/workflows/backends.yml
index f18f253..53851d0 100644
--- a/.github/workflows/backends.yml
+++ b/.github/workflows/backends.yml
@@ -15,7 +15,10 @@ on:
jobs:
windows:
runs-on: windows-latest
-
+
+ env:
+ VULKAN_VERSION: 1.3.261.1
+
strategy:
matrix:
include:
@@ -33,6 +36,8 @@ jobs:
defines: '-DSD_CUBLAS=ON -DSD_BUILD_SHARED_LIBS=ON'
- build: 'rocm5'
defines: '-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030" -DSD_BUILD_SHARED_LIBS=ON'
+ - build: 'vulkan'
+ defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON"
steps:
- name: Checkout
@@ -79,6 +84,15 @@ jobs:
with:
version: 1.11.1
+ - name: Install Vulkan SDK
+ id: get_vulkan
+ if: ${{ matrix.build == 'vulkan' }}
+ run: |
+ curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/VulkanSDK-${env:VULKAN_VERSION}-Installer.exe"
+ & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
+ Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
+ Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
+
- name: Build
id: cmake_build
run: |
@@ -349,6 +363,7 @@ jobs:
nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda.nuspec -version ${{ github.event.inputs.version }}
nuget pack ./Backends/StableDiffusion.NET.Backend.Rocm.nuspec -version ${{ github.event.inputs.version }}
nuget pack ./Backends/StableDiffusion.NET.Backend.Sycl.nuspec -version ${{ github.event.inputs.version }}
+ nuget pack ./Backends/StableDiffusion.NET.Backend.Vulkan.nuspec -version ${{ github.event.inputs.version }}
- name: Upload artifacts
id: upload_artifacts
diff --git a/Backends/StableDiffusion.NET.Backend.Vulkan.nuspec b/Backends/StableDiffusion.NET.Backend.Vulkan.nuspec
new file mode 100644
index 0000000..0f9057c
--- /dev/null
+++ b/Backends/StableDiffusion.NET.Backend.Vulkan.nuspec
@@ -0,0 +1,28 @@
+
+
+
+ StableDiffusion.NET.Backend.Vulkan
+ $version$
+ StableDiffusion.NET.Backend.Vulkan
+ Darth Affe & stable-diffusion.cpp Authors
+ false
+ MIT
+ sd_net_vulkan.png
+ https://github.com/DarthAffe/StableDiffusion.NET
+ Vulkan-Backend for StableDiffusion.NET.
+
+ Copyright © Darth Affe 2024
+ readme.md
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Backends/sd_net_vulkan.png b/Backends/sd_net_vulkan.png
new file mode 100644
index 0000000..c6c8f4b
Binary files /dev/null and b/Backends/sd_net_vulkan.png differ
diff --git a/Resources/sd_net_icon.xcf b/Resources/sd_net_icon.xcf
index a7d9992..910f404 100644
Binary files a/Resources/sd_net_icon.xcf and b/Resources/sd_net_icon.xcf differ
diff --git a/StableDiffusion.NET/Backends/Backends.cs b/StableDiffusion.NET/Backends/Backends.cs
index 2ce6607..a2d7295 100644
--- a/StableDiffusion.NET/Backends/Backends.cs
+++ b/StableDiffusion.NET/Backends/Backends.cs
@@ -15,11 +15,12 @@ public static class Backends
public static CudaBackend CudaBackend { get; } = new();
public static RocmBackend RocmBackend { get; } = new();
public static SyclBackend SyclBackend { get; } = new();
+ public static VulkanBackend VulkanBackend { get; } = new();
private static readonly List CUSTOM_BACKENDS = [];
public static IReadOnlyList CustomBackends => CUSTOM_BACKENDS.AsReadOnly();
- public static IEnumerable RegisteredBackends => [CpuBackend, CudaBackend, RocmBackend, SyclBackend, .. CUSTOM_BACKENDS];
+ public static IEnumerable RegisteredBackends => [CpuBackend, CudaBackend, RocmBackend, SyclBackend, VulkanBackend, .. CUSTOM_BACKENDS];
public static IEnumerable AvailableBackends => RegisteredBackends.Where(x => x.IsAvailable);
public static IEnumerable ActiveBackends => AvailableBackends.Where(x => x.IsEnabled);
@@ -37,7 +38,7 @@ public static class Backends
public static bool RegisterBackend(IBackend backend)
{
- if (backend is NET.CpuBackend or NET.CudaBackend or NET.RocmBackend or NET.SyclBackend)
+ if (backend is NET.CpuBackend or NET.CudaBackend or NET.RocmBackend or NET.SyclBackend or NET.VulkanBackend)
throw new ArgumentException("Default backends can't be registered again.");
if (CUSTOM_BACKENDS.Contains(backend))
diff --git a/StableDiffusion.NET/Backends/CpuBackend.cs b/StableDiffusion.NET/Backends/CpuBackend.cs
index ae8ed0e..4c1ff2e 100644
--- a/StableDiffusion.NET/Backends/CpuBackend.cs
+++ b/StableDiffusion.NET/Backends/CpuBackend.cs
@@ -13,7 +13,7 @@ public class CpuBackend : IBackend
public bool IsEnabled { get; set; } = true;
- public int Priority => 0;
+ public int Priority { get; set; } = 0;
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
diff --git a/StableDiffusion.NET/Backends/CudaBackend.cs b/StableDiffusion.NET/Backends/CudaBackend.cs
index c0e97c9..91aa1e3 100644
--- a/StableDiffusion.NET/Backends/CudaBackend.cs
+++ b/StableDiffusion.NET/Backends/CudaBackend.cs
@@ -22,7 +22,7 @@ public partial class CudaBackend : IBackend
public bool IsEnabled { get; set; } = true;
- public int Priority => 10;
+ public int Priority { get; set; } = 10;
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
diff --git a/StableDiffusion.NET/Backends/IBackend.cs b/StableDiffusion.NET/Backends/IBackend.cs
index e881a9c..286d95e 100644
--- a/StableDiffusion.NET/Backends/IBackend.cs
+++ b/StableDiffusion.NET/Backends/IBackend.cs
@@ -6,7 +6,7 @@ namespace StableDiffusion.NET;
public interface IBackend
{
bool IsEnabled { get; set; }
- public int Priority { get; }
+ public int Priority { get; set; }
bool IsAvailable { get; }
string PathPart { get; }
}
\ No newline at end of file
diff --git a/StableDiffusion.NET/Backends/RocmBackend.cs b/StableDiffusion.NET/Backends/RocmBackend.cs
index 14035e0..cfbcf42 100644
--- a/StableDiffusion.NET/Backends/RocmBackend.cs
+++ b/StableDiffusion.NET/Backends/RocmBackend.cs
@@ -12,7 +12,7 @@ public partial class RocmBackend : IBackend
public bool IsEnabled { get; set; } = true;
- public int Priority => 10;
+ public int Priority { get; set; } = 10;
public bool IsAvailable => ((RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
&& RocmVersion is 5)
diff --git a/StableDiffusion.NET/Backends/SyclBackend.cs b/StableDiffusion.NET/Backends/SyclBackend.cs
index 80e0b5b..d08a643 100644
--- a/StableDiffusion.NET/Backends/SyclBackend.cs
+++ b/StableDiffusion.NET/Backends/SyclBackend.cs
@@ -11,7 +11,7 @@ public class SyclBackend : IBackend
//TODO DarthAffe 10.08.2024: tbh I'm not really sure how to detect a sycl-compatible system so for now it's disabled by default
public bool IsEnabled { get; set; } = false;
- public int Priority => 5;
+ public int Priority { get; set; } = 5;
public bool IsAvailable => (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
diff --git a/StableDiffusion.NET/Backends/VulkanBackend.cs b/StableDiffusion.NET/Backends/VulkanBackend.cs
new file mode 100644
index 0000000..0fa5097
--- /dev/null
+++ b/StableDiffusion.NET/Backends/VulkanBackend.cs
@@ -0,0 +1,29 @@
+using System.Runtime.InteropServices;
+using JetBrains.Annotations;
+
+namespace StableDiffusion.NET;
+
+[PublicAPI]
+public class VulkanBackend : IBackend
+{
+ #region Properties & Fields
+
+ //TODO DarthAffe 28.08.2024: Find a way to detect vulkan compatibility
+ public bool IsEnabled { get; set; } = false;
+
+ public int Priority { get; set; } = 5;
+
+ public bool IsAvailable => RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
+ && (RuntimeInformation.OSArchitecture == Architecture.X64);
+
+ public string PathPart => "vulkan";
+
+ #endregion
+
+ #region Constructors
+
+ internal VulkanBackend()
+ { }
+
+ #endregion
+}
\ No newline at end of file