Skip to content

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

C++

Add Frame generation to Game settings

Leonardo Lobato5f9f872a0493
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index 10cc6fc..a57c117 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -1468,7 +1468,7 @@ rt::KitCapabilities RuntimeHost::TitleKit(const Composition& c, const rt::Runtim
if (!c.kit) return {};
const auto kit = rt::KitCapabilitiesFromManifest(c.kit->capabilities, true);
// The title's markers are read only when the kit has something an older runtime would refuse.
- return kit.display_120hz || kit.profile_version_2 || kit.input_rumble
+ return kit.display_120hz || kit.profile_version_2 || kit.input_rumble || kit.display_framegen
? rt::KitForTitleRuntime(kit, TitleRuntimeCurrent(c, record))
: kit;
}
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index 1757a85..dfc7003 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -97,6 +97,17 @@ std::vector<SettingDefinition> BuildCatalogue() {
{{"off", "Off", "No cap."}, {"120", "120", ""}, {"60", "60", ""}, {"40", "40", ""},
{"30", "30", ""}},
"off", 2));
+ // MihawkGen in the kit's libvulkan.prx ([display] framegen): the pictures between the game's frames are made up, and
+ // the display (FIFO) paces them, so the game runs at the TV's rate divided by the factor.
+ list.push_back(Choice("framegen", "Frame generation",
+ "Adds made-up pictures between the game's frames for smoother motion. The game responds about "
+ "one frame later.",
+ "[display] framegen · MihawkGen", G::kDisplay,
+ {{"off", "Off", ""},
+ {"2", "2×", "The game runs at half the TV's rate: 30 fps shows as 60."},
+ {"3", "3×", "The game runs at a third of the TV's rate: 20 fps shows as 60."},
+ {"4", "4×", "The game runs at a quarter of the TV's rate: 15 fps shows as 60."}},
+ "off", 2));
list.push_back(Choice("vsync", "VSync", "Waits for the TV before showing a frame. Stops tearing, adds some delay.",
"dxgi.syncInterval · d3d9.presentInterval", G::kDisplay,
{{"game", "Game default", "The game's own setting."},
@@ -469,11 +480,29 @@ bool FrameLimitOwnsCap(const EffectiveSettings& settings) {
return settings.display_120hz && limit.available && limit.value != "off";
}
+// Whether frame generation applies: a display-framegen runtime, a game that presents through Vulkan (DXVK or Zink) and
+// a factor chosen. Frame limit comes before the row in the catalogue, so this reads the value as chosen.
+bool FramegenOn(const std::string& graphics, const KitCapabilities& kit,
+ const std::map<std::string, EffectiveValue>& values) {
+ const auto framegen = values.find("framegen");
+ return kit.display_framegen && (graphics == "dxvk" || graphics == "opengl") && framegen != values.end() &&
+ framegen->second.value != "off";
+}
+
std::string Unavailable(const SettingDefinition& definition, const std::string& graphics, const KitCapabilities& kit,
const std::map<std::string, EffectiveValue>& values) {
const auto& id = definition.id;
const bool dxvk = graphics == "dxvk";
const bool display_graphics = dxvk || graphics == "opengl";
+ // Frame generation's pictures fill every vblank, so it sets the game's pace and always waits for the TV.
+ const bool framegen = FramegenOn(graphics, kit, values);
+ if (id == "frame_limit" && framegen) return "Frame generation sets the frame rate.";
+ if (id == "vsync" && framegen) return "Frame generation always waits for the TV.";
+ if (id == "framegen") {
+ if (!display_graphics) return "Only with DXVK or OpenGL.";
+ if (kit.display_framegen_needs_update) return kAppliesAfterKitUpdate;
+ if (!kit.display_framegen) return "Needs a runtime kit with frame generation.";
+ }
// A display-120hz runtime paces the frame limit itself on every Vulkan path (DXVK, vkd3d-proton, Zink).
if (id == "frame_limit" && kit.display_120hz) {
if (!display_graphics) return "Only with DXVK or OpenGL.";
@@ -520,7 +549,10 @@ std::string Unavailable(const SettingDefinition& definition, const std::string&
// later in the catalogue, so its value here is not checked yet: the same test it gets below.
const auto d3d12 = values.find("d3d12");
const bool vkd3d_proton = kit.vkd3d_proton && dxvk && d3d12 != values.end() && d3d12->second.value == "vkd3d-proton";
- if ((id == "performance_overlay" || id == "overlay_detail") && vkd3d_proton) return "Not shown for Direct3D 12 games.";
+ // With frame generation the overlay is its own counter (the game's frames and the pictures shown), on every path.
+ if (id == "overlay_detail" && framegen) return "Frame generation shows its own counter.";
+ if (id == "performance_overlay" && vkd3d_proton && !framegen) return "Not shown for Direct3D 12 games.";
+ if (id == "overlay_detail" && vkd3d_proton) return "Not shown for Direct3D 12 games.";
if (id == "overlay_detail") {
if (!dxvk) return "Only available with DXVK.";
if (!kit.dxvk_config) return "Needs a runtime that reads dxvk.conf.";
@@ -1045,6 +1077,10 @@ bool RenderProsperoProfile(const GameRecipe& recipe, const EffectiveSettings& se
const bool frame_rate =
settings.display_120hz && limit.available && limit.value != "off" && SoftwareFrameLimit(settings).empty();
if (frame_rate) text += "frame_rate = " + limit.value + "\n";
+ // Only for a title whose runtime takes it: an older runtime refuses the whole profile for this key.
+ const auto& framegen = OptionalValue(settings, "framegen");
+ const bool display_framegen = framegen.available && framegen.value != "off";
+ if (display_framegen) text += "framegen = " + framegen.value + "\n";
text += "\n[input]\n";
if (value("controller_preset") != "none") text += "preset = " + value("controller_preset") + "\n";
@@ -1169,6 +1205,7 @@ bool RenderProsperoProfile(const GameRecipe& recipe, const EffectiveSettings& se
features.input_wheel = wheel;
features.audio_section = audio_section;
features.display_frame_rate = frame_rate;
+ features.display_framegen = display_framegen;
features.runtime_version = settings.profile_version == 2;
if (!CheckProsperoProfile(text, &why, features)) return fail("generated profile is invalid: " + why);
*profile = {target.id, std::move(text)};
@@ -2913,8 +2950,9 @@ namespace playden::runtime {
const std::vector<std::string>& SettingsKitCapabilityNames() {
// Sorted, as a kit manifest lists them.
- static const std::vector<std::string> names = {kKitDisplay120Hz, kKitInputRumble, kKitAudioVolume, kKitDxvkConfig,
- kKitDxvkPresent, kKitInputTuning, kKitInputWheel, kKitEnvironment};
+ static const std::vector<std::string> names = {kKitDisplay120Hz, kKitDisplayFramegen, kKitInputRumble,
+ kKitAudioVolume, kKitDxvkConfig, kKitDxvkPresent,
+ kKitInputTuning, kKitInputWheel, kKitEnvironment};
return names;
}
@@ -2941,6 +2979,7 @@ KitCapabilities KitCapabilitiesFromManifest(const std::vector<std::string>& capa
kit.display_120hz = has(kKitDisplay120Hz);
kit.profile_version_2 = has(kKitProfileVersion2);
kit.input_rumble = has(kKitInputRumble);
+ kit.display_framegen = has(kKitDisplayFramegen);
kit.registry = bottle_access;
return kit;
}
@@ -2958,6 +2997,10 @@ KitCapabilities KitForTitleRuntime(KitCapabilities kit, bool title_runtime_curre
kit.input_rumble = false;
kit.input_rumble_needs_update = true;
}
+ if (!title_runtime_current && kit.display_framegen) {
+ kit.display_framegen = false;
+ kit.display_framegen_needs_update = true;
+ }
return kit;
}
@@ -3221,6 +3264,9 @@ bool CommunityPresetSupported(const CommunityPreset& community, const KitCapabil
else if (feature == "input-rumble") {
if (!kit.input_tuning && !kit.input_rumble && !kit.input_rumble_needs_update) return false;
}
+ else if (feature == "display-framegen") {
+ if (!kit.display_framegen && !kit.display_framegen_needs_update) return false;
+ }
// Legacy PR references are informational sidecar provenance. Unknown feature
// names or version requirements need verified support before a preset is shown.
else if (feature.size() < 2 || feature.front() != '#' ||
diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.h
index 980dcd0..80c118c 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -73,6 +73,10 @@ struct KitCapabilities {
// runtime, like display_120hz.
bool input_rumble = false;
bool input_rumble_needs_update = false;
+ // [display] framegen = off|2|3|4 (frame generation in libvulkan.prx). Counts only for a title that runs this kit's
+ // runtime, like display_120hz.
+ bool display_framegen = false;
+ bool display_framegen_needs_update = false;
};
struct SettingChoice {
@@ -478,10 +482,9 @@ bool ParseCommunityRecipe(std::string_view json, CommunityRecipe* community, std
// Whether the kit's runtime has every newer profile feature the sidecar declares in
// requires.prospero_win: the kit capability names without "settings-" (profile-environment,
-// input-tuning, input-wheel, audio-volume; see prospero-win-profiles SIDECARS.md), and display-120hz and input-rumble,
-// which need the
-// game's own title on such a runtime: pass the kit as KitForTitleRuntime gives it for the game. Other entries
-// (pull requests, versions) are not checked.
+// input-tuning, input-wheel, audio-volume; see prospero-win-profiles SIDECARS.md), and display-120hz, input-rumble and
+// display-framegen, which need the game's own title on such a runtime: pass the kit as KitForTitleRuntime gives it
+// for the game. Other entries (pull requests, versions) are not checked.
bool CommunityPresetSupported(const CommunityPreset& community, const KitCapabilities& kit);
// --- Integration contract (roadmap S4, integration Tasks 4-6 and 8) ---
@@ -525,6 +528,9 @@ inline constexpr const char* kKitProfileVersion2 = "profile-version-2";
// The title scales the game's vibration, the DualSense's motors and its L2/R2 trigger vibration, by [input] rumble =
// 0-100 (0 turns it off). Runtimes without it refuse a profile with rumble.
inline constexpr const char* kKitInputRumble = "input-rumble";
+// The title reads [display] framegen = off|2|3|4: the kit's libvulkan.prx shows that many pictures for each frame a
+// Vulkan-presenting game (DXVK, Zink) draws, made by MihawkGen. Runtimes without it refuse a profile with framegen.
+inline constexpr const char* kKitDisplayFramegen = "display-framegen";
const std::vector<std::string>& SettingsKitCapabilityNames();
// Settings gates from a verified kit's capabilities. bottle_access: the adapter can edit the
@@ -534,7 +540,7 @@ KitCapabilities KitCapabilitiesFromManifest(const std::vector<std::string>& capa
// The installed kit's capabilities for one game's title. A prepared title keeps its own copy of the runtime until
// Update, so a capability that adds profile keys counts only when the title runs this kit's runtime
// (title_runtime_current: the title's owner markers name this kit, PackageInstaller::TitleCurrent). Otherwise
-// display_120hz, profile_version_2 and input_rumble are off and their _needs_update say why.
+// display_120hz, profile_version_2, input_rumble and display_framegen are off and their _needs_update say why.
KitCapabilities KitForTitleRuntime(KitCapabilities kit, bool title_runtime_current);
// Everything one game's settings put on disk for its next launch.
diff --git a/src/runtime/kit_trust.cpp b/src/runtime/kit_trust.cpp
index 99ccbb9..0974385 100644
--- a/src/runtime/kit_trust.cpp
+++ b/src/runtime/kit_trust.cpp
@@ -14,7 +14,8 @@ KitAdmissionConfig DevelopmentKitAdmission() {
kKitTitleAnyId, kKitGameRootUnowned, kKitBottleProfileShared, kKitOpenGLZink,
kKitAudioVolume, kKitDxvkConfig, kKitDxvkPresent, kKitInputTuning,
kKitInputWheel, kKitEnvironment, kKitWineMono, kKitVkd3dProton,
- kKitDisplay120Hz, kKitProfileVersion2, kKitInputRumble};
+ kKitDisplay120Hz, kKitProfileVersion2, kKitInputRumble,
+ kKitDisplayFramegen};
std::sort(config.known_capabilities.begin(), config.known_capabilities.end());
return config;
}
diff --git a/src/runtime/prospero_profile.cpp b/src/runtime/prospero_profile.cpp
index 8adf72a..3d14653 100644
--- a/src/runtime/prospero_profile.cpp
+++ b/src/runtime/prospero_profile.cpp
@@ -312,6 +312,8 @@ bool CheckProsperoProfile(std::string_view text, std::string* reason, ProsperoPr
if (value != "60" && value != "120") return bad("not 60 or 120");
} else if (features.display_frame_rate && key == "frame_rate") {
if (!OneOf(value, {"0", "120", "60", "40", "30"})) return bad("not 0, 120, 60, 40 or 30");
+ } else if (features.display_framegen && key == "framegen") {
+ if (!OneOf(value, {"off", "2", "3", "4"})) return bad("not off, 2, 3 or 4");
} else {
return fail("unknown [display] key " + key);
}
diff --git a/src/runtime/prospero_profile.h b/src/runtime/prospero_profile.h
index f4607a5..32b2c30 100644
--- a/src/runtime/prospero_profile.h
+++ b/src/runtime/prospero_profile.h
@@ -80,6 +80,7 @@ struct ProsperoProfileFeatures {
bool audio_section = false; // [audio] volume
bool debug_env = false; // [debug] env = NAME=value (upstream prospero-win)
bool display_frame_rate = false; // [display] frame_rate = 0|120|60|40|30 (kit capability display-120hz)
+ bool display_framegen = false; // [display] framegen = off|2|3|4 (kit capability display-framegen)
bool runtime_version = false; // [runtime] version = 1|2 (kit capability profile-version-2)
};
// A [debug] env variable the runtime takes: PW_, DXVK_, MESA_, GALLIUM_, ZINK_, RADV_ or VK_ names, without the ones
diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cpp
index d3387f1..9e408ac 100644
--- a/tests/game_settings_test.cpp
+++ b/tests/game_settings_test.cpp
@@ -76,7 +76,7 @@ int main(int argc, char** argv) {
if (definition.group != SettingGroup::kButtonMapping) ids.push_back(definition.id);
const std::vector<std::string> expected = {
"launch_option", "program", "extra_arguments",
- "resolution", "refresh", "frame_limit", "vsync", "performance_overlay", "overlay_detail", "scaling",
+ "resolution", "refresh", "frame_limit", "framegen", "vsync", "performance_overlay", "overlay_detail", "scaling",
"window_view",
"controller", "controller_preset",
"pointer_stick", "pointer_speed", "stick_deadzone", "rumble", "invert_stick", "trigger_deadzone", "wheel_stick",
@@ -872,6 +872,64 @@ int main(int argc, char** argv) {
CHECK(BuildEffectiveSettings(hl2, nullptr, {{"controller", "keyboard"}, {"rumble", "0"}}, rumble_kit, &settings, &error));
CHECK(settings.values.at("rumble").reason == "Only with the Xbox controller.");
}
+ // Frame generation (display-framegen) on DXVK and OpenGL, once the title runs the kit's runtime. Its pictures fill
+ // every vblank, so it takes over Frame limit and VSync, and the overlay is its own counter.
+ {
+ const auto framegen_kit =
+ KitCapabilitiesFromManifest({kKitDxvk, kKitDxvkPresent, kKitVkd3dProton, kKitDisplay120Hz, kKitDisplayFramegen}, false);
+ CHECK(framegen_kit.display_framegen && !KitCapabilitiesFromManifest({kKitDxvk}, false).display_framegen);
+ auto game = hl2;
+ game.graphics = "dxvk";
+ const std::map<std::string, std::string> chosen = {
+ {"framegen", "2"}, {"frame_limit", "30"}, {"vsync", "off"}, {"performance_overlay", "on"}};
+ CHECK(BuildEffectiveSettings(game, nullptr, chosen, framegen_kit, &settings, &error));
+ CHECK(settings.values.at("framegen").available && Value(settings, "framegen") == "2");
+ CHECK(!settings.values.at("frame_limit").available &&
+ settings.values.at("frame_limit").reason == "Frame generation sets the frame rate.");
+ CHECK(!settings.values.at("vsync").available &&
+ settings.values.at("vsync").reason == "Frame generation always waits for the TV.");
+ CHECK(!settings.values.at("overlay_detail").available && settings.values.at("performance_overlay").available);
+ CHECK(RenderProsperoProfile(game, settings, target, &profile, &reason));
+ CHECK(profile.text.find("\nframegen = 2\n") != std::string::npos);
+ CHECK(profile.text.find("frame_rate") == std::string::npos && profile.text.find("show_fps = true\n") != std::string::npos);
+ const auto dxvk_conf = RenderDxvkConfig(settings);
+ CHECK(dxvk_conf.find("maxFrameRate") == std::string::npos && dxvk_conf.find("syncInterval") == std::string::npos &&
+ dxvk_conf.find("dxvk.hud") == std::string::npos);
+ CHECK(!CheckProsperoProfile(profile.text, &reason));
+ CHECK(CheckProsperoProfile(profile.text, &reason, {.display_framegen = true}));
+ // A Direct3D 12 game gets the counter too: frame generation draws it, not DXVK.
+ auto d3d12 = chosen;
+ d3d12["d3d12"] = "vkd3d-proton";
+ CHECK(BuildEffectiveSettings(game, nullptr, d3d12, framegen_kit, &settings, &error));
+ CHECK(settings.values.at("performance_overlay").available && !settings.values.at("overlay_detail").available);
+ // Off writes nothing and leaves the other rows as they were.
+ CHECK(BuildEffectiveSettings(game, nullptr, {{"frame_limit", "30"}}, framegen_kit, &settings, &error));
+ CHECK(settings.values.at("frame_limit").available && settings.values.at("vsync").available);
+ CHECK(RenderProsperoProfile(game, settings, target, &profile, &reason));
+ CHECK(profile.text.find("framegen") == std::string::npos);
+ // GDI does not present through Vulkan; a kit without the capability says so.
+ game.graphics = "gdi";
+ CHECK(BuildEffectiveSettings(game, nullptr, chosen, framegen_kit, &settings, &error));
+ CHECK(!settings.values.at("framegen").available &&
+ settings.values.at("framegen").reason == "Only with DXVK or OpenGL.");
+ game.graphics = "opengl";
+ CHECK(BuildEffectiveSettings(game, nullptr, chosen, KitCapabilitiesFromManifest({kKitDxvk}, false), &settings, &error));
+ CHECK(settings.values.at("framegen").reason == "Needs a runtime kit with frame generation.");
+ CHECK(BuildEffectiveSettings(game, nullptr, chosen, framegen_kit, &settings, &error));
+ CHECK(settings.values.at("framegen").available && !settings.values.at("frame_limit").available);
+ // A title on an older runtime keeps the choice for its update; until then the other rows apply as before.
+ const auto stale = KitForTitleRuntime(framegen_kit, false);
+ CHECK(!stale.display_framegen && stale.display_framegen_needs_update);
+ CHECK(KitForTitleRuntime(framegen_kit, true).display_framegen);
+ CHECK(!KitForTitleRuntime(KitCapabilities{}, false).display_framegen_needs_update);
+ game.graphics = "dxvk";
+ CHECK(BuildEffectiveSettings(game, nullptr, chosen, stale, &settings, &error));
+ const auto& waiting = settings.values.at("framegen");
+ CHECK(!waiting.available && waiting.waits_for_update && waiting.after_update == "2");
+ CHECK(settings.values.at("vsync").available);
+ CHECK(RenderProsperoProfile(game, settings, target, &profile, &reason));
+ CHECK(profile.text.find("framegen") == std::string::npos);
+ }
// Trigger dead zone rides with controller tuning; the wheel and volume have their own gates.
const std::map<std::string, std::string> more_tuning = {
@@ -1141,6 +1199,12 @@ int main(int argc, char** argv) {
CHECK(CommunityPresetSupported(needs_rumble, rumble) && CommunityPresetSupported(needs_rumble, KitForTitleRuntime(rumble, false)));
CHECK(CommunityPresetSupported(needs_rumble, KitCapabilitiesFromManifest({kKitInputTuning}, false)));
CHECK(!CommunityPresetSupported(needs_rumble, KitCapabilitiesFromManifest({kKitDxvk}, false)));
+ auto needs_framegen = community;
+ needs_framegen.requires_prospero_win.push_back("display-framegen");
+ const auto framegen = KitCapabilitiesFromManifest({kKitDisplayFramegen}, false);
+ CHECK(CommunityPresetSupported(needs_framegen, framegen) &&
+ CommunityPresetSupported(needs_framegen, KitForTitleRuntime(framegen, false)));
+ CHECK(!CommunityPresetSupported(needs_framegen, KitCapabilitiesFromManifest({kKitDxvk}, false)));
}
CHECK(BuildEffectiveSettings(hl2, &community.preset, {}, KitCapabilities{}, &settings, &error));
CHECK(settings.values.at("controller").value == "keyboard");
diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cpp
index ef489ff..4cef23f 100644
--- a/tests/homebrew_simulation_test.cpp
+++ b/tests/homebrew_simulation_test.cpp
@@ -374,10 +374,10 @@ void t08b_settings_sheet_rules(const std::filesystem::path& fixtures, const std:
activate(simulation, "game-settings");
// Rows by topic: the frame-rate rows sit together in Display, and focus steps over the headings.
const auto& keys = simulation.state().navigation.modals.back().action_keys;
- const std::vector<std::string> top(keys.begin(), keys.begin() + std::min<std::size_t>(keys.size(), 22));
+ const std::vector<std::string> top(keys.begin(), keys.begin() + std::min<std::size_t>(keys.size(), 23));
check(top == std::vector<std::string>{"preset-picker", "heading-game", "setting-launch_option", "setting-extra_arguments",
"heading-display", "setting-resolution", "setting-refresh", "setting-frame_limit",
- "setting-vsync", "setting-performance_overlay", "setting-overlay_detail",
+ "setting-framegen", "setting-vsync", "setting-performance_overlay", "setting-overlay_detail",
"setting-scaling", "setting-window_view", "heading-controls", "setting-controller",
"setting-controller_preset", "button-mapping", "controller-tuning", "heading-sound",
"setting-volume", "section-compatibility", "section-advanced"},
diff --git a/tests/prospero_profile_test.cpp b/tests/prospero_profile_test.cpp
index 53ebe1e..66c882a 100644
--- a/tests/prospero_profile_test.cpp
+++ b/tests/prospero_profile_test.cpp
@@ -174,6 +174,11 @@ int main(int argc, char** argv) {
CHECK(CheckProsperoProfile(base + "[display]\nrefresh = 120\nframe_rate = " + rate + "\n", &reason,
{.display_frame_rate = true}));
CHECK(!CheckProsperoProfile(base + "[display]\nframe_rate = 50\n", &reason, {.display_frame_rate = true}));
+ // [display] framegen needs a display-framegen runtime.
+ CHECK(!CheckProsperoProfile(base + "[display]\nframegen = 2\n", &reason));
+ for (const char* factor : {"off", "2", "3", "4"})
+ CHECK(CheckProsperoProfile(base + "[display]\nframegen = " + factor + "\n", &reason, {.display_framegen = true}));
+ CHECK(!CheckProsperoProfile(base + "[display]\nframegen = 5\n", &reason, {.display_framegen = true}));
CHECK(CheckProsperoProfile(base + "[display]\nopengl_thread = true\n", &reason));
CHECK(!CheckProsperoProfile(base + "[input]\nmouse_speed = 0\n", &reason));
CHECK(!CheckProsperoProfile(base + "[input]\nrumble = 50\n", &reason)); // released runtimes refuse it