forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
realcugan-ncnn-vulkan: init at 20220728 (NixOS#295212)
- Loading branch information
Showing
3 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index dac535d..59f6e5b 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -62,20 +62,13 @@ if(USE_SYSTEM_NCNN) | ||
message(STATUS "Using glslang install located at ${GLSLANG_TARGET_DIR}") | ||
|
||
find_package(Threads) | ||
+ find_package(glslang REQUIRED) | ||
+ find_package(SPIRV-Tools-opt REQUIRED) | ||
|
||
- include("${GLSLANG_TARGET_DIR}/OSDependentTargets.cmake") | ||
- include("${GLSLANG_TARGET_DIR}/OGLCompilerTargets.cmake") | ||
if(EXISTS "${GLSLANG_TARGET_DIR}/HLSLTargets.cmake") | ||
# hlsl support can be optional | ||
include("${GLSLANG_TARGET_DIR}/HLSLTargets.cmake") | ||
endif() | ||
- include("${GLSLANG_TARGET_DIR}/glslangTargets.cmake") | ||
- include("${GLSLANG_TARGET_DIR}/SPIRVTargets.cmake") | ||
- | ||
- if (NOT TARGET glslang OR NOT TARGET SPIRV) | ||
- message(WARNING "glslang or SPIRV target not found! USE_SYSTEM_NCNN will be turned off.") | ||
- set(USE_SYSTEM_NCNN OFF) | ||
- endif() | ||
endif() | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
diff --git a/main.cpp b/main.cpp | ||
index bd78c99..75f162f 100644 | ||
--- a/main.cpp | ||
+++ b/main.cpp | ||
@@ -109,7 +109,7 @@ static void print_usage() | ||
fprintf(stdout, " -s scale upscale ratio (1/2/3/4, default=2)\n"); | ||
fprintf(stdout, " -t tile-size tile size (>=32/0=auto, default=0) can be 0,0,0 for multi-gpu\n"); | ||
fprintf(stdout, " -c syncgap-mode sync gap mode (0/1/2/3, default=3)\n"); | ||
- fprintf(stdout, " -m model-path realcugan model path (default=models-se)\n"); | ||
+ fprintf(stdout, " -m model-path realcugan model path (default=REPLACE_MODELS)\n"); | ||
fprintf(stdout, " -g gpu-id gpu device to use (-1=cpu, default=auto) can be 0,1,2 for multi-gpu\n"); | ||
fprintf(stdout, " -j load:proc:save thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu\n"); | ||
fprintf(stdout, " -x enable tta mode\n"); | ||
@@ -442,7 +442,7 @@ int main(int argc, char** argv) | ||
int noise = -1; | ||
int scale = 2; | ||
std::vector<int> tilesize; | ||
- path_t model = PATHSTR("models-se"); | ||
+ path_t model = PATHSTR("REPLACE_MODELS"); | ||
std::vector<int> gpuid; | ||
int jobs_load = 1; | ||
std::vector<int> jobs_proc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
fetchzip, | ||
fetchFromGitHub, | ||
cmake, | ||
vulkan-headers, | ||
vulkan-loader, | ||
glslang, | ||
libwebp, | ||
ncnn, | ||
}: | ||
stdenv.mkDerivation rec { | ||
pname = "realcugan-ncnn-vulkan"; | ||
version = "20220728"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "nihui"; | ||
repo = "realcugan-ncnn-vulkan"; | ||
rev = version; | ||
hash = "sha256-P3Y1B8m1+mpFinacwnvBE2vU150jj6Q12IS6QYNRZ6A="; | ||
}; | ||
sourceRoot = "${src.name}/src"; | ||
|
||
models = fetchzip { | ||
url = "https://github.com/nihui/realcugan-ncnn-vulkan/releases/download/20220728/realcugan-ncnn-vulkan-20220728-ubuntu.zip"; | ||
sha256 = "sha256-71C6taL2Zr1exG5HEXOLy1j9ZMKgkMJjTgNi2hiA7xk="; | ||
}; | ||
|
||
patches = [ | ||
./cmakelists.patch | ||
./models_path.patch | ||
]; | ||
|
||
cmakeFlags = [ | ||
(lib.cmakeBool "USE_SYSTEM_NCNN" true) | ||
(lib.cmakeBool "USE_SYSTEM_WEBP" true) | ||
(lib.cmakeFeature "GLSLANG_TARGET_DIR" "${glslang}/lib/cmake") | ||
]; | ||
|
||
nativeBuildInputs = [ cmake ]; | ||
buildInputs = [ | ||
vulkan-headers | ||
vulkan-loader | ||
glslang | ||
libwebp | ||
ncnn | ||
]; | ||
|
||
postPatch = '' | ||
substituteInPlace main.cpp --replace REPLACE_MODELS $out/share/models-se | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/bin $out/share | ||
cp realcugan-ncnn-vulkan $out/bin/ | ||
cp -r ${models}/models-{nose,pro,se} $out/share | ||
runHook postInstall | ||
''; | ||
|
||
meta = with lib; { | ||
description = "Real-cugan converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan"; | ||
homepage = "https://github.com/nihui/realcugan-ncnn-vulkan"; | ||
license = licenses.mit; | ||
maintainers = with maintainers; [ iynaix ]; | ||
mainProgram = "realcugan-ncnn-vulkan"; | ||
platforms = platforms.all; | ||
}; | ||
} |