Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ jobs:
tests/startup_gfx2hlsl_operand_count_check.py \
tests/startup_image_2d_array_check.py \
tests/startup_host_cpu_check.py \
tests/startup_live_telemetry_check.py \
tests/startup_gfx2hlsl_cvt_alu_check.py \
tests/startup_gfx2hlsl_capture_check.py \
tests/startup_translator_check.py \
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ python3 -m venv out/pe-env
./out/pe-env/bin/python -B tests/startup_gfx2hlsl_mad_check.py
./out/pe-env/bin/python -B tests/startup_image_2d_array_check.py
./out/pe-env/bin/python -B tests/startup_host_cpu_check.py
./out/pe-env/bin/python -B tests/startup_live_telemetry_check.py
./out/pe-env/bin/python -B tests/startup_gfx2hlsl_capture_check.py
./out/pe-env/bin/python -B tests/startup_translator_check.py
./out/pe-env/bin/python -B tests/startup_gfx2hlsl_smem_offset_check.py
Expand Down
8 changes: 8 additions & 0 deletions docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,14 @@ when either memory value changed, so the cost of a stalled load is visible. Each
by a line of failed requests by cause and a line of page-destination requests by end (see
DirectStorage failure causes and DirectStorage page-request ends under Findings).

The live log window also shows DirectStorage heartbeat lines and `x2w-render totals` as they
arrive. It reports frame counts and FPS from the graphics heartbeat without inferring whether
draws were executed. Network refusals are shown when observed; the window does not establish
that all network activity is blocked. To check this presentation with generated logs, run
`python -B tests/startup_live_telemetry_check.py`. See [#1199](https://github.com/R0Y00/Xbox2Windows/issues/1199)
for memory accounting and [#1281](https://github.com/R0Y00/Xbox2Windows/issues/1281) for
the launcher's concurrent-hook limitation.

```powershell
cmake --build --preset release --target xmem_shim startup_stub_xcrdapi xmem_slab_slots_check
ctest --preset release --no-tests=error -R '^(xmem_slab_slots|xmem_page_stats|startup_heartbeat_commit)$' -V
Expand Down
65 changes: 65 additions & 0 deletions tests/startup_live_telemetry_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""Check the live viewer with generated startup log lines."""

import contextlib
import io
from pathlib import Path
import runpy
import sys
import tempfile
import unittest
from unittest import mock


class LiveViewCheck(unittest.TestCase):
def view_log(self, first_chunk, second_chunk=None):
viewer = Path(__file__).resolve().parents[1] / "tools" / "startup" / "live_view.py"
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
log = root / "trap.log"
log.write_text(first_chunk, encoding="utf-8")
finished = root / "finished.txt"

def finish_run(_seconds):
if not finished.exists():
if second_chunk is not None:
with log.open("a", encoding="utf-8", newline="\n") as handle:
handle.write(second_chunk)
finished.write_text("finished\n", encoding="utf-8")

if second_chunk is None:
finish_run(0)
output = io.StringIO()
with mock.patch.object(sys, "argv", [str(viewer), directory]), \
mock.patch("os.system"), mock.patch("time.sleep", side_effect=finish_run), \
contextlib.redirect_stdout(output):
runpy.run_path(str(viewer), run_name="__main__")
return output.getvalue()

def test_frame_heartbeat_does_not_claim_draws_were_dropped(self):
output = self.view_log("x2w-d3d12 heartbeat: 60 frames presented in 2.0 s (30.0 fps overall)\n")
self.assertIn("60 frames presented, 30.0 fps", output)
self.assertNotIn("every draw dropped", output)
self.assertNotIn("game runs offline", output)

def test_storage_and_render_totals_are_preserved(self):
storage = ("x2w-dstorage heartbeat 10 s: requests done=12 inflated=7 failed=2 bcpack-blank=1; "
"page tokens 0 at enqueue=3, still 0 at run=1; commit peak=900 MiB current=800 MiB, "
"live physical-page sections=42")
render = ("x2w-render totals: resets 2 (failed 0), closes 2, clears 1, executes 2, "
"draws 4 (skipped 1), translated draws 3 (not drawn 2), pipelines translated 4 / missing 1, "
"null bindings 5 (entry 1, buffer 1, token 1, wrapper 1, dimension 1), "
"textures uploaded 2 (16 KiB, unreadable 1)")
output = self.view_log(storage + "\n" + render + "\n")
self.assertIn(storage, output)
self.assertIn(render, output)
self.assertIn("7 chunks decompressed", output)

def test_unknown_and_split_heartbeat(self):
first = "x2w-dstorage heartbeat 20 s: requests done=0 inflated=0 failed=0 bcpack-blank=0; "
second = "page tokens 0 at enqueue=0, still 0 at run=0; commit unknown, live physical-page sections=unknown\n"
output = self.view_log(first, second)
self.assertEqual(output.count(first + second.strip()), 1)


if __name__ == "__main__":
unittest.main()
14 changes: 11 additions & 3 deletions tools/startup/live_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,18 @@ def on_shim(line):
say("storage", f"read batch complete: {m.group(1)} compressed chunks decompressed so far, {m.group(2)} failed")
elif "EnqueueRequest" in line or "options=" in line or "Queue::Submit" in line or "IsComplete" in line:
return
elif line.startswith("x2w-dstorage heartbeat "):
m = re.search(r"\binflated=(\d+)", line)
if m:
counts["chunks"] = int(m.group(1))
say("storage", line)
elif line.startswith("x2w-render totals:"):
say("render", line)
elif "heartbeat" in line:
m = re.search(r"heartbeat: (\d+) frames presented in ([\d.]+) s \(([\d.]+) fps", line)
if m:
frames = m.group(1)
say("frames", f"{m.group(1)} frames presented, {m.group(3)} fps (every draw dropped: no GPU translation yet)")
say("frames", f"{m.group(1)} frames presented, {m.group(3)} fps")
elif "title main state" in line:
m = re.search(r"state (-?\d+) -> (-?\d+)", line)
if m:
Expand All @@ -122,7 +129,7 @@ def on_shim(line):
positions = {name: 0 for name in sources}
partial = {name: b"" for name in sources} # bytes: a character can be split between two reads
print("Xbox2Windows local startup experiment: live log of " + os.path.abspath(rundir))
print("Columns: time since this window opened, category, detail. The game runs offline (network opens are refused).")
print("Columns: time since this window opened, category, detail. Network refusals are shown when observed.")
print("-" * 110, flush=True)
finished = os.path.join(rundir, "finished.txt")
ended = False
Expand Down Expand Up @@ -160,7 +167,8 @@ def on_shim(line):
time.sleep(0.25)
print("-" * 110)
try:
print(open(finished, encoding="utf-8", errors="replace").read().strip())
with open(finished, encoding="utf-8", errors="replace") as handle:
print(handle.read().strip())
except OSError:
pass
print("\nRun ended. Full logs are in " + os.path.abspath(rundir) + " (events.txt, files.txt, trap.log).")
Expand Down
Loading