Skip to content

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

C++

Show the frame rate for Direct3D 12 games

Leonardo Lobato25d447d10f71
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index 2830379..37903a9 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -1538,7 +1538,8 @@ 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 || kit.display_framegen || kit.launcher_mode
+ return kit.display_120hz || kit.profile_version_2 || kit.input_rumble || kit.display_framegen || kit.display_fps_counter ||
+ kit.launcher_mode
? rt::KitForTitleRuntime(kit, TitleRuntimeCurrent(c, record))
: kit;
}
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index 3cef29a..f7c365f 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -562,14 +562,17 @@ std::string Unavailable(const SettingDefinition& definition, const std::string&
return "Turn on Start through a launcher first.";
}
if (id == "performance_overlay" && graphics == "gdi") return "Only available with DXVK or OpenGL.";
- // DXVK's overlay is drawn by its Direct3D 9-11 presenter, not by vkd3d-proton's swapchain. The Direct3D 12 row comes
+ // DXVK's overlay is drawn by its Direct3D 9-11 presenter, not by vkd3d-proton's swapchain, so a Direct3D 12 game gets
+ // the driver's counter, which is only the frame rate, from a runtime that has it. The Direct3D 12 row comes
// 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";
// 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 == "performance_overlay" && vkd3d_proton && !framegen && !kit.display_fps_counter)
+ return kit.display_fps_counter_needs_update ? kAppliesAfterKitUpdate : "Not shown for Direct3D 12 games.";
+ if (id == "overlay_detail" && vkd3d_proton)
+ return kit.display_fps_counter ? "Direct3D 12 games show only the frame rate." : "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.";
@@ -1097,7 +1100,12 @@ bool RenderProsperoProfile(const GameRecipe& recipe, const EffectiveSettings& se
// With a kit that reads dxvk.conf, a DXVK game's overlay is dxvk.hud there; the title's
// own DXVK_HUD=fps would override it, so show_fps stays false.
const bool hud_in_config = settings.values.at("overlay_detail").available;
- text += std::string("show_fps = ") + (hud_in_config ? "false" : on("performance_overlay")) + "\n";
+ // A Direct3D 12 game's overlay is the driver's counter instead, unless frame generation draws its own.
+ const auto& framegen = OptionalValue(settings, "framegen");
+ const bool display_framegen = framegen.available && framegen.value != "off";
+ const auto& overlay = settings.values.at("performance_overlay");
+ const bool fps_counter = settings.vkd3d_proton && !display_framegen && overlay.available && overlay.value == "on";
+ text += std::string("show_fps = ") + (hud_in_config || fps_counter ? "false" : on("performance_overlay")) + "\n";
// An OpenGL game always names its rate, as before (60 unless the runtime takes 120 Hz). opengl_thread is no longer
// written: it was the PS5 OpenGL SDK's, and runtimes default it to off.
if (settings.values.at("refresh").available || settings.graphics == "opengl")
@@ -1110,9 +1118,8 @@ bool RenderProsperoProfile(const GameRecipe& recipe, const EffectiveSettings& se
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";
+ if (fps_counter) text += "fps_counter = true\n";
text += "\n[input]\n";
if (value("controller_preset") != "none") text += "preset = " + value("controller_preset") + "\n";
@@ -1260,6 +1267,7 @@ bool RenderProsperoProfile(const GameRecipe& recipe, const EffectiveSettings& se
features.audio_section = audio_section;
features.display_frame_rate = frame_rate;
features.display_framegen = display_framegen;
+ features.display_fps_counter = fps_counter;
features.runtime_version = settings.profile_version == 2;
features.launcher_section = launcher_section;
if (!CheckProsperoProfile(text, &why, features)) return fail("generated profile is invalid: " + why);
@@ -3159,9 +3167,10 @@ namespace playden::runtime {
const std::vector<std::string>& SettingsKitCapabilityNames() {
// Sorted, as a kit manifest lists them.
- static const std::vector<std::string> names = {kKitDisplay120Hz, kKitDisplayFramegen, kKitInputRumble, kKitLauncherMode,
- kKitAudioVolume, kKitDxvkConfig, kKitDxvkPresent,
- kKitInputTuning, kKitInputWheel, kKitEnvironment};
+ static const std::vector<std::string> names = {kKitDisplay120Hz, kKitDisplayFpsCounter, kKitDisplayFramegen,
+ kKitInputRumble, kKitLauncherMode, kKitAudioVolume,
+ kKitDxvkConfig, kKitDxvkPresent, kKitInputTuning,
+ kKitInputWheel, kKitEnvironment};
return names;
}
@@ -3189,6 +3198,7 @@ KitCapabilities KitCapabilitiesFromManifest(const std::vector<std::string>& capa
kit.profile_version_2 = has(kKitProfileVersion2);
kit.input_rumble = has(kKitInputRumble);
kit.display_framegen = has(kKitDisplayFramegen);
+ kit.display_fps_counter = has(kKitDisplayFpsCounter);
kit.launcher_mode = has(kKitLauncherMode);
kit.registry = bottle_access;
return kit;
@@ -3211,6 +3221,10 @@ KitCapabilities KitForTitleRuntime(KitCapabilities kit, bool title_runtime_curre
kit.display_framegen = false;
kit.display_framegen_needs_update = true;
}
+ if (!title_runtime_current && kit.display_fps_counter) {
+ kit.display_fps_counter = false;
+ kit.display_fps_counter_needs_update = true;
+ }
if (!title_runtime_current && kit.launcher_mode) {
kit.launcher_mode = false;
kit.launcher_mode_needs_update = true;
@@ -3483,6 +3497,9 @@ bool CommunityPresetSupported(const CommunityPreset& community, const KitCapabil
else if (feature == "display-framegen") {
if (!kit.display_framegen && !kit.display_framegen_needs_update) return false;
}
+ else if (feature == "display-fps-counter") {
+ if (!kit.display_fps_counter && !kit.display_fps_counter_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 da30ec4..c499511 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -76,6 +76,10 @@ struct KitCapabilities {
// [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;
+ // [display] fps_counter = true (the frame rate drawn by libvulkan.prx, for Direct3D 12 on vkd3d-proton). Counts only
+ // for a title that runs this kit's runtime, like display_120hz.
+ bool display_fps_counter = false;
+ bool display_fps_counter_needs_update = false;
bool launcher_mode = false; // [launcher]: the game starts through a launcher (kKitLauncherMode)
bool launcher_mode_needs_update = false; // the kit has it, but the game's title still runs an older runtime
bool display_framegen_needs_update = false;
@@ -564,6 +568,9 @@ 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";
+// The title reads [display] fps_counter = true: the kit's libvulkan.prx draws the game's frame rate on each frame, for
+// vkd3d-proton, which has no overlay of its own. Runtimes without it refuse a profile with fps_counter.
+inline constexpr const char* kKitDisplayFpsCounter = "display-fps-counter";
// The title reads [launcher]: the exec chain only for a game that asks for it, a second input for the first
// program, and the touchpad hold that swaps them. Runtimes without it refuse a profile with the section.
inline constexpr const char* kKitLauncherMode = "launcher-mode";
@@ -576,7 +583,8 @@ 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, input_rumble and display_framegen are off and their _needs_update say why.
+// display_120hz, profile_version_2, input_rumble, display_framegen and display_fps_counter 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 0e8764e..47b2116 100644
--- a/src/runtime/kit_trust.cpp
+++ b/src/runtime/kit_trust.cpp
@@ -15,7 +15,7 @@ KitAdmissionConfig DevelopmentKitAdmission() {
kKitAudioVolume, kKitDxvkConfig, kKitDxvkPresent, kKitInputTuning,
kKitInputWheel, kKitEnvironment, kKitWineMono, kKitVkd3dProton,
kKitDisplay120Hz, kKitProfileVersion2, kKitInputRumble,
- kKitDisplayFramegen, kKitLauncherMode};
+ kKitDisplayFramegen, kKitDisplayFpsCounter, kKitLauncherMode};
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 bc081fb..25b0d2f 100644
--- a/src/runtime/prospero_profile.cpp
+++ b/src/runtime/prospero_profile.cpp
@@ -313,6 +313,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_fps_counter && key == "fps_counter") {
+ if (!OneOf(value, {"true", "false"})) return bad("not true or false");
} else if (features.display_framegen && key == "framegen") {
if (!OneOf(value, {"off", "2", "3", "4"})) return bad("not off, 2, 3 or 4");
} else {
diff --git a/src/runtime/prospero_profile.h b/src/runtime/prospero_profile.h
index 2daf4ab..cd5dc18 100644
--- a/src/runtime/prospero_profile.h
+++ b/src/runtime/prospero_profile.h
@@ -81,6 +81,7 @@ struct ProsperoProfileFeatures {
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 display_fps_counter = false; // [display] fps_counter = true|false (kit capability display-fps-counter)
bool launcher_section = false; // [launcher] (kit launcher-mode)
bool runtime_version = false; // [runtime] version = 1|2 (kit capability profile-version-2)
};
diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cpp
index 35a2b46..10c77cd 100644
--- a/tests/game_settings_test.cpp
+++ b/tests/game_settings_test.cpp
@@ -425,6 +425,34 @@ int main(int argc, char** argv) {
CHECK(!shown.values.at("performance_overlay").available &&
shown.values.at("performance_overlay").reason == "Not shown for Direct3D 12 games.");
CHECK(!shown.values.at("overlay_detail").available);
+ // A runtime with the driver's counter shows the frame rate instead of DXVK's overlay.
+ auto counter_kit = display;
+ counter_kit.display_fps_counter = true;
+ KitCapabilities counter_stale = display;
+ counter_stale.display_fps_counter_needs_update = true;
+ EffectiveSettings counted;
+ CHECK(BuildEffectiveSettings(d3d12, nullptr, {{"performance_overlay", "on"}}, counter_kit, &counted, &error));
+ CHECK(counted.values.at("performance_overlay").available && !counted.values.at("overlay_detail").available);
+ CHECK(counted.values.at("overlay_detail").reason == "Direct3D 12 games show only the frame rate.");
+ ProsperoProfile counted_profile;
+ CHECK(RenderProsperoProfile(d3d12, counted, target, &counted_profile, &reason));
+ CHECK(counted_profile.text.find("\nfps_counter = true\n") != std::string::npos);
+ CHECK(counted_profile.text.find("show_fps = false\n") != std::string::npos);
+ CHECK(!CheckProsperoProfile(counted_profile.text, &reason, {.debug_env = true}));
+ CHECK(CheckProsperoProfile(counted_profile.text, &reason, {.debug_env = true, .display_fps_counter = true}));
+ // Off writes nothing an older runtime would refuse, and neither does a game on Direct3D 9-11.
+ CHECK(BuildEffectiveSettings(d3d12, nullptr, {}, counter_kit, &counted, &error));
+ CHECK(RenderProsperoProfile(d3d12, counted, target, &counted_profile, &reason));
+ CHECK(counted_profile.text.find("fps_counter") == std::string::npos);
+ CHECK(BuildEffectiveSettings(hl2, nullptr, {{"performance_overlay", "on"}}, counter_kit, &counted, &error));
+ CHECK(RenderProsperoProfile(hl2, counted, target, &counted_profile, &reason));
+ CHECK(counted_profile.text.find("fps_counter") == std::string::npos);
+ // A title on an older runtime keeps the choice for its update, and its profile stays readable there.
+ CHECK(BuildEffectiveSettings(d3d12, nullptr, {{"performance_overlay", "on"}}, counter_stale, &counted, &error));
+ CHECK(!counted.values.at("performance_overlay").available &&
+ counted.values.at("performance_overlay").reason == kAppliesAfterKitUpdate);
+ CHECK(RenderProsperoProfile(d3d12, counted, target, &counted_profile, &reason));
+ CHECK(counted_profile.text.find("fps_counter") == std::string::npos);
std::string vkd3d_rate;
for (const auto& value : RenderBottleEnvironment(shown))
if (value.name == "VKD3D_FRAME_RATE") vkd3d_rate = value.data;
@@ -970,6 +998,11 @@ int main(int argc, char** argv) {
CHECK(!stale.display_framegen && stale.display_framegen_needs_update);
CHECK(KitForTitleRuntime(framegen_kit, true).display_framegen);
CHECK(!KitForTitleRuntime(KitCapabilities{}, false).display_framegen_needs_update);
+ KitCapabilities with_counter;
+ with_counter.display_fps_counter = true;
+ CHECK(KitForTitleRuntime(with_counter, false).display_fps_counter_needs_update);
+ CHECK(!KitForTitleRuntime(with_counter, false).display_fps_counter);
+ CHECK(KitForTitleRuntime(with_counter, true).display_fps_counter);
game.graphics = "dxvk";
CHECK(BuildEffectiveSettings(game, nullptr, chosen, stale, &settings, &error));
const auto& waiting = settings.values.at("framegen");