Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Republish game settings when Update changes the runtime

Leonardo Lobatoee04bbd02964
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index b8c0363..c33a2a6 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -1529,7 +1529,7 @@ std::string RuntimeHost::UnlinkDxvkConfig(const rt::RuntimeInstall& record) {
std::string RuntimeHost::RepublishSettings(Composition& c, const rt::RuntimeInstall& record, bool* published,
bool steam_account_known, bool* prepare_again,
- std::string* upgrade_deferred, std::string* code) {
+ std::string* upgrade_deferred, std::string* code, bool force) {
if (published) *published = false;
if (code) code->clear();
if (prepare_again) *prepare_again = false;
@@ -1540,10 +1540,11 @@ std::string RuntimeHost::RepublishSettings(Composition& c, const rt::RuntimeInst
if (RecipeFits(candidate, record) && candidate.id == record.recipe_id)
if (const auto lacks = KitLacksForRecipe(candidate, c.kit->view); !lacks.empty()) return lacks;
// Only the unowned upgrade of a game that did not move, with no newer settings: the game
- // played under its owned publication, which stays when the upgrade fails.
+ // played under its owned publication, which stays when the upgrade fails. A forced publication
+ // (another runtime) reports its refusal instead.
const auto saved_revision = config_.settings_record
? config_.settings_record(GameOf(record)).value_or(rt::GameSettingsRecord{}).revision : 0;
- const bool upgrade_only = record.moved_from.empty() && saved_revision <= record.settings_revision &&
+ const bool upgrade_only = !force && record.moved_from.empty() && saved_revision <= record.settings_revision &&
NeedsUnownedPublication(c, record);
// A game folder that isn't there (a stale record, an unplugged drive) can't be published, and
// arming the request first would leave a journal on the record: nothing is armed for it.
@@ -1556,7 +1557,7 @@ std::string RuntimeHost::RepublishSettings(Composition& c, const rt::RuntimeInst
return {};
}
}
- auto refused = PublishSavedSettings(c, record, published, steam_account_known, prepare_again, code);
+ auto refused = PublishSavedSettings(c, record, published, steam_account_known, prepare_again, code, force);
if (refused.empty() || !upgrade_only) return refused;
Log("settings update app=" + std::to_string(record.runtime_number) + " unowned upgrade deferred, owned publication kept: " +
refused);
@@ -1570,16 +1571,19 @@ std::string RuntimeHost::RepublishSettings(Composition& c, const rt::RuntimeInst
}
std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeInstall& record, bool* published,
- bool steam_account_known, bool* prepare_again, std::string* code) {
+ bool steam_account_known, bool* prepare_again, std::string* code,
+ bool force) {
if (code) code->clear();
// Refusals only a new preparation gets past (the title's recipe or settings can't be published again).
const auto again = [prepare_again](std::string message) {
if (prepare_again) *prepare_again = true;
return message;
};
- const auto saved = config_.settings_record
- ? config_.settings_record(GameOf(record)).value_or(rt::GameSettingsRecord{})
- : rt::GameSettingsRecord{};
+ auto saved = config_.settings_record
+ ? config_.settings_record(GameOf(record)).value_or(rt::GameSettingsRecord{})
+ : rt::GameSettingsRecord{};
+ // A forced publication keeps the title's revision: the settings are the same, the runtime is not.
+ if (force) saved.revision = std::max(saved.revision, record.settings_revision);
// A game whose folder moved (RuntimeInstall::moved_from) is published again at its revision, so
// its descriptor, profile and dxvk.conf name the new folder.
const bool moved = !record.moved_from.empty();
@@ -1587,7 +1591,7 @@ std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeI
const bool unowned_upgrade = !moved && NeedsUnownedPublication(c, record);
if (unowned_upgrade) Log("settings update app=" + std::to_string(record.runtime_number) + " publishes the game folder unowned");
// "Steam features" only swaps the game's own files, so it follows the saved value at once.
- if (saved.revision <= record.settings_revision && !moved && !unowned_upgrade)
+ if (!force && saved.revision <= record.settings_revision && !moved && !unowned_upgrade)
return ApplyPreparationSteps(c, record, steam_account_known);
if (!c.kit) return "No verified compatibility kit is installed.";
if (saved.revision < record.settings_revision)
@@ -1691,6 +1695,26 @@ std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeI
if (plan.app_id != record.runtime_number || plan.recipe_id != record.recipe_id || plan.recipe_version != record.recipe_version ||
plan.launch_entry_id != next.launch_entry_id || plan.profile_id != record.default_profile_id)
return again("The settings no longer match this game's PS5 title; prepare it again.");
+ // A forced publication runs only when the new runtime changes what the settings write (120 Hz output), so a
+ // respin that changes nothing there keeps its publication, registration and bottle as they are.
+ if (force) {
+ // POSIX reads, as elsewhere here: the PS5 libc++ has no locale support for file streams.
+ const auto read = [](const std::filesystem::path& path) {
+ std::string bytes;
+ const int fd = open(path.c_str(), O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
+ if (fd < 0) return bytes;
+ char chunk[4096];
+ for (ssize_t count; (count = ::read(fd, chunk, sizeof(chunk))) > 0;)
+ bytes.append(chunk, static_cast<std::size_t>(count));
+ close(fd);
+ return bytes;
+ };
+ const auto profile = HostPath(record.data_root) / "library/profiles" / (plan.profile_id + ".profile");
+ const auto config = HostPath(record.install_path) / WorkingFolder(next.launch_working_directory, next.launch_path,
+ next.launch_in_install_root) /
+ "dxvk.conf";
+ if (read(profile) == plan.profile_bytes && read(config) == plan.dxvk_config) return {};
+ }
const auto transaction = config_.uuid();
if (!transaction) return "No secure random source for the settings update.";
rt::SettingsPublicationRequest request;
@@ -2582,7 +2606,10 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
const auto written = WriteTitleMetadata(c, *existing, request.title_name);
if (written.state != rt::PackageActionState::kComplete) return written.message;
}
- if (!c.installer->TitleCurrent(*existing) || !metadata_current) {
+ // A title that moves to the kit's runtime gets its settings published again below: the profile
+ // was built for the runtime it had, and the new one may take more keys (120 Hz output) or fewer.
+ const bool runtime_refresh = !c.installer->TitleCurrent(*existing);
+ if (runtime_refresh || !metadata_current) {
// Same kit id and recipe; title files changed (a new wrapper build) or
// the runtime was rebuilt (same artifacts, new bytes). The registration
// and publication stay as they are. A rebuilt runtime is copied into the
@@ -2664,6 +2691,15 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
PublishInstalls(c);
if (admission != "ok") return "The PS5 title still fails its start check: " + admission;
OpenGameFolders(c, *existing);
+ if (runtime_refresh) {
+ const auto refreshed_record = c.records.Find(existing->install_id);
+ if (!refreshed_record) return "The game's install record is missing.";
+ bool republished = false;
+ const auto refused = RepublishSettings(c, *refreshed_record, &republished, true, nullptr, nullptr, nullptr, true);
+ Log("runtime refresh republish app=" + std::to_string(request.runtime_number) + " published=" +
+ std::to_string(republished) + (refused.empty() ? std::string() : " refused=" + refused));
+ if (!refused.empty()) return refused;
+ }
return changed ? std::string{} : "This game is already prepared.";
}
if (existing->install_path != request.install_path)
diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hpp
index 2e01388..cb124a3 100644
--- a/src/homebrew/runtime_host.hpp
+++ b/src/homebrew/runtime_host.hpp
@@ -500,14 +500,17 @@ class RuntimeHost {
// The unowned upgrade alone (not moved, no newer settings) never refuses: its failure is in
// *upgrade_deferred and the owned publication stays, as it played before.
// `code`: the publication's failure code when the publication itself refused (empty otherwise).
+ // With force, the settings are published again even when the title already has their revision:
+ // after Update moved the title to another runtime, which may take different profile keys (120 Hz
+ // output). Nothing is published when they write the same profile and dxvk.conf as before.
std::string RepublishSettings(Composition& composition, const runtime::RuntimeInstall& record,
bool* published = nullptr, bool steam_account_known = true,
bool* prepare_again = nullptr, std::string* upgrade_deferred = nullptr,
- std::string* code = nullptr);
+ std::string* code = nullptr, bool force = false);
// RepublishSettings without the upgrade's fallback.
std::string PublishSavedSettings(Composition& composition, const runtime::RuntimeInstall& record,
bool* published, bool steam_account_known, bool* prepare_again,
- std::string* code = nullptr);
+ std::string* code = nullptr, bool force = false);
// A Ready game published owned (schema 2, before 0.6 or by a kit before 0.10) while the kit
// admits unowned game folders: published again as unowned, so folders the player opened pass.
bool NeedsUnownedPublication(const Composition& composition, const runtime::RuntimeInstall& record);
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index a8770a7..18f727a 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -882,13 +882,13 @@ bool RenderProsperoProfile(const GameRecipe& recipe, const EffectiveSettings& se
// written: it was the PS5 OpenGL SDK's, and runtimes default it to off.
if (settings.values.at("refresh").available || settings.graphics == "opengl")
text += "refresh = " + value("refresh") + "\n";
- // Only for a title whose runtime takes it: an older runtime refuses the whole profile for this key.
+ // Only a cap the display paces, for a title whose runtime takes it: an older runtime refuses the whole profile for
+ // this key. No cap is the runtime's default (0), so uncapped profiles stay readable by every runtime; 30 at 120 Hz
+ // output is left to the software limiters (RenderDxvkConfig, RenderBottleEnvironment).
const auto& limit = OptionalValue(settings, "frame_limit");
- const bool frame_rate = settings.display_120hz && limit.available;
- if (frame_rate) {
- const bool paced = limit.value != "off" && SoftwareFrameLimit(settings).empty();
- text += "frame_rate = " + (paced ? limit.value : std::string("0")) + "\n";
- }
+ const bool frame_rate =
+ settings.display_120hz && limit.available && limit.value != "off" && SoftwareFrameLimit(settings).empty();
+ if (frame_rate) text += "frame_rate = " + limit.value + "\n";
text += "\n[input]\n";
if (value("controller_preset") != "none") text += "preset = " + value("controller_preset") + "\n";
diff --git a/src/runtime/settings_publication.cpp b/src/runtime/settings_publication.cpp
index d160d45..45f5150 100644
--- a/src/runtime/settings_publication.cpp
+++ b/src/runtime/settings_publication.cpp
@@ -190,6 +190,16 @@ std::optional<bool> PublishedGameRootUnowned(const RuntimeInstall& r, const std:
return std::nullopt;
return m.game_root_unowned != 0;
}
+std::optional<std::string> PublishedProfileDigest(const RuntimeInstall& r, const std::filesystem::path& prefix) {
+ if (!prefix.empty() && (!prefix.is_absolute() || prefix != prefix.lexically_normal())) return std::nullopt;
+ auto profiles = ManagedDirectory::Open(Map(prefix, r.data_root + "/library/profiles"), DirectoryPolicy::kPrivate);
+ auto bytes = profiles ? ReadPublicationFile(*profiles, ".playden-publication", 32768) : std::nullopt;
+ PwTitlePublicationMetadata m{};
+ if (!bytes || !bytes->present || pw_title_publication_metadata_parse(
+ reinterpret_cast<const uint8_t*>(bytes->bytes.data()), bytes->bytes.size(), &m) != PW_OK)
+ return std::nullopt;
+ return std::string(m.profile_sha256);
+}
std::optional<GameRootMove> GameRootMoveOf(const RuntimeInstall& record) {
if (record.moved_from.empty() || record.moved_from == record.install_path) return std::nullopt;
return GameRootMove{record.moved_from, record.install_path};
diff --git a/src/runtime/settings_publication.h b/src/runtime/settings_publication.h
index 0eb1497..05e4358 100644
--- a/src/runtime/settings_publication.h
+++ b/src/runtime/settings_publication.h
@@ -51,6 +51,10 @@ PackageActionResult VerifyCommittedPublicationReceipt(const RuntimeInstall& reco
// unowned (metadata schema 3); nothing when there is none or it can't be read.
std::optional<bool> PublishedGameRootUnowned(const RuntimeInstall& record,
const std::filesystem::path& host_namespace_prefix = {});
+// The SHA-256 of the profile the game's committed publication wrote (its .playden-publication);
+// nothing when there is none or it can't be read.
+std::optional<std::string> PublishedProfileDigest(const RuntimeInstall& record,
+ const std::filesystem::path& host_namespace_prefix = {});
enum class PublicationStep {
kOwnerBlocked, kJournalDurable, kPendingDurable, kFilesApplied,
diff --git a/src/runtime/settings_publication_owner.cpp b/src/runtime/settings_publication_owner.cpp
index f0d32fc..ba24ba8 100644
--- a/src/runtime/settings_publication_owner.cpp
+++ b/src/runtime/settings_publication_owner.cpp
@@ -1,5 +1,6 @@
#include "runtime/settings_publication_owner.h"
#include "runtime/publication_contract.h"
+#include "runtime/artifact_hash.h"
#include "platform/managed_file_lock.h"
#include "platform/storage.h"
#include <cerrno>
@@ -45,13 +46,17 @@ PublicationPaths OperationPaths(const SettingsPublicationOperation& operation, c
// A Ready update publishes a newer revision, or the same one again when the game folder
// moved (RuntimeInstall::moved_from): its publication must then name the new folder. With a
// kit that admits unowned folders, a committed owned publication (schema 2) is also published
-// again as unowned; one already unowned, or unreadable, is not.
-bool UpdateRevisionAllowed(const RuntimeInstall& current, std::uint64_t requested, bool unowned_game_roots,
+// again as unowned; one already unowned, or unreadable, is not. The same revision is also
+// published again when the title moved to another runtime and the same settings now make
+// another profile (RuntimeHost::RepublishSettings, force). Never an older revision.
+bool UpdateRevisionAllowed(const RuntimeInstall& current, const SettingsLaunchPlan& plan, bool unowned_game_roots,
const std::filesystem::path& prefix) {
- if (requested > current.settings_revision) return true;
- if (requested != current.settings_revision) return false;
+ if (plan.settings_revision > current.settings_revision) return true;
+ if (plan.settings_revision != current.settings_revision) return false;
if (!current.moved_from.empty()) return true;
- return unowned_game_roots && PublishedGameRootUnowned(current, prefix) == std::optional<bool>(false);
+ if (unowned_game_roots && PublishedGameRootUnowned(current, prefix) == std::optional<bool>(false)) return true;
+ const auto published = PublishedProfileDigest(current, prefix);
+ return published && HashArtifactBytes(plan.profile_bytes) != published;
}
bool MatchingJournal(const RuntimeInstall& r, const SettingsPublicationOperation& o) {
return r.journal && r.journal->operation == "settings-publication" && r.journal->operation_id == o.transaction_id;
@@ -68,7 +73,7 @@ PackageActionResult SettingsPublicationOwner::Request(const SettingsPublicationR
const bool update = current && current->state == PreparationState::kReady;
const bool armed = current && current->journal && current->journal->operation == "settings-request";
if (!expected || !current || !SameRuntimeInstallIdentity(*current, request.install) ||
- (update ? !UpdateRevisionAllowed(*current, request.plan.settings_revision, unowned_game_roots_, host_namespace_prefix_) :
+ (update ? !UpdateRevisionAllowed(*current, request.plan, unowned_game_roots_, host_namespace_prefix_) :
request.plan.settings_revision != current->settings_revision) ||
(update ? !ReadyCaptureAllowed(*current, request.transaction_id) :
current->state != PreparationState::kPreparing || !current->journal ||
@@ -118,7 +123,7 @@ PackageActionResult SettingsPublicationOwner::ResumeRequested(const RuntimeInsta
auto loaded = LoadSettingsPublicationRequest(directory, current->journal->operation_id);
if (loaded.state != PublicationRecoveryState::kValid || !loaded.request ||
!SameRuntimeInstallIdentity(loaded.request->install, *current) ||
- (current->state == PreparationState::kReady ? !UpdateRevisionAllowed(*current, loaded.request->plan.settings_revision, unowned_game_roots_, prefix) :
+ (current->state == PreparationState::kReady ? !UpdateRevisionAllowed(*current, loaded.request->plan, unowned_game_roots_, prefix) :
loaded.request->plan.settings_revision != current->settings_revision))
return Failure("publication-request-unavailable", "Requested plan is missing, altered or does not match OWNER; preserve all evidence.");
const auto& request = *loaded.request;
diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cpp
index af1d59d..f5b2d3f 100644
--- a/tests/game_settings_test.cpp
+++ b/tests/game_settings_test.cpp
@@ -313,20 +313,21 @@ int main(int argc, char** argv) {
CHECK(Value(shown, "frame_limit") == "off" && shown.values.at("frame_limit").reason == "Only with 120 Hz output.");
CHECK(SettingChoiceUnavailable(shown, "frame_limit", rate) == "Only with 120 Hz output.");
CHECK(RenderProsperoProfile(hl2, shown, target, &profile, &reason));
- CHECK(profile.text.find("\nrefresh = 60\nframe_rate = 0\n") != std::string::npos);
+ CHECK(profile.text.find("\nrefresh = 60\n") != std::string::npos && profile.text.find("frame_rate") == std::string::npos);
}
- // Off is no cap; 60 and 30 at 60 Hz output are paced by the display as well.
+ // Off is no cap, the runtime's default, so the profile has no frame_rate and every runtime reads it; 60 and 30 at
+ // 60 Hz output are paced by the display as well.
CHECK(BuildEffectiveSettings(hl2, nullptr, {}, display, &shown, &error));
CHECK(RenderProsperoProfile(hl2, shown, target, &profile, &reason));
- CHECK(profile.text.find("\nrefresh = 60\nframe_rate = 0\n") != std::string::npos);
+ CHECK(profile.text.find("\nrefresh = 60\n") != std::string::npos && profile.text.find("frame_rate") == std::string::npos);
CHECK(BuildEffectiveSettings(hl2, nullptr, {{"frame_limit", "30"}}, display, &shown, &error));
CHECK(RenderProsperoProfile(hl2, shown, target, &profile, &reason));
CHECK(profile.text.find("\nframe_rate = 30\n") != std::string::npos && RenderDxvkConfig(shown).find("maxFrameRate") == std::string::npos);
// 30 at 120 Hz output takes four vblanks, which the display cannot pace: DXVK's limiter does it, and the profile
- // asks for no cap.
+ // has no frame_rate.
CHECK(BuildEffectiveSettings(hl2, nullptr, {{"refresh", "120"}, {"frame_limit", "30"}}, display, &shown, &error));
CHECK(RenderProsperoProfile(hl2, shown, target, &profile, &reason));
- CHECK(profile.text.find("\nrefresh = 120\nframe_rate = 0\n") != std::string::npos);
+ CHECK(profile.text.find("\nrefresh = 120\n") != std::string::npos && profile.text.find("frame_rate") == std::string::npos);
CHECK(RenderDxvkConfig(shown).find("\ndxgi.maxFrameRate = 30\nd3d9.maxFrameRate = 30\n") != std::string::npos);
bool frame_rate_env = false;
for (const auto& value : RenderBottleEnvironment(shown))
@@ -355,7 +356,7 @@ int main(int argc, char** argv) {
if (value.name == "VKD3D_FRAME_RATE") vkd3d_rate = value.data;
CHECK(vkd3d_rate == "\"30\"");
CHECK(RenderProsperoProfile(d3d12, shown, target, &profile, &reason));
- CHECK(profile.text.find("\nshow_fps = false\nrefresh = 120\nframe_rate = 0\n") != std::string::npos);
+ CHECK(profile.text.find("\nshow_fps = false\nrefresh = 120\n\n[input]") != std::string::npos);
// Paced by the display at 60: no VKD3D_FRAME_RATE.
CHECK(BuildEffectiveSettings(d3d12, nullptr, {{"refresh", "120"}, {"frame_limit", "60"}}, display, &shown, &error));
vkd3d_rate.clear();
@@ -533,7 +534,7 @@ int main(int argc, char** argv) {
CHECK(profile.text.find("\n[audio]\nvolume = 50\n") != std::string::npos);
CHECK(!CheckProsperoProfile(profile.text, &reason)); // a released runtime refuses both
CHECK(CheckProsperoProfile(profile.text, &reason,
- {.input_tuning = true, .input_wheel = true, .audio_section = true, .display_frame_rate = true}));
+ {.input_tuning = true, .input_wheel = true, .audio_section = true}));
CHECK(BuildEffectiveSettings(hl2, nullptr, {{"volume", "100"}, {"wheel_stick", "none"}}, all_kit, &settings, &error));
CHECK(RenderProsperoProfile(hl2, settings, target, &profile, &reason));
CHECK(profile.text.find("[audio]") == std::string::npos && profile.text.find("wheel") == std::string::npos);
diff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cpp
index 2f14f83..64dd4db 100644
--- a/tests/homebrew_runtime_host_test.cpp
+++ b/tests/homebrew_runtime_host_test.cpp
@@ -1895,11 +1895,8 @@ void KitWithoutUnownedRootsKeepsTightening() {
host.Shutdown();
}
-// A kit with 120 Hz output over a title still running an earlier kit's runtime: until Update, the title's profile
-// has no frame_rate (its runtime would refuse the whole profile) and Frame limit stays DXVK's. After Update the
-// display paces it.
-void StaleTitleWaitsForUpdateBefore120Hz() {
- Fixture fixture;
+// The test kit plus what a fixture needs for preparations and settings updates.
+RuntimeHostConfig DisplayConfig(Fixture& fixture, unsigned* uuids, GameSettingsRecord* saved) {
auto config = fixture.Config();
config.host_namespace_prefix = fixture.root;
config.package_paths.console_data_root = "/data";
@@ -1910,15 +1907,25 @@ void StaleTitleWaitsForUpdateBefore120Hz() {
config.package_operations.validate_bottle = [](const fs::path& bottle) {
return fs::is_regular_file(bottle / "system.reg") && fs::is_regular_file(bottle / "user.reg");
};
- unsigned uuids = 0;
- config.uuid = [&uuids]() -> std::optional<std::string> {
- ++uuids; return std::string("00000000-0000-4000-8000-00000000000") + std::to_string(uuids);
+ config.uuid = [uuids]() -> std::optional<std::string> {
+ ++*uuids; return "00000000-0000-4000-8000-" + std::string(12 - std::to_string(*uuids).size(), '0') + std::to_string(*uuids);
};
config.unix_time = [] { return std::int64_t{1760000000}; };
+ config.settings_record = [saved](const playden::GameId&) -> std::optional<GameSettingsRecord> { return *saved; };
+ return config;
+}
+
+// A kit with 120 Hz output over a title still running an earlier kit's runtime: until Update, the title's profile
+// has no frame_rate (its runtime would refuse the whole profile) and Frame limit stays DXVK's. Update alone
+// publishes the saved settings again for the new runtime, and an Update back onto a kit without 120 Hz output
+// takes them out again.
+void StaleTitleWaitsForUpdateBefore120Hz() {
+ Fixture fixture;
+ unsigned uuids = 0;
+ GameSettingsRecord saved;
+ auto config = DisplayConfig(fixture, &uuids, &saved);
const auto game = fixture.root / "data/homebrew/FAKE77031/games/220";
const auto profile = fixture.root / "data/playden/games/steam-220/library/profiles/playden-steam-220.profile";
- GameSettingsRecord saved;
- config.settings_record = [&saved](const playden::GameId&) -> std::optional<GameSettingsRecord> { return saved; };
Write(game / "hl2.exe", "existing-game", 0644);
CHECK(chmod(game.c_str(), 0755) == 0);
{
@@ -1935,37 +1942,90 @@ void StaleTitleWaitsForUpdateBefore120Hz() {
CHECK(ready.installs[0].title_current && ready.installs[0].runtime_current);
host.Shutdown();
}
- auto respun = SyntheticKit(fixture.root / "kit-respun", "native-2", "kit-1", 'c');
- respun.capabilities = {"display-120hz", "dxvk", "offline_bottle", "per_game_title", "wow64_i386"};
- config.admit_kit = [respun](std::string*) { return std::optional<RuntimeKit>(respun); };
- RuntimeHost host(config);
- CHECK(host.Start());
- const auto started = WaitFor(host, Started);
- CHECK(!started.installs[0].title_current && !started.installs[0].runtime_current);
- const auto apply = [&host] {
+ const auto update = [](RuntimeHost& host) {
+ host.Prepare(Hl2());
+ const auto result = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && !s.installs.empty() && (s.installs[0].title_current || s.refusals.count(220));
+ }, 60);
+ if (result.refusals.count(220)) std::fprintf(stderr, "Update refused: %s\n", result.refusals.at(220).c_str());
+ CHECK(!result.refusals.count(220) && result.installs[0].runtime_current);
+ return result;
+ };
+ {
+ auto display = SyntheticKit(fixture.root / "kit-display", "native-2", "kit-1", 'c');
+ display.capabilities = {"display-120hz", "dxvk", "offline_bottle", "per_game_title", "wow64_i386"};
+ auto second = config;
+ second.admit_kit = [display](std::string*) { return std::optional<RuntimeKit>(display); };
+ RuntimeHost host(second);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(!started.installs[0].title_current && !started.installs[0].runtime_current);
+ saved.revision = 1;
+ saved.overrides = {{"refresh", "120"}, {"frame_limit", "60"}};
const auto before = host.Snapshot().maintenance_handled;
host.Maintain(220, RuntimeMaintenance::kApplySettings);
- return WaitFor(host, [before](const RuntimeSnapshot& s) { return s.maintenance_handled > before; }, 60);
- };
- saved.revision = 1;
- saved.overrides = {{"refresh", "120"}, {"frame_limit", "60"}};
- auto result = apply();
- if (!result.maintenance.at(220).ok) std::fprintf(stderr, "stale apply: %s\n", result.maintenance.at(220).message.c_str());
- CHECK(result.maintenance.at(220).ok && result.installs[0].settings_revision == 1);
- CHECK(Read(profile).find("frame_rate") == std::string::npos && Read(profile).find("refresh") == std::string::npos);
- CHECK(Read(game / "dxvk.conf").find("dxgi.maxFrameRate = 60") != std::string::npos);
+ const auto applied = WaitFor(host, [before](const RuntimeSnapshot& s) { return s.maintenance_handled > before; }, 60);
+ if (!applied.maintenance.at(220).ok) std::fprintf(stderr, "stale apply: %s\n", applied.maintenance.at(220).message.c_str());
+ CHECK(applied.maintenance.at(220).ok && applied.installs[0].settings_revision == 1);
+ CHECK(Read(profile).find("frame_rate") == std::string::npos && Read(profile).find("refresh") == std::string::npos);
+ CHECK(Read(game / "dxvk.conf").find("dxgi.maxFrameRate = 60") != std::string::npos);
+ // Update alone rewrites them for the new runtime: the display paces the cap, DXVK no longer does.
+ const auto updated = update(host);
+ CHECK(updated.installs[0].settings_revision == 1);
+ CHECK(Read(profile).find("\nrefresh = 120\nframe_rate = 60\n") != std::string::npos);
+ CHECK(!fs::exists(game / "dxvk.conf") || Read(game / "dxvk.conf").find("maxFrameRate") == std::string::npos);
+ host.Shutdown();
+ }
+ // Back to a kit revision without 120 Hz output: Update takes frame_rate out again, and DXVK caps the game.
+ auto older = SyntheticKit(fixture.root / "kit-older", "native-3", "kit-1", 'e');
+ older.capabilities = {"dxvk", "offline_bottle", "per_game_title", "wow64_i386"};
+ config.admit_kit = [older](std::string*) { return std::optional<RuntimeKit>(older); };
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ CHECK(!WaitFor(host, Started).installs[0].runtime_current);
+ update(host);
+ CHECK(Read(profile).find("frame_rate") == std::string::npos && Read(profile).find("refresh") == std::string::npos);
+ CHECK(Read(game / "dxvk.conf").find("dxgi.maxFrameRate = 60") != std::string::npos);
+ host.Shutdown();
+ }
+ // Title files that match the kit but runtime artifacts bound from another build: not this kit's runtime.
+ const auto installs = fixture.root / "data/runtime-state/installs.json";
+ auto records = Read(installs);
+ const auto runtime_hash = *HashArtifactFile(fixture.root / "kit-older/runtime/wine/rev/lib/core.prx");
+ const auto at = records.find(runtime_hash);
+ CHECK(at != std::string::npos);
+ records.replace(at, runtime_hash.size(), std::string(runtime_hash.size(), runtime_hash[0] == 'f' ? '0' : 'f'));
+ Write(installs, records, static_cast<unsigned>(fs::status(installs).permissions()) & 0777u);
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ const auto mismatched = WaitFor(host, Started);
+ CHECK(mismatched.installs.size() == 1 && mismatched.installs[0].title_current && !mismatched.installs[0].runtime_current);
+ host.Shutdown();
+}
+// A game prepared on a kit with 120 Hz output publishes its 120 Hz settings with the first profile.
+void FreshPrepareOn120HzKitPublishesIt() {
+ Fixture fixture;
+ unsigned uuids = 0;
+ GameSettingsRecord saved;
+ saved.overrides = {{"refresh", "120"}, {"frame_limit", "40"}};
+ auto config = DisplayConfig(fixture, &uuids, &saved);
+ const auto game = fixture.root / "data/homebrew/FAKE77031/games/220";
+ Write(game / "hl2.exe", "existing-game", 0644);
+ CHECK(chmod(game.c_str(), 0755) == 0);
+ auto kit = SyntheticKit(fixture.root / "kit");
+ kit.capabilities = {"display-120hz", "dxvk", "offline_bottle", "per_game_title", "wow64_i386"};
+ config.admit_kit = [kit](std::string*) { return std::optional<RuntimeKit>(kit); };
+ RuntimeHost host(config);
+ CHECK(host.Start());
host.Prepare(Hl2());
- result = WaitFor(host, [](const RuntimeSnapshot& s) {
- return !s.preparing_app && !s.installs.empty() && (s.installs[0].title_current || s.refusals.count(220));
+ const auto ready = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && (s.refusals.count(220) || (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));
}, 60);
- CHECK(!result.refusals.count(220) && result.installs[0].runtime_current);
- saved.revision = 2;
- result = apply();
- if (!result.maintenance.at(220).ok) std::fprintf(stderr, "updated apply: %s\n", result.maintenance.at(220).message.c_str());
- CHECK(result.maintenance.at(220).ok && result.installs[0].settings_revision == 2);
- CHECK(Read(profile).find("\nrefresh = 120\nframe_rate = 60\n") != std::string::npos);
- CHECK(!fs::exists(game / "dxvk.conf") || Read(game / "dxvk.conf").find("maxFrameRate") == std::string::npos);
+ CHECK(!ready.refusals.count(220) && ready.installs[0].runtime_current);
+ const auto profile = Read(fixture.root / "data/playden/games/steam-220/library/profiles/playden-steam-220.profile");
+ CHECK(profile.find("\nrefresh = 120\nframe_rate = 40\n") != std::string::npos);
host.Shutdown();
}
@@ -4742,6 +4802,7 @@ int main(int argc, char** argv) {
SettingsSavedDuringPrepareReachReadyTitle();
KitRespinKeepsWaitingSettingsUpdate();
StaleTitleWaitsForUpdateBefore120Hz();
+ FreshPrepareOn120HzKitPublishesIt();
RemovesTitleKeepingSaves();
PreparesGameInstalledAgainElsewhere();
SharedProfileKitOpensSaves();