2 * Copyright (C) 2018-2019 Lima Project
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
28 #include <pipe/p_defines.h>
30 #include "lima_util.h"
31 #include "lima_parser.h"
33 FILE *lima_dump_command_stream
= NULL
;
35 bool lima_get_absolute_timeout(uint64_t *timeout
)
37 struct timespec current
;
40 if (*timeout
== PIPE_TIMEOUT_INFINITE
)
43 if (clock_gettime(CLOCK_MONOTONIC
, ¤t
))
46 current_ns
= ((uint64_t)current
.tv_sec
) * 1000000000ull;
47 current_ns
+= current
.tv_nsec
;
48 *timeout
+= current_ns
;
53 void lima_dump_blob(FILE *fp
, void *data
, int size
, bool is_float
)
56 for (int i
= 0; i
* 4 < size
; i
++) {
61 fprintf(fp
, "%f, ", ((float *)data
)[i
]);
63 fprintf(fp
, "0x%08x, ", ((uint32_t *)data
)[i
]);
65 if ((i
% 4 == 3) || (i
== size
/ 4 - 1)) {
66 fprintf(fp
, "/* 0x%08x */", MAX2((i
- 3) * 4, 0));
67 if (i
) fprintf(fp
, "\n");
74 lima_dump_vs_command_stream_print(void *data
, int size
, uint32_t start
)
76 if (lima_dump_command_stream
)
77 lima_parse_vs(lima_dump_command_stream
, (uint32_t *)data
, size
, start
);
81 lima_dump_plbu_command_stream_print(void *data
, int size
, uint32_t start
)
83 if (lima_dump_command_stream
)
84 lima_parse_plbu(lima_dump_command_stream
, (uint32_t *)data
, size
, start
);
88 lima_dump_rsw_command_stream_print(void *data
, int size
, uint32_t start
)
90 if (lima_dump_command_stream
)
91 lima_parse_render_state(lima_dump_command_stream
, (uint32_t *)data
, size
, start
);
95 lima_dump_command_stream_print(void *data
, int size
, bool is_float
,
98 if (lima_dump_command_stream
) {
101 vfprintf(lima_dump_command_stream
, fmt
, ap
);
104 lima_dump_blob(lima_dump_command_stream
, data
, size
, is_float
);