1# Copyright © 2020 Google, Inc 2 3# Permission is hereby granted, free of charge, to any person obtaining a copy 4# of this software and associated documentation files (the "Software"), to deal 5# in the Software without restriction, including without limitation the rights 6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7# copies of the Software, and to permit persons to whom the Software is 8# furnished to do so, subject to the following conditions: 9 10# The above copyright notice and this permission notice shall be included in 11# all copies or substantial portions of the Software. 12 13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19# SOFTWARE. 20 21if with_tests 22 diff = find_program('diff') 23endif 24 25# Shared cmdstream decoding: 26libfreedreno_cffdec = static_library( 27 'freedreno_cffdec', 28 [ 29 'buffers.c', 30 'buffers.h', 31 'cffdec.c', 32 'cffdec.h', 33 'pager.c', 34 'pager.h', 35 'rnnutil.c', 36 'rnnutil.h', 37 'util.h', 38 ], 39 include_directories: [ 40 inc_freedreno, 41 inc_freedreno_rnn, 42 inc_include, 43 inc_src, 44 ], 45 c_args : [ no_override_init_args ], 46 gnu_symbol_visibility: 'hidden', 47 dependencies: [], 48 link_with: [ 49 libfreedreno_rnn, 50 libfreedreno_ir2, # for disasm_a2xx 51 libfreedreno_ir3, # for disasm_a3xx 52 _libmesa_util, 53 ], 54 build_by_default: false, 55) 56 57if dep_libarchive.found() 58 libfreedreno_io = static_library( 59 'freedreno_io', 60 [ 61 'io.c', 62 'io.h', 63 ], 64 include_directories: [], 65 c_args : [no_override_init_args], 66 gnu_symbol_visibility: 'hidden', 67 dependencies: [ 68 dep_libarchive, 69 ], 70 build_by_default: false, 71 ) 72 73 foreach kmd : freedreno_kmds 74 if not (kmd in ['kgsl', 'msm', 'wsl']) 75 warning('replay not supported for ' + kmd + ' KMD') 76 continue 77 endif 78 79 # Only append the KMD name if there are multiple KMDs 80 if freedreno_kmds.length() == 1 81 replay_name = 'replay' 82 else 83 replay_name = 'replay-' + kmd 84 endif 85 86 replay_flags = [] 87 replay_deps = [] 88 if kmd == 'kgsl' 89 replay_flags += '-DFD_REPLAY_KGSL' 90 elif kmd == 'msm' 91 replay_flags += '-DFD_REPLAY_MSM' 92 replay_deps += dep_libdrm 93 elif kmd == 'wsl' 94 replay_flags += '-DFD_REPLAY_WSL' 95 endif 96 97 replay = executable( 98 replay_name, 99 [ 100 'replay.c' 101 ], 102 include_directories: [ 103 inc_freedreno, 104 inc_include, 105 inc_src, 106 ], 107 c_args : [no_override_init_args, replay_flags], 108 gnu_symbol_visibility: 'hidden', 109 dependencies: replay_deps, 110 link_with: [ 111 libfreedreno_cffdec, 112 libfreedreno_io, 113 ], 114 build_by_default: with_tools.contains('freedreno'), 115 install: install_fd_decode_tools, 116 ) 117 endforeach 118 119 rddecompiler = executable( 120 'rddecompiler', 121 [ 122 'rddecompiler.c', 123 freedreno_xml_header_files, 124 ], 125 include_directories: [ 126 inc_freedreno, 127 inc_freedreno_rnn, 128 inc_include, 129 inc_src, 130 ], 131 c_args : [no_override_init_args], 132 gnu_symbol_visibility: 'hidden', 133 dependencies: [ 134 dep_libdrm, 135 ], 136 link_with: [ 137 libfreedreno_cffdec, 138 libfreedreno_io, 139 ], 140 build_by_default: with_tools.contains('freedreno'), 141 install: install_fd_decode_tools, 142 ) 143else 144 warning('libarchive not found, not building replay or rddecompiler') 145endif 146 147if dep_lua.found() and dep_libarchive.found() 148 cffdump = executable( 149 'cffdump', 150 [ 151 'cffdump.c', 152 'script.c', 153 'script.h' 154 ], 155 include_directories: [ 156 inc_freedreno, 157 inc_freedreno_rnn, 158 inc_include, 159 inc_src, 160 ], 161 c_args : [no_override_init_args], 162 gnu_symbol_visibility: 'hidden', 163 dependencies: [ 164 dep_lua, 165 ], 166 link_with: [ 167 libfreedreno_cffdec, 168 libfreedreno_io, 169 ], 170 build_by_default: with_tools.contains('freedreno'), 171 install: install_fd_decode_tools, 172 ) 173 174 if with_tests 175 # dump only a single frame, and single tile pass, to keep the 176 # reference output size managable 177 cffdump_tests = [ 178 ['fd-clouds', ['--frame', '0', '--once']], 179 ['es2gears-a320', ['--frame', '0', '--once']], 180 ['glxgears-a420', ['--frame', '1', '--once']], 181 ['compute-a540', ['--once']], 182 ['dEQP-GLES2.functional.texture.specification.basic_teximage2d.rgba16f_2d', ['--once']], 183 ['dEQP-VK.draw.indirect_draw.indexed.indirect_draw_count.triangle_list', ['--frame', '0', '--once']], 184 # Test a lua script to ensure we don't break scripting API 185 ['shadow', ['--script', files('scripts/parse-submits.lua')]], 186 ] 187 foreach cffdump_test: cffdump_tests 188 name = cffdump_test[0] 189 args = cffdump_test[1] 190 191 log = custom_target(name + '.log', 192 output: name + '.log', 193 command: [cffdump, '--unit-test', args, files('../.gitlab-ci/traces/' + name + '.rd.gz')], 194 capture: true, 195 ) 196 test('cffdump-' + name, 197 diff, 198 args: ['-u', files('../.gitlab-ci/reference/' + name + '.log'), log], 199 suite: 'freedreno', 200 workdir: dir_source_root 201 ) 202 203 endforeach 204 endif 205else 206 warning('lua or libarchive not found, not building cffdump') 207endif 208 209crashdec = executable( 210 'crashdec', 211 [ 212 'crashdec.c', 213 'crashdec.h', 214 'crashdec-hfi.c', 215 'crashdec-mempool.c', 216 'crashdec-prefetch.c', 217 ], 218 include_directories: [ 219 inc_freedreno, 220 inc_freedreno_rnn, 221 inc_include, 222 inc_src, 223 ], 224 gnu_symbol_visibility: 'hidden', 225 dependencies: [], 226 link_with: [ 227 libfreedreno_cffdec, 228 ], 229 build_by_default: with_tools.contains('freedreno'), 230 install: install_fd_decode_tools, 231) 232 233if with_tests 234 crashdec_tests = [ 235 ['crash', ['-sf']], 236 ['crash_prefetch', ['-sf']], 237 ['prefetch-test', ['-sf']], 238 ] 239 foreach crashdec_test: crashdec_tests 240 name = crashdec_test[0] 241 args = crashdec_test[1] 242 243 log = custom_target(name + '.log', 244 output: name + '.log', 245 command: [crashdec, args, files('../.gitlab-ci/traces/' + name + '.devcore')], 246 capture: true, 247 env: {'GALLIUM_DUMP_CPU': 'false'}, 248 ) 249 250 test('crashdec-' + name, 251 diff, 252 args: ['-u', files('../.gitlab-ci/reference/' + name + '.log'), log], 253 suite: 'freedreno', 254 workdir: dir_source_root 255 ) 256 257 endforeach 258endif 259 260if dep_libarchive.found() 261 pgmdump = executable( 262 'pgmdump', 263 'pgmdump.c', 264 include_directories: [ 265 inc_freedreno, 266 inc_include, 267 inc_src, 268 ], 269 gnu_symbol_visibility: 'hidden', 270 dependencies: [], 271 link_with: [ 272 libfreedreno_cffdec, 273 libfreedreno_io, 274 libfreedreno_ir2, # for disasm_a2xx 275 libfreedreno_ir3, # for disasm_a3xx 276 ], 277 build_by_default: with_tools.contains('freedreno'), 278 install: false, 279 ) 280 pgmdump2 = executable( 281 'pgmdump2', 282 'pgmdump2.c', 283 include_directories: [ 284 inc_freedreno, 285 inc_include, 286 inc_src, 287 ], 288 gnu_symbol_visibility: 'hidden', 289 dependencies: [], 290 link_with: [ 291 libfreedreno_cffdec, 292 libfreedreno_io, 293 libfreedreno_ir2, # for disasm_a2xx 294 libfreedreno_ir3, # for disasm_a3xx 295 ], 296 build_by_default: with_tools.contains('freedreno'), 297 install: false, 298 ) 299else 300 warning('libarchive not found, not building pgmdump') 301endif 302