cl: Fix missing OpenCL 3.0 definition
[piglit.git] / framework / replay / backends / angle.py
blob9610420950f6df4eed1f36384925952324c3bb2e
1 # coding=utf-8
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
17 __all__ = [
18 'REGISTRY',
19 'ANGLETraceBackend',
23 class ANGLETraceBackend(DumpBackend):
24 """ replayer's ANGLE dump backend
26 This backend uses ANGLE for replaying its traces.
27 """
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]
40 else:
41 raise exceptions.PiglitFatalError(
42 f'Invalid trace_path: "{self._trace_path}" tried to be dumped '
43 'by the ANGLETraceBackend.\n')
45 @dump_handler
46 def dump(self):
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)
54 chdir(angle_path)
56 cmd = self._retrace_cmd + ['--one-frame-only',
57 '--gtest_filter=TraceTest.' + test_name,
58 '--use-angle=vulkan',
59 '--screenshot-dir', self._output_dir,
60 '--save-screenshots']
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)
68 REGISTRY = Registry(
69 extensions=['.so'],
70 backend=ANGLETraceBackend,