mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Feat] (TraceApp, CI): pass arbitrary env vars through the retrace lane
- PLAN-B.md §8.2 and appendix B add a batch of new runtime switches
(MOBILEGL_PIPE_PUSH / _VERIFY / _STATS / _LEGACY_MEMOS / _TEXEL_RETAIN_MB /
_INDEX_MIRROR_MB, plus MOBILEGL_IPC_* later), and §11 P0 wants them parsed beside
the existing ones. Today every knob that has to reach an Android replay costs an
edit in five files - run_android_retrace_local.py, trace-replay-ci.sh,
TraceReplayActivity's request record, the JNI marshalling, and the setenv block in
trace_replay_core.cpp. That per-knob tax is what this replaces: one extra,
`--es mobilegl_env "K=V;K=V"`, carries all of them.
- Applied last, immediately before dlopen(libMobileGL.so), so it can also override
the dedicated fields above it - MobileGL's config is read during the load, and an
escape hatch that cannot beat the defaults is not one. An entry with no '=' unsets
the variable, which is the only way to clear a default the marshalling sets.
- The existing per-knob flags stay: they carry semantics beyond a setenv (use_angle
also selects a variant, the dump lists are joined, DirectVulkan forces the
R11G11B10F fallback), and rewriting them as env strings would move that logic into
the callers.
- Surface: --env / MOBILEGL_TRACE_ENV in trace-replay-ci.sh, repeatable --env
KEY=VALUE in run_android_retrace_local.py, `mobilegl_env` intent extra,
Request::envOverrides.
- The two-level parse now lives in trace_env_overrides.hpp, beside the semicolon
splitter it shares with the texture and FBO dump lists, and
tools/trace_replay/trace_env_overrides_test.cpp pins it: the empty entries a
trailing ';' leaves behind must not become unsetenv(""), `K=` must stay a Set of
the empty string rather than an Unset (a knob read with getenv() != nullptr sees
those as opposite answers), and only the FIRST '=' may separate, or a value
carrying '=' is truncated without a word of warning. The whole MOBILEGL_PIPE_*
batch rides on this parse, and the only lane that exercised it end to end was an
on-device retrace, which would have reported a splitting bug as "the knob had no
effect".
- The check is built and RUN at build time and mobilegl_trace_replay depends on it,
so `cmake --build ... --target mobilegl_trace_replay` - the exact command of
test.yml's "Build trace replay" job, which never invokes ctest - runs it. It is
assert-free on purpose: that lane configures Release, and <cassert> under NDEBUG
would compile every check into a green run that checked nothing. Negative control:
swapping find('=') for rfind('=') fails 2 checks, and keeping the splitter's empty
entries fails 2 more.
This commit is contained in:
@@ -119,7 +119,7 @@ def render_summary():
|
||||
shutil.copyfile(SUMMARY_DIR / SUMMARY_HTML, SUMMARY_DIR / "index.html")
|
||||
|
||||
|
||||
def run_case(case, backend, extra_args=None, timeout_seconds=None):
|
||||
def run_case(case, backend, extra_args=None, timeout_seconds=None, env_overrides=None):
|
||||
backend_info = BACKENDS[backend]
|
||||
apk = find_trace_apk()
|
||||
trace_archive = FIXTURES / case["trace_archive"]
|
||||
@@ -189,6 +189,11 @@ def run_case(case, backend, extra_args=None, timeout_seconds=None):
|
||||
command.append("--avoid-angle-llvmpipe-explicit-lod-bias")
|
||||
if case.get("coherent_as_flush"):
|
||||
command.append("--coherent-as-flush")
|
||||
# Generic environment passthrough: --env MOBILEGL_FOO=1 needs no per-knob plumbing in
|
||||
# this script, in trace-replay-ci.sh, in the Activity, in the JNI marshalling or in the
|
||||
# runner - one extra carries them all.
|
||||
if env_overrides:
|
||||
command.extend(["--env", ";".join(env_overrides)])
|
||||
env = dict(**__import__("os").environ)
|
||||
env["PYTHON"] = "python"
|
||||
env["MSYS2_ARG_CONV_EXCL"] = "/data/*"
|
||||
@@ -255,7 +260,13 @@ def run_benchmark_case(case, backend, args):
|
||||
stale = RESULT_ROOT / f"{safe_case(case['name'])}-{backend}" / "benchmark.json"
|
||||
if stale.exists():
|
||||
stale.unlink()
|
||||
rc = run_case(case, backend, extra_args=extra_args, timeout_seconds=args.benchmark_timeout_seconds)
|
||||
rc = run_case(
|
||||
case,
|
||||
backend,
|
||||
extra_args=extra_args,
|
||||
timeout_seconds=args.benchmark_timeout_seconds,
|
||||
env_overrides=args.env,
|
||||
)
|
||||
report = read_benchmark(case, backend, run_index)
|
||||
if rc != 0 or report is None:
|
||||
print(f"{label} run {run_index}/{args.benchmark_repeats}: FAILED (exit {rc})", flush=True)
|
||||
@@ -287,6 +298,15 @@ def parse_args():
|
||||
parser.add_argument("--backend", action="append", choices=sorted(BACKENDS), help="Backend to run; may be repeated.")
|
||||
parser.add_argument("--all", action="store_true", help="Run every case in the APK workflow matrix.")
|
||||
parser.add_argument("--keep-results", action="store_true", help="Do not clear the previous result root.")
|
||||
parser.add_argument(
|
||||
"--env",
|
||||
action="append",
|
||||
default=[],
|
||||
metavar="KEY=VALUE",
|
||||
help="Environment variable to set in the replay process, applied just before "
|
||||
"libMobileGL.so is loaded; may be repeated. A KEY with no '=' unsets it. This "
|
||||
"is the generic passthrough for MOBILEGL_* knobs that have no flag of their own.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--benchmark",
|
||||
action="store_true",
|
||||
@@ -343,7 +363,7 @@ def main():
|
||||
failures += run_benchmark_case(case, backend, args)
|
||||
continue
|
||||
print(f"=== Android retrace: {case['name']} / {backend} ===", flush=True)
|
||||
rc = run_case(case, backend)
|
||||
rc = run_case(case, backend, env_overrides=args.env)
|
||||
try:
|
||||
render_summary()
|
||||
except Exception as error:
|
||||
|
||||
Reference in New Issue
Block a user