-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
187 lines (173 loc) · 6.84 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# static link msvcrt
cmake_policy(SET CMP0091 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
project(vapoursynth-realcugan-ncnn-vulkan)
cmake_minimum_required(VERSION 3.9)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE release CACHE STRING "Choose the type of build" FORCE)
endif()
find_package(Vulkan REQUIRED)
# check glslangValidator
macro(realcugan_add_shader SHADER_SRC)
get_filename_component(SHADER_SRC_NAME_WE ${SHADER_SRC} NAME_WE)
set(SHADER_COMP_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${SHADER_SRC_NAME_WE}.comp.hex.h)
add_custom_command(
OUTPUT ${SHADER_COMP_HEADER}
COMMAND ${CMAKE_COMMAND} -DSHADER_SRC=${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_SRC} -DSHADER_COMP_HEADER=${SHADER_COMP_HEADER} -P "${CMAKE_CURRENT_SOURCE_DIR}/src/generate_shader_comp_header.cmake"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER_SRC}
COMMENT "Preprocessing shader source ${SHADER_SRC_NAME_WE}.comp"
VERBATIM
)
set_source_files_properties(${SHADER_COMP_HEADER} PROPERTIES GENERATED TRUE)
list(APPEND SHADER_SPV_HEX_FILES ${SHADER_COMP_HEADER})
endmacro()
# enable global link time optimization
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT ipo_supported_output)
if(ipo_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "IPO is not supported: ${ipo_supported_output}")
endif()
# build ncnn library
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/deps/ncnn/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! Please update submodules with \"git submodule update --init --recursive\" and try again.")
endif()
option(NCNN_INSTALL_SDK "" OFF)
option(NCNN_PIXEL_ROTATE "" OFF)
option(NCNN_PIXEL_AFFINE "" OFF)
option(NCNN_PIXEL_DRAWING "" OFF)
option(NCNN_VULKAN "" ON)
option(NCNN_VULKAN_ONLINE_SPIRV "" ON)
option(NCNN_BUILD_BENCHMARK "" OFF)
option(NCNN_BUILD_TESTS "" OFF)
option(NCNN_BUILD_TOOLS "" OFF)
option(NCNN_BUILD_EXAMPLES "" OFF)
option(NCNN_DISABLE_RTTI "" ON)
option(NCNN_DISABLE_EXCEPTION "" OFF)
option(NCNN_INT8 "" OFF)
option(WITH_LAYER_absval "" OFF)
option(WITH_LAYER_argmax "" OFF)
option(WITH_LAYER_batchnorm "" OFF)
option(WITH_LAYER_bias "" OFF)
option(WITH_LAYER_bnll "" OFF)
option(WITH_LAYER_concat "" OFF)
option(WITH_LAYER_convolution "" ON)
option(WITH_LAYER_crop "" ON)
option(WITH_LAYER_deconvolution "" ON)
option(WITH_LAYER_dropout "" OFF)
option(WITH_LAYER_eltwise "" ON)
option(WITH_LAYER_elu "" OFF)
option(WITH_LAYER_embed "" OFF)
option(WITH_LAYER_exp "" OFF)
option(WITH_LAYER_flatten "" ON)
option(WITH_LAYER_innerproduct "" ON)
option(WITH_LAYER_input "" ON)
option(WITH_LAYER_log "" OFF)
option(WITH_LAYER_lrn "" OFF)
option(WITH_LAYER_memorydata "" OFF)
option(WITH_LAYER_mvn "" OFF)
option(WITH_LAYER_pooling "" ON)
option(WITH_LAYER_power "" OFF)
option(WITH_LAYER_prelu "" OFF)
option(WITH_LAYER_proposal "" OFF)
option(WITH_LAYER_reduction "" ON)
option(WITH_LAYER_relu "" ON)
option(WITH_LAYER_reshape "" OFF)
option(WITH_LAYER_roipooling "" OFF)
option(WITH_LAYER_scale "" ON)
option(WITH_LAYER_sigmoid "" ON)
option(WITH_LAYER_slice "" OFF)
option(WITH_LAYER_softmax "" OFF)
option(WITH_LAYER_split "" ON)
option(WITH_LAYER_spp "" OFF)
option(WITH_LAYER_tanh "" OFF)
option(WITH_LAYER_threshold "" OFF)
option(WITH_LAYER_tile "" OFF)
option(WITH_LAYER_rnn "" OFF)
option(WITH_LAYER_lstm "" OFF)
option(WITH_LAYER_binaryop "" ON)
option(WITH_LAYER_unaryop "" OFF)
option(WITH_LAYER_convolutiondepthwise "" OFF)
option(WITH_LAYER_padding "" ON)
option(WITH_LAYER_squeeze "" OFF)
option(WITH_LAYER_expanddims "" OFF)
option(WITH_LAYER_normalize "" OFF)
option(WITH_LAYER_permute "" OFF)
option(WITH_LAYER_priorbox "" OFF)
option(WITH_LAYER_detectionoutput "" OFF)
option(WITH_LAYER_interp "" ON)
option(WITH_LAYER_deconvolutiondepthwise "" OFF)
option(WITH_LAYER_shufflechannel "" OFF)
option(WITH_LAYER_instancenorm "" OFF)
option(WITH_LAYER_clip "" OFF)
option(WITH_LAYER_reorg "" OFF)
option(WITH_LAYER_yolodetectionoutput "" OFF)
option(WITH_LAYER_quantize "" OFF)
option(WITH_LAYER_dequantize "" OFF)
option(WITH_LAYER_yolov3detectionoutput "" OFF)
option(WITH_LAYER_psroipooling "" OFF)
option(WITH_LAYER_roialign "" OFF)
option(WITH_LAYER_packing "" ON)
option(WITH_LAYER_requantize "" OFF)
option(WITH_LAYER_cast "" ON)
option(WITH_LAYER_hardsigmoid "" OFF)
option(WITH_LAYER_selu "" OFF)
option(WITH_LAYER_hardswish "" OFF)
option(WITH_LAYER_noop "" OFF)
option(WITH_LAYER_pixelshuffle "" ON)
option(WITH_LAYER_deepcopy "" OFF)
option(WITH_LAYER_mish "" OFF)
option(WITH_LAYER_statisticspooling "" OFF)
option(WITH_LAYER_swish "" OFF)
option(WITH_LAYER_gemm "" OFF)
option(WITH_LAYER_groupnorm "" OFF)
option(WITH_LAYER_layernorm "" OFF)
option(WITH_LAYER_softplus "" OFF)
option(WITH_LAYER_gru "" OFF)
option(WITH_LAYER_multiheadattention "" OFF)
option(WITH_LAYER_gelu "" OFF)
option(WITH_LAYER_convolution1d "" OFF)
option(WITH_LAYER_pooling1d "" OFF)
option(WITH_LAYER_convolutiondepthwise1d "" OFF)
option(WITH_LAYER_convolution3d "" OFF)
option(WITH_LAYER_convolutiondepthwise3d "" OFF)
option(WITH_LAYER_pooling3d "" OFF)
option(WITH_LAYER_matmul "" OFF)
option(WITH_LAYER_deconvolution1d "" OFF)
option(WITH_LAYER_deconvolutiondepthwise1d "" OFF)
option(WITH_LAYER_deconvolution3d "" OFF)
option(WITH_LAYER_deconvolutiondepthwise3d "" OFF)
option(WITH_LAYEY_enisum "" OFF)
option(WITH_LAYER_deformableconv2d "" OFF)
add_subdirectory(deps/ncnn)
# generate-spirv target
set(SHADER_SPV_HEX_FILES)
realcugan_add_shader(src/realcugan_preproc.comp)
realcugan_add_shader(src/realcugan_postproc.comp)
realcugan_add_shader(src/realcugan_4x_postproc.comp)
realcugan_add_shader(src/realcugan_preproc_tta.comp)
realcugan_add_shader(src/realcugan_postproc_tta.comp)
realcugan_add_shader(src/realcugan_4x_postproc_tta.comp)
add_custom_target(generate-spirv DEPENDS ${SHADER_SPV_HEX_FILES})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# check VapourSynth headers
if (UNIX)
set(VAPOURSYNTH_INCLUDE_DIR "/usr/local/include/vapoursynth" CACHE PATH "VapourSynth header files")
if (NOT EXISTS "${VAPOURSYNTH_INCLUDE_DIR}/VSHelper.h")
message(FATAL_ERROR "VapourSynth header files not found, specify with -DVAPOURSYNTH_INCLUDE_DIR")
endif()
elseif (WIN32)
set(VAPOURSYNTH_INCLUDE_DIR "C:/Program Files/VapourSynth/sdk/include/vapoursynth" CACHE PATH "VapourSynth header files")
if (NOT EXISTS "${VAPOURSYNTH_INCLUDE_DIR}/VSHelper.h")
message(FATAL_ERROR "VapourSynth header files not found, specify with -DVAPOURSYNTH_INCLUDE_DIR")
endif()
endif()
# librealcugan
add_library(realcugannv SHARED src/main.cpp src/realcugan.cpp)
target_include_directories(realcugannv PRIVATE ${VAPOURSYNTH_INCLUDE_DIR})
target_link_libraries(realcugannv ncnn ${Vulkan_LIBRARY})
add_dependencies(realcugannv generate-spirv)