-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
219 lines (198 loc) · 9.57 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
cmake_minimum_required(VERSION 3.13)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
enable_testing()
project(tracetooltests)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 17)
if(NOT DEFINED WINDOWSYSTEM) # to prevent overwriting toolchain setting
set(WINDOWSYSTEM "x11" CACHE STRING "Window system to use for build")
set_property(CACHE WINDOWSYSTEM PROPERTY STRINGS fbdev sdl pbuffer x11)
endif()
if(WINDOWSYSTEM MATCHES "sdl")
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
set(IT_LIBS ${SDL2_LIBRARIES})
set(IT_DEFINES "SDL")
message(STATUS "Building for SDL2")
elseif (WINDOWSYSTEM MATCHES "fbdev")
set(IT_DEFINES "FBDEV")
message(STATUS "Building for fbdev")
elseif (WINDOWSYSTEM MATCHES "x11" OR WINDOWSYSTEM MATCHES "X11" OR WINDOWSYSTEM MATCHES "xcb")
set(IT_DEFINES X11 VK_USE_PLATFORM_XCB_KHR)
find_package(X11 REQUIRED)
include_directories(${X11_INCLUDE_DIR})
set(IT_LIBS ${X11_X11_LIB})
message(STATUS "Building for X11")
find_package(XCB REQUIRED)
set(XCB_LIBRARIES ${XCB_LIBRARIES} ${X11_LIBRARIES})
elseif (WINDOWSYSTEM MATCHES "pbuffers")
set(IT_DEFINES "PBUFFERS")
message(STATUS "Building for pbuffers")
else()
message(FATAL_ERROR "Invalid window system: ${WINDOWSYSTEM}")
endif()
set(IT_CFLAGS "-Wall -g")
if (SANITIZE)
# before running test with sanitizer, recommend to run these two:
# export LSAN_OPTIONS='detect_leaks=0'
# export ASAN_OPTIONS='symbolize=1,abort_on_error=1'
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -fsanitize=${SANITIZE} -fsanitize-undefined-trap-on-error -fuse-ld=gold")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -fsanitize=${SANITIZE} -fsanitize-undefined-trap-on-error -fuse-ld=gold")
endif()
set(SYMLINK_DIR "$ENV{HOME}/.local/share/benchmarking")
install(DIRECTORY DESTINATION "${SYMLINK_DIR}")
function(gles_test test_name)
add_executable(gles_${ARGV0} src/util.cpp src/util.h src/gles_${ARGV0}.cpp src/gles_common.cpp src/gles_common.h)
target_link_libraries(gles_${ARGV0} PRIVATE -Wl,--add-needed EGL GLESv2 pthread ${IT_LIBS})
target_link_directories(gles_${ARGV0} PRIVATE ${API_LIBS})
target_compile_definitions(gles_${ARGV0} PUBLIC ${IT_DEFINES})
set_target_properties(gles_${ARGV0} PROPERTIES COMPILE_FLAGS ${IT_CFLAGS})
target_include_directories(gles_${ARGV0} PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR} ${GLES_HEADERS} ${EGL_HEADERS})
install(TARGETS gles_${ARGV0} DESTINATION tests)
add_test(NAME gles_test_${ARGV0} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/gles_${ARGV0})
file(COPY ${PROJECT_SOURCE_DIR}/benchmarking/gles_${ARGV0}.bench DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/benchmarking/gles_${ARGV0}.bench DESTINATION tests)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_INSTALL_PREFIX}/tests/gles_${ARGV0}.bench ${SYMLINK_DIR}/gles_${ARGV0}.bench)")
endfunction()
function(vulkan_test_build test_name)
add_executable(vulkan_${ARGV0} src/vulkan_${ARGV0}.cpp src/vulkan_common.cpp src/vulkan_common.h src/vulkan_compute_common.cpp src/vulkan_compute_common.h
src/vulkan_window_common.cpp src/vulkan_window_common.h src/util.cpp src/util.h)
target_link_libraries(vulkan_${ARGV0} PRIVATE vulkan pthread ${IT_LIBS} ${XCB_LIBRARIES})
target_link_directories(vulkan_${ARGV0} PRIVATE ${API_LIBS})
target_compile_definitions(vulkan_${ARGV0} PUBLIC ${IT_DEFINES})
set_target_properties(vulkan_${ARGV0} PROPERTIES COMPILE_FLAGS ${IT_CFLAGS})
target_include_directories(vulkan_${ARGV0} PUBLIC ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/external/Vulkan-Headers/include)
install(TARGETS vulkan_${ARGV0} DESTINATION tests)
endfunction()
function(vulkan_test test_name)
vulkan_test_build(${ARGV0})
add_test(NAME vulkan_${ARGV0} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/vulkan_${ARGV0})
set(ENABLE_JSON "{\"target\": \"vulkan_${ARGV0}\"}")
set_tests_properties(vulkan_${ARGV0} PROPERTIES SKIP_RETURN_CODE 77 ENVIRONMENT "VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation;BENCHMARKING_ENABLE_JSON=${ENABLE_JSON}")
file(COPY ${PROJECT_SOURCE_DIR}/benchmarking/vulkan_${ARGV0}.bench DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/benchmarking/vulkan_${ARGV0}.bench DESTINATION tests)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_INSTALL_PREFIX}/tests/vulkan_${ARGV0}.bench ${SYMLINK_DIR}/vulkan_${ARGV0}.bench)")
endfunction()
function(vulkan_test_extra test_name test_exe)
add_test(NAME vulkan_${ARGV0} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/vulkan_${ARGV1} ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5} ${ARGV6} ${ARGV7})
set(ENABLE_JSON "{\"target\": \"vulkan_${ARGV0}\"}")
set_tests_properties(vulkan_${ARGV0} PROPERTIES SKIP_RETURN_CODE 77 ENVIRONMENT "VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation;BENCHMARKING_ENABLE_JSON=${ENABLE_JSON}")
endfunction()
if (NOT NO_GLES MATCHES "1")
gles_test(dummy_1)
gles_test(multisurface_1)
gles_test(multithread_1)
gles_test(multithread_2)
gles_test(multithread_3)
gles_test(bindbufferrange_1)
gles_test(compute_1)
gles_test(compute_2)
gles_test(compute_3)
gles_test(programs_1)
gles_test(imagetex_1)
gles_test(indirectdraw_1)
gles_test(indirectdraw_2)
gles_test(drawrange_1)
gles_test(drawrange_2)
gles_test(draw_1)
gles_test(draw_2)
gles_test(multisample_1)
gles_test(vertexbuffer_1)
gles_test(khr_debug)
gles_test(extension_pack_es31a)
gles_test(copy_image_1)
gles_test(geometry_shader_1)
gles_test(khr_blend_equation_advanced)
gles_test(oes_sample_shading)
gles_test(ext_texture_border_clamp)
gles_test(oes_texture_stencil8)
gles_test(ext_gpu_shader5)
gles_test(ext_texture_sRGB_decode)
gles_test(ext_texture_buffer)
gles_test(ext_texture_cube_map_array)
gles_test(uninit_texture_1)
gles_test(uninit_texture_2)
gles_test(texsubimage3d)
endif()
if (NOT NO_VULKAN MATCHES "1")
vulkan_test(general)
vulkan_test(init)
vulkan_test(copying_1)
vulkan_test_extra(copying_1_test_0_0 copying_1 -q 0 -m 0)
vulkan_test_extra(copying_1_test_1_0 copying_1 -q 1 -m 0 -c 5)
vulkan_test_extra(copying_1_test_2_0 copying_1 -q 2 -m 0)
vulkan_test_extra(copying_1_test_3_0 copying_1 -q 3 -m 0)
vulkan_test_extra(copying_1_test_4_0 copying_1 -q 4 -m 0)
vulkan_test_extra(copying_1_test_0_1 copying_1 -q 0 -m 1 -c 7)
vulkan_test_extra(copying_1_test_0_2 copying_1 -q 0 -m 0 -f 1)
vulkan_test_extra(copying_1_test_0_3 copying_1 -q 0 -m 2)
vulkan_test_extra(copying_1_test_0_4 copying_1 -q 0 -m 1 -D)
vulkan_test_extra(copying_1_test_1_1 copying_1 -q 1 -m 1)
vulkan_test_extra(copying_1_test_2_1 copying_1 -q 2 -m 1)
vulkan_test_extra(copying_1_test_3_1 copying_1 -q 3 -m 1)
vulkan_test_extra(copying_1_test_4_1 copying_1 -q 4 -m 1)
vulkan_test_extra(copying_1_test_1_2 copying_1 -q 1 -m 2)
vulkan_test_extra(copying_1_test_2_2 copying_1 -q 2 -m 2)
vulkan_test_extra(copying_1_test_3_2 copying_1 -q 3 -m 2)
vulkan_test_extra(copying_1_test_4_2 copying_1 -q 4 -m 2 -b 1000)
vulkan_test_extra(copying_1_test_5_2 copying_1 -q 5 -m 1 -b 1000)
vulkan_test_extra(copying_1_test_6_0 copying_1 -V 0)
vulkan_test_extra(copying_1_test_6_1 copying_1 -V 2)
vulkan_test_extra(copying_1_test_6_2 copying_1 -V 2 -B -D)
vulkan_test_extra(copying_1_test_6_3 copying_1 -V 3)
vulkan_test(thread_1)
vulkan_test(thread_2)
vulkan_test(thread_3)
vulkan_test(memory_1)
vulkan_test(memory_1_1)
vulkan_test(as_1)
vulkan_test(as_2)
vulkan_test(as_3)
vulkan_test(as_4)
vulkan_test(as_5)
vulkan_test(copying_2)
vulkan_test_extra(copying_2_test_0_0_0 copying_2 -q 0 -f 0 -m 0 -t 3)
vulkan_test_extra(copying_2_test_0_0_1 copying_2 -q 0 -f 0 -m 1 -t 3)
vulkan_test_extra(copying_2_test_0_0_2 copying_2 -q 0 -f 0 -m 2 -t 3)
vulkan_test_extra(copying_2_test_1_0_0 copying_2 -q 1 -f 0 -m 0 -t 3)
vulkan_test_extra(copying_2_test_1_1_0 copying_2 -q 1 -f 0 -m 1 -c 5 -t 3)
vulkan_test_extra(copying_2_test_1_1_1 copying_2 -q 1 -f 0 -m 2 -b 1000 -t 3)
vulkan_test_extra(copying_2_test_2_0_0 copying_2 -V 3) # vulkan 1.3 required
vulkan_test(copying_3)
vulkan_test_extra(copying_3_test_0 copying_3 -c 0 -t 3)
vulkan_test_extra(copying_3_test_1 copying_3 -c 1 -t 3)
vulkan_test_extra(copying_3_test_2 copying_3 -c 2 -t 3)
vulkan_test(tool_1)
vulkan_test(feature_1)
vulkan_test(feature_2)
vulkan_test(debug_marker)
vulkan_test(debug_report)
vulkan_test(compute_1)
add_custom_command(TARGET vulkan_compute_1 PRE_BUILD COMMAND rm -f test.bin)
vulkan_test_extra(vulkan_compute_1_test_0 compute_1 -pc) # pipelinecache, only use
vulkan_test_extra(vulkan_compute_1_test_1 compute_1 -pc -pcf ${CMAKE_CURRENT_BINARY_DIR}/test.bin) # +save
vulkan_test_extra(vulkan_compute_1_test_2 compute_1 -pc -pcf ${CMAKE_CURRENT_BINARY_DIR}/test.bin) # +read
vulkan_test_extra(vulkan_compute_1_test_3 compute_1 -I) # indirect
vulkan_test_extra(vulkan_compute_1_test_4 compute_1 -I -ioff 7) # indirect, offset
vulkan_test_extra(vulkan_compute_1_test_5 compute_1 -i) # image output
vulkan_test(compute_2)
vulkan_test_extra(vulkan_compute_2_test_0 compute_2 -q 1 -s 1)
vulkan_test(compute_3)
vulkan_test_extra(vulkan_compute_3_test_0 compute_3 --times 3) # repeat
vulkan_test(compute_aliasing)
vulkan_test(compute_bda_sc) # buffer device address through specialization constants
vulkan_test(compute_bda_pushconstant) # buffer device address through push constants
vulkan_test(compute_bda_ubo) # buffer device address through uniform buffer objects
vulkan_test_extra(compute_bda_ubo_1_test_1 compute_bda_ubo --ssbo)
vulkan_test(deferred_1)
vulkan_test(pipelinecache_1)
vulkan_test(multidevice_1)
vulkan_test(multiinstance)
vulkan_test(stress_1)
vulkan_test(pnext_chain)
# These are only built, not automatically run as part of the test suite
vulkan_test_build(window_1)
vulkan_test_build(memory_mprotect)
vulkan_test_build(mesh_1)
endif()