diff --git a/docs/linux_proton.md b/docs/linux_proton.md index f98aacf149..7d721eb7cd 100644 --- a/docs/linux_proton.md +++ b/docs/linux_proton.md @@ -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) diff --git a/make_game.py b/make_game.py index 3eb0899458..a26ffde287 100644 --- a/make_game.py +++ b/make_game.py @@ -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 `/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"] @@ -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) diff --git a/runtime/shims/dstorage.cpp b/runtime/shims/dstorage.cpp index 7f4cef9d94..5f60049511 100644 --- a/runtime/shims/dstorage.cpp +++ b/runtime/shims/dstorage.cpp @@ -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 " + "/bcpack/history.bcph); loading art and most BC7 textures stay empty until " + "tools/build_dstorage_history.py generates it"); return {}; } std::unique_ptr file(raw, &std::fclose); diff --git a/tests/test_make_game_dstorage_profile.py b/tests/test_make_game_dstorage_profile.py new file mode 100644 index 0000000000..e1cc5ec1f2 --- /dev/null +++ b/tests/test_make_game_dstorage_profile.py @@ -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() \ No newline at end of file