Skip to content
Closed
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
6 changes: 4 additions & 2 deletions docs/linux_proton.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ the layout the comments at their top describe (`/opt/leonida` for traces, overla
characters before).
- **Window:** frames are presented in the title's own window; `LEONIDA_PRESENT_WINDOW=own|hidden` chooses otherwise.

Three setup mistakes each give a blank or empty picture without an error: the executable's embedded shaders missing
Three setup mistakes each give a blank or empty picture: the executable's embedded shaders missing
from the library (`exe/index.json`), a build without SDL3 (no pad), and a BCPack predictor file that was never
generated (`tools/build_dstorage_history.py`; without it the loading art and most BC7 textures stay empty).
generated (`tools/build_dstorage_history.py`; without it the loading art and most BC7 textures stay empty). The
runtime's DStorage open line now names a missing predictor, and the runtime stage warns when the `--if-needed`
generation did not produce the profile.

## What a healthy boot looks like (Linux machine)

Expand Down
14 changes: 14 additions & 0 deletions make_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -2510,6 +2510,18 @@ def build_pipeline_check(jobs: int) -> None:
"or VULKAN_SDK); the CMake output above says which is missing.")


def dstorage_profile_hint(profile: str) -> "str | None":
"""The warning for a BCPack predictor profile that was not generated, or None when the file exists.

The runtime reads `<work>/bcpack/history.bcph` (or LEONIDA_DSTORAGE_HISTORY) and silently keeps the built-in
codec policy when it is absent; the loading art and most BC7 textures then stay empty. The runtime stage
generates it with tools/build_dstorage_history.py, so a missing file afterwards is a real setup gap."""
if os.path.isfile(profile):
return None
return (f"the BCPack predictor profile was not generated at {profile}; loading art and most BC7 textures "
"stay empty. Generate it with tools/build_dstorage_history.py")


def runtime(game: str, out: str, v: dict, runtime_build: str | None = None, jobs: int = 1,
*, work: str | None = None) -> None:
destinations = [*RUNTIME_FILES, "game_path.txt"]
Expand Down Expand Up @@ -2555,6 +2567,8 @@ def runtime(game: str, out: str, v: dict, runtime_build: str | None = None, jobs
native = os.path.join(build, "bcpack_history_train.exe")
trainer = ["--trainer", native] if os.name == "nt" and os.path.isfile(native) else []
py("build_dstorage_history.py", game, "--out", profile, "--if-needed", *trainer)
if hint := dstorage_profile_hint(profile):
log("runtime: warning: " + hint)
# Wine's path converter takes the original Unix filename bytes. The Windows reader expects UTF-8.
encoded = shader_dir.encode("utf-8") if os.name == "nt" else os.fsencode(shader_dir)
pending = tempfile.NamedTemporaryFile(dir=out, delete=False)
Expand Down
5 changes: 4 additions & 1 deletion runtime/shims/dstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ const leonida::bcpack::Calibration* bcpack_history() {
}
FILE* raw = nullptr;
if (_wfopen_s(&raw, path.c_str(), L"rb") || !raw) {
log_once("history-open", "could not open the local BCPack predictor profile");
log_once("history-open",
"could not open the local BCPack predictor profile (LEONIDA_DSTORAGE_HISTORY or "
"<work>/bcpack/history.bcph); loading art and most BC7 textures stay empty until "
"tools/build_dstorage_history.py generates it");
return {};
}
std::unique_ptr<FILE, decltype(&std::fclose)> file(raw, &std::fclose);
Expand Down
37 changes: 37 additions & 0 deletions tests/test_make_game_dstorage_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Unit tests for the BCPack predictor profile hint in make_game.py.

python -I tests/test_make_game_dstorage_profile.py
"""
import os
import sys
import tempfile
import unittest

ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if ROOT not in sys.path:
sys.path.insert(0, ROOT)
import make_game


class DstorageProfileHintTest(unittest.TestCase):
"""The runtime stage must name a profile that build_dstorage_history.py did not produce."""

def test_missing_profile_names_generator_and_consequence(self):
with tempfile.TemporaryDirectory() as temp:
profile = os.path.join(temp, "bcpack", "history.bcph")
hint = make_game.dstorage_profile_hint(profile)
self.assertIsNotNone(hint)
self.assertIn(profile, hint)
self.assertIn("tools/build_dstorage_history.py", hint)
self.assertIn("BC7", hint)

def test_present_profile_needs_no_hint(self):
with tempfile.TemporaryDirectory() as temp:
profile = os.path.join(temp, "history.bcph")
with open(profile, "wb") as handle:
handle.write(b"BCPHIST1")
self.assertIsNone(make_game.dstorage_profile_hint(profile))


if __name__ == "__main__":
unittest.main()