3 # Copyright © Collabora Ltd.
4 # SPDX-License-Identifier: MIT
7 """ Module providing an ANGLE dump backend for replayer """
9 from os
import chdir
, path
, rename
10 from typing
import List
12 from framework
import core
, exceptions
14 from .abstract
import DumpBackend
, dump_handler
15 from .register
import Registry
23 class ANGLETraceBackend(DumpBackend
):
24 """ replayer's ANGLE dump backend
26 This backend uses ANGLE for replaying its traces.
29 _get_last_frame_call
= None # this silences the abstract-not-subclassed warning
31 def __init__(self
, trace_path
: str, output_dir
: str = None, calls
: List
[str] = None, **kwargs
: str) -> None:
32 super().__init
__(trace_path
, output_dir
, calls
, **kwargs
)
33 extension
: str = path
.splitext(self
._trace
_path
)[1]
35 if extension
== '.so':
36 angle_bin
: str = core
.get_option('PIGLIT_REPLAY_ANGLE_BINARY',
37 ('replay', 'angle_bin'),
38 default
='./angle_trace_tests')
39 self
._retrace
_cmd
= [angle_bin
]
41 raise exceptions
.PiglitFatalError(
42 f
'Invalid trace_path: "{self._trace_path}" tried to be dumped '
43 'by the ANGLETraceBackend.\n')
47 '''dumps screenshots'''
48 # we start from library, including path and we need only the test name here
49 lib_name
: str = self
._trace
_path
.split("libangle_restricted_traces_")[1]
50 test_name
: str = lib_name
[:-3]
52 # change working directory into where .so is placed
53 angle_path
: str = path
.dirname(self
._trace
_path
)
56 cmd
= self
._retrace
_cmd
+ ['--one-frame-only',
57 '--gtest_filter=TraceTest.' + test_name
,
59 '--screenshot-dir', self
._output
_dir
,
61 self
._run
_logged
_command
(cmd
, None)
63 angle_screenshot
: str = path
.join(self
._output
_dir
, 'angle_vulkan_' + test_name
+ '.png')
64 piglit_screenshot
: str = f
'{path.join(self._output_dir, path.basename(self._trace_path))}-.png'
65 rename(angle_screenshot
, piglit_screenshot
)
70 backend
=ANGLETraceBackend
,