diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/build_profiles.sh | 135 | ||||
| -rwxr-xr-x | scripts/clang-format-all.sh | 4 | ||||
| -rwxr-xr-x | scripts/dmt.py | 107 | ||||
| -rwxr-xr-x | scripts/format-all.sh | 3 |
4 files changed, 111 insertions, 138 deletions
diff --git a/scripts/build_profiles.sh b/scripts/build_profiles.sh deleted file mode 100755 index 0ae6d63..0000000 --- a/scripts/build_profiles.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env bash -# Build every codegen profile under gcc+clang release and report .so sizes. -# Always wipes existing build dirs to ensure a clean configure. -# Profiles are discovered from pixpat-native/profiles/*.toml. - -set -euo pipefail - -# Meson setup flags applied to every (compiler × profile) build dir. -# Add new -D flags or buildtype overrides here. -MESON_SETUP_ARGS=( - --buildtype=release -) - -# name → toml path. -PROFILES=() -profile_dir="pixpat-native/profiles" -for toml in "$profile_dir"/*.toml; do - [[ -e "$toml" ]] || continue - name="$(basename "$toml" .toml)" - PROFILES+=("$name:$toml") -done - -COMPILERS=( - "gcc:gcc:g++" - "clang:clang:clang++" -) - -build_one() { - local cc_name=$1 cc=$2 cxx=$3 name=$4 toml=$5 log=$6 - local dir="build-$cc_name-$name" - - local setup_args=("${MESON_SETUP_ARGS[@]}") - [[ -d "$dir/meson-info" ]] && setup_args+=(--wipe) - setup_args+=("-Dconfig=$toml") - - # Capture meson output so we can show it on failure; on success discard - # it and let ninja write its (warnings-only with --quiet) output instead. - if ! CC=$cc CXX=$cxx meson setup "$dir" "${setup_args[@]}" >"$log" 2>&1; then - return 1 - fi - : >"$log" - ninja -C "$dir" --quiet >"$log" 2>&1 -} - -pids=() -labels=() -logs=() -for comp in "${COMPILERS[@]}"; do - IFS=: read -r cc_name cc cxx <<<"$comp" - for entry in "${PROFILES[@]}"; do - name="${entry%%:*}" - toml="${entry#*:}" - dir="build-$cc_name-$name" - log=$(mktemp) - echo "==> launching $dir" - build_one "$cc_name" "$cc" "$cxx" "$name" "$toml" "$log" & - pids+=($!) - labels+=("$dir") - logs+=("$log") - done -done - -failed=0 -for i in "${!pids[@]}"; do - if wait "${pids[$i]}"; then - if [[ -s "${logs[$i]}" ]]; then - echo "==> ${labels[$i]} ok (warnings):" - cat "${logs[$i]}" - else - echo "==> ${labels[$i]} ok" - fi - else - echo "==> ${labels[$i]} FAILED:" - cat "${logs[$i]}" - failed=1 - fi - rm -f "${logs[$i]}" -done -(( failed == 0 )) || exit 1 - -CASES=( - "RGB888 -> BGR888" - "NV12 -> BGR888" - "BGR888 -> NV12" - "NV12 -> YUV420" - "smpte -> BGR888" - "smpte -> NV12" - "kmstest -> BGR888" -) -LABELS=("RGB->BGR" "NV12->BGR" "BGR->NV12" "NV12->YUV" "smpte/BGR" "smpte/NV12" "kmstest/BGR") - -PERF_TEST="pixpat-python/scripts/perf_test.py" - -join_cases() { - local out="" - local c - for c in "$@"; do - out+="${out:+,}$c" - done - printf '%s' "$out" -} -cases_arg=$(join_cases "${CASES[@]}") - -echo -echo "=== libpixpat.so.0.0.0 sizes + pixpat MP/s (release, --iters 5 --warmup 2) ===" -printf "%-28s %10s" "build-dir" "bytes" -for lbl in "${LABELS[@]}"; do - printf " %10s" "$lbl" -done -echo - -for comp in "${COMPILERS[@]}"; do - cc_name="${comp%%:*}" - for entry in "${PROFILES[@]}"; do - name="${entry%%:*}" - dir="build-$cc_name-$name" - so="$dir/libpixpat.so.0.0.0" - if [[ ! -f "$so" ]]; then - printf "%-28s %10s\n" "$dir" "MISSING" - continue - fi - - bytes=$(stat -c%s "$so") - tsv=$(PIXPAT_LIB="$so" python3 "$PERF_TEST" \ - --tsv --iters 5 --warmup 2 \ - --cases "$cases_arg" 2>/dev/null || true) - - printf "%-28s %10d" "$dir" "$bytes" - for c in "${CASES[@]}"; do - val=$(awk -F'\t' -v want="$c" '$1 == want { print $2; exit }' <<<"$tsv") - printf " %10s" "${val:--}" - done - echo - done -done diff --git a/scripts/clang-format-all.sh b/scripts/clang-format-all.sh new file mode 100755 index 0000000..38091fb --- /dev/null +++ b/scripts/clang-format-all.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +dirs="kms++ kmscube kms++util py utils" +find $dirs \( -name "*.cpp" -o -name "*.h" \) -exec clang-format -i {} \; diff --git a/scripts/dmt.py b/scripts/dmt.py new file mode 100755 index 0000000..82defb6 --- /dev/null +++ b/scripts/dmt.py @@ -0,0 +1,107 @@ +#!/usr/bin/python3 + +import sys +import re + +# Convert DMT pdf to txt: +# pdftotext -layout -f 18 -l 105 DMTr1\ v13.pdf DMT.txt + +# Path to the text file +filepath = sys.argv[1] + +m = {} +line = "" + +def parsei(key, regex, base=10): + global m + global line + + match = re.search(regex, line) + if match != None: + m[key] = int(match.group(1), base) + +def parsef(key, regex, base=10): + global m + global line + + match = re.search(regex, line) + if match != None: + m[key] = float(match.group(1)) + +for line in open(filepath, 'r'): + # each page starts with this + if "VESA MONITOR TIMING STANDARD" in line: + m = { } + + # each page ends with this + if "VESA Display Monitor Timing Standard" in line: + print("// {:#x} - {}".format(m["dmt_id"], m["name"])) + + flags = [] + if m["ilace"]: + flags += [ "DRM_MODE_FLAG_INTERLACE" ] + + if m["hsp"]: + flags += [ "DRM_MODE_FLAG_PHSYNC" ] + else: + flags += [ "DRM_MODE_FLAG_NHSYNC" ] + + if m["vsp"]: + flags += [ "DRM_MODE_FLAG_PVSYNC" ] + else: + flags += [ "DRM_MODE_FLAG_NVSYNC" ] + + print("DRM_MODE(\"{}\", {}, {}, {}, {}, {}, {}, {}, {}, {}, {}),".format( + m["name"], + int(m["pclk"] * 1000), + m["hact"], m["hfp"], m["hsw"], m["hbp"], + m["vact"], m["vfp"], m["vsw"], m["vbp"], + " | ".join(flags) + )) + + match = re.search("Timing Name\s+=\s+([^;]+)", line) + if match != None: + m["name"] = str.strip(match.group(1)) + + parsei("dmt_id", "EDID ID:\s+DMT ID: ([0-9A-Fa-f]+)h", 16) + parsef("pclk", "Pixel Clock\s+=\s+(\d+\.\d+)") + + parsei("hact", "Hor Pixels\s+=\s+(\d+)") + parsei("hfp", "H Front Porch.*\s(\d+) Pixels") + parsei("hsw", "Hor Sync Time.*\s(\d+) Pixels") + parsei("hbp", "H Back Porch.*\s(\d+) Pixels") + + parsei("vact", "Ver Pixels\s+=\s+(\d+)") + parsei("vfp", "V Front Porch.*\s(\d+)\s+lines") + parsei("vsw", "Ver Sync Time.*\s(\d+)\s+lines") + parsei("vbp", "V Back Porch.*\s(\d+)\s+lines") + + match = re.search("Scan Type\s+=\s+(\w+);", line) + if match != None: + if match.group(1) == "NONINTERLACED": + m["ilace"] = False + elif match.group(1) == "INTERLACED": + m["ilace"] = True + else: + print("Bad scan type") + exit(-1) + + match = re.search("Hor Sync Polarity\s+=\s+(\w+)", line) + if match != None: + if match.group(1) == "POSITIVE": + m["hsp"] = True + elif match.group(1) == "NEGATIVE": + m["hsp"] = False + else: + print("Bad hsync polarity") + exit(-1) + + match = re.search("Ver Sync Polarity\s+=\s+(\w+)", line) + if match != None: + if match.group(1) == "POSITIVE": + m["vsp"] = True + elif match.group(1) == "NEGATIVE": + m["vsp"] = False + else: + print("Bad vsync polarity") + exit(-1) diff --git a/scripts/format-all.sh b/scripts/format-all.sh deleted file mode 100755 index 156d807..0000000 --- a/scripts/format-all.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -uncrustify -c uncrustify.cfg -l CPP --no-backup $(git ls-files '*.cpp' '*.h') |
