diff options
author | Andres Gomez <agomez@igalia.com> | 2021-02-08 17:24:46 +0200 |
---|---|---|
committer | Andres Gomez <agomez@igalia.com> | 2021-02-12 16:23:25 +0200 |
commit | d4d9353b7290ed22cb7349226a8e4017402d3f02 (patch) | |
tree | 42f3b99d974b1cd82820ddcbf980ac6c15fd16e7 /framework | |
parent | f23e73b2434ab79fc98c21a90237aa93884287c1 (diff) |
framework/replay: adapt GFXReconstruct backend to >=0.9.4
The info tool is now spitting the total frames in the 3rd line.
Also, we can now get rid of the VK_LAYER_LUNARG_screenshot layer and
use replay's screenshot built-in flag instead.
v2:
- Check the last frame through a regexp (Martin).
- Check replay's minimum supported version (Martin).
Signed-off-by: Andres Gomez <agomez@igalia.com>
Reviewed-by: Martin Peres <martin.peres@mupuf.org>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/473>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/replay/backends/abstract.py | 2 | ||||
-rw-r--r-- | framework/replay/backends/gfxreconstruct.py | 67 |
2 files changed, 46 insertions, 23 deletions
diff --git a/framework/replay/backends/abstract.py b/framework/replay/backends/abstract.py index 905549b8c..f84a4e0e3 100644 --- a/framework/replay/backends/abstract.py +++ b/framework/replay/backends/abstract.py @@ -95,7 +95,7 @@ class DumpBackend(metaclass=abc.ABCMeta): print(logoutput.decode(errors='replace')) if ret.returncode: raise RuntimeError( - '[dump_traces_images] Process failed with error code: {}'.format( + '[dump_trace_images] Process failed with error code: {}'.format( ret.returncode)) diff --git a/framework/replay/backends/gfxreconstruct.py b/framework/replay/backends/gfxreconstruct.py index 07cb3b846..b247a5b67 100644 --- a/framework/replay/backends/gfxreconstruct.py +++ b/framework/replay/backends/gfxreconstruct.py @@ -28,11 +28,14 @@ """ Module providing a GFXReconstruct dump backend for replayer """ import os +import re import subprocess +from packaging import version from os import path from framework import core, exceptions +from . import DumpBackendError from .abstract import DumpBackend, dump_handler from .register import Registry @@ -43,6 +46,11 @@ __all__ = [ ] +_MIN_VERSION = version.Version('0.9.4') +_VERSION_RE = re.compile('\s*GFXReconstruct Version\s*([0-9]\.[0-9]\.[0-9])') + +_TOTAL_FRAMES_RE = re.compile('\s*Total frames:\s*([0-9]*)') + class GFXReconstructBackend(DumpBackend): """ replayer's GFXReconstruct dump backend @@ -74,44 +82,59 @@ class GFXReconstructBackend(DumpBackend): ret = subprocess.run(cmd, stdout=subprocess.PIPE) lines = ret.stdout.decode(errors='replace').splitlines() print(ret.stdout.decode(errors='replace')) - if lines: - c = lines[0].split(': ', 1) - if len(c) > 1 and c[1].isnumeric(): - return int(c[1]) - return -1 + try: + frames = re.search(_TOTAL_FRAMES_RE, lines[2]) + return int(frames.group(1)) + except: + return -1 + + def _check_version(self, gfxrecon_replay_bin): + cmd = [gfxrecon_replay_bin, '--version'] + ret = subprocess.run(cmd, stdout=subprocess.PIPE) + lines = ret.stdout.decode(errors='replace').splitlines() + print(ret.stdout.decode(errors='replace')) + try: + v = re.search(_VERSION_RE, lines[1]) + current = version.Version(v.group(1)) + except: + raise DumpBackendError( + '[dump_trace_images] Unable to check the current ' + 'gfxrecon-replay version.') + if _MIN_VERSION > current: + raise DumpBackendError( + '[dump_trace_images] The current gfxrecon-replay version ' + 'is {}. Try to update, at least to the {} version.'.format( + current, _MIN_VERSION)) @dump_handler def dump(self): from PIL import Image outputprefix = path.join(self._output_dir, path.basename(self._trace_path)) - if not self._calls: - # FIXME: The VK_LAYER_LUNARG_screenshot numbers the calls from 0 to - # (total-num-calls - 1) while gfxreconstruct does it from 1 to - # total-num-calls: - # https://github.com/LunarG/gfxreconstruct/issues/284 - self._calls = [str(max(-1, self._get_last_frame_call() - 1))] gfxrecon_replay_bin = core.get_option( 'PIGLIT_REPLAY_GFXRECON_REPLAY_BINARY', ('replay', 'gfxrecon-replay_bin'), default='gfxrecon-replay') + self._check_version(gfxrecon_replay_bin) + if not self._calls: + self._calls = [str(self._get_last_frame_call())] gfxrecon_replay_extra_args = core.get_option( 'PIGLIT_REPLAY_GFXRECON_REPLAY_EXTRA_ARGS', ('replay', 'gfxrecon-replay_extra_args'), default='').split() - cmd = ([gfxrecon_replay_bin] - + gfxrecon_replay_extra_args + [self._trace_path]) - env = os.environ.copy() - env['VK_INSTANCE_LAYERS'] = 'VK_LAYER_LUNARG_screenshot' - env['VK_SCREENSHOT_FRAMES'] = ','.join(self._calls) - env['VK_SCREENSHOT_DIR'] = self._output_dir - self._run_logged_command(cmd, env) + cmd = ([gfxrecon_replay_bin] + gfxrecon_replay_extra_args + + ['--screenshots', ','.join(self._calls), + '--screenshot-dir', self._output_dir, + self._trace_path]) + self._run_logged_command(cmd, None) for c in self._calls: - ppm = '{}.ppm'.format(path.join(self._output_dir, c)) + bmp = '{}_frame_{}.bmp'.format(path.join(self._output_dir, + 'screenshot'), + c) outputfile = '{}-{}.png'.format(outputprefix, c) - print('Writing: {} to {}'.format(ppm, outputfile)) - Image.open(ppm).save(outputfile) - os.remove(ppm) + print('Writing: {} to {}'.format(bmp, outputfile)) + Image.open(bmp).save(outputfile) + os.remove(bmp) REGISTRY = Registry( |