Commit 686f9768 authored by Alexandros Frantzis's avatar Alexandros Frantzis

scripts: Support a new trace type used for testing

The 'testtrace' trace type contains a text representation
of the RGBA (rrggbbaa) color to fill a 32x32 image with.
Signed-off-by: Alexandros Frantzis's avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
parent 2a0b2753
......@@ -76,6 +76,18 @@ def dump_with_renderdoc(trace, calls, device_name):
log_path = Path(outputdir) / (Path(trace).name + ".log")
run_logged_command(cmd, log_path)
def dump_with_testtrace(trace, calls, device_name):
import png
outputdir_path = Path(trace).parent / "test" / device_name
outputdir_path.mkdir(parents=True, exist_ok=True)
with Path(trace).open() as f:
rgba = f.read()
color = [int(rgba[0:2], 16), int(rgba[2:4], 16),
int(rgba[4:6], 16), int(rgba[6:8], 16)]
for c in calls:
outputfile = str(outputdir_path / Path(trace).name) + "-" + c + ".png"
png.from_array([color * 32] * 32, 'RGBA').save(outputfile)
def dump_from_trace(trace, device_name):
log("Info", "Dumping trace %s" % trace, end='... ')
calls = get_calls_num(trace, device_name)
......@@ -85,6 +97,8 @@ def dump_from_trace(trace, device_name):
dump_with_apitrace(trace, calls, device_name)
elif trace_type == TraceType.RENDERDOC:
dump_with_renderdoc(trace, calls, device_name)
elif trace_type == TraceType.TESTTRACE:
dump_with_testtrace(trace, calls, device_name)
else:
raise RuntimeError("Unknown tracefile extension")
log_result("OK")
......
......@@ -28,12 +28,17 @@ class TraceType(Enum):
UNKNOWN = auto()
APITRACE = auto()
RENDERDOC = auto()
TESTTRACE = auto()
_trace_type_info_map = {
TraceType.APITRACE : ("apitrace", ".trace"),
TraceType.RENDERDOC : ("renderdoc", ".rdc")
TraceType.RENDERDOC : ("renderdoc", ".rdc"),
TraceType.TESTTRACE : ("testtrace", ".testtrace")
}
def all_trace_types():
return _trace_type_info_map.keys()
def all_trace_type_names():
s = []
for t,(name, ext) in _trace_type_info_map.items():
......@@ -55,7 +60,7 @@ def trace_type_from_filename(trace_file):
return TraceType.UNKNOWN
def iter_trace_paths(directory, trace_types=[TraceType.APITRACE, TraceType.RENDERDOC]):
def iter_trace_paths(directory, trace_types=all_trace_types()):
for root, dirs, files in os.walk(directory):
for file in files:
trace_type = trace_type_from_filename(file)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment