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    'libfreedreno_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  )
72endif
73
74if dep_lua.found() and dep_libarchive.found()
75  cffdump = executable(
76    'cffdump',
77    [
78      'cffdump.c',
79      'script.c',
80      'script.h'
81    ],
82    include_directories: [
83      inc_freedreno,
84      inc_freedreno_rnn,
85      inc_include,
86      inc_src,
87    ],
88    c_args : [no_override_init_args],
89    gnu_symbol_visibility: 'hidden',
90    dependencies: [
91      dep_lua,
92    ],
93    link_with: [
94      libfreedreno_cffdec,
95      libfreedreno_io,
96    ],
97    build_by_default: with_tools.contains('freedreno'),
98    install: install_fd_decode_tools,
99  )
100
101  if with_tests
102    # dump only a single frame, and single tile pass, to keep the
103    # reference output size managable
104    cffdump_tests = [
105      ['fd-clouds', ['--frame', '0', '--once']],
106      ['es2gears-a320', ['--frame', '0', '--once']],
107      ['glxgears-a420', ['--frame', '1', '--once']],
108      ['dEQP-GLES2.functional.texture.specification.basic_teximage2d.rgba16f_2d', ['--once']],
109      ['dEQP-VK.draw.indirect_draw.indexed.indirect_draw_count.triangle_list', ['--frame', '0', '--once']],
110      # Test a lua script to ensure we don't break scripting API
111      ['shadow', ['--script', files(join_paths(meson.current_source_dir(), 'scripts', 'parse-submits.lua'))]],
112    ]
113    foreach cffdump_test: cffdump_tests
114      name = cffdump_test[0]
115      args = cffdump_test[1]
116
117      log = custom_target(name + '.log',
118        output: name + '.log',
119        command: [cffdump, '--unit-test', args, files('../.gitlab-ci/traces/' + name + '.rd.gz')],
120        capture: true,
121      )
122      test('cffdump-' + name,
123        diff,
124        args: ['-u', files('../.gitlab-ci/reference/' + name + '.log'), log],
125        suite: 'freedreno',
126        workdir: meson.source_root()
127      )
128
129    endforeach
130  endif
131endif
132
133crashdec = executable(
134  'crashdec',
135  [
136    'crashdec.c',
137    'crashdec.h',
138    'crashdec-hfi.c',
139    'crashdec-mempool.c',
140  ],
141  include_directories: [
142    inc_freedreno,
143    inc_freedreno_rnn,
144    inc_include,
145    inc_src,
146  ],
147  gnu_symbol_visibility: 'hidden',
148  dependencies: [],
149  link_with: [
150    libfreedreno_cffdec,
151  ],
152  build_by_default: with_tools.contains('freedreno'),
153  install: install_fd_decode_tools,
154)
155
156if with_tests
157  crashdec_output = custom_target('crashdec.txt',
158    output: 'crashdec.txt',
159    command: [crashdec, '-sf', files('../.gitlab-ci/traces/crash.devcore')],
160    capture: true
161  )
162  test('crashdec',
163    diff,
164    args: ['-u', files('../.gitlab-ci/reference/crash.log'), crashdec_output],
165    suite: 'freedreno',
166    workdir: meson.source_root()
167  )
168endif
169
170if dep_libarchive.found()
171  pgmdump = executable(
172    'pgmdump',
173    'pgmdump.c',
174    include_directories: [
175      inc_freedreno,
176      inc_include,
177      inc_src,
178    ],
179    gnu_symbol_visibility: 'hidden',
180    dependencies: [],
181    link_with: [
182      libfreedreno_cffdec,
183      libfreedreno_io,
184      libfreedreno_ir2,  # for disasm_a2xx
185      libfreedreno_ir3,  # for disasm_a3xx
186    ],
187    build_by_default: with_tools.contains('freedreno'),
188    install: false,
189  )
190  pgmdump2 = executable(
191    'pgmdump2',
192    'pgmdump2.c',
193    include_directories: [
194      inc_freedreno,
195      inc_include,
196      inc_src,
197    ],
198    gnu_symbol_visibility: 'hidden',
199    dependencies: [],
200    link_with: [
201      libfreedreno_cffdec,
202      libfreedreno_io,
203      libfreedreno_ir2,  # for disasm_a2xx
204      libfreedreno_ir3,  # for disasm_a3xx
205    ],
206    build_by_default: with_tools.contains('freedreno'),
207    install: false,
208  )
209endif
210