Replace Vblank Divider with Vblank Frequency (#3532)

This commit is contained in:
UltraDaCat
2025-09-07 00:00:26 +02:00
committed by GitHub
parent 0e7e100a7e
commit 5e3ffeafbe
7 changed files with 34 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <fstream>
@@ -140,7 +140,7 @@ static ConfigEntry<bool> readbackLinearImagesEnabled(false);
static ConfigEntry<bool> directMemoryAccessEnabled(false);
static ConfigEntry<bool> shouldDumpShaders(false);
static ConfigEntry<bool> shouldPatchShaders(false);
static ConfigEntry<u32> vblankDivider(1);
static ConfigEntry<u32> vblankFrequency(60);
static ConfigEntry<bool> isFullscreen(false);
static ConfigEntry<string> fullscreenMode("Windowed");
static ConfigEntry<string> presentMode("Mailbox");
@@ -398,8 +398,8 @@ bool isLoggingEnabled() {
return logEnabled.get();
}
u32 vblankDiv() {
return vblankDivider.get();
u32 vblankFreq() {
return vblankFrequency.get();
}
bool vkValidationEnabled() {
@@ -530,8 +530,8 @@ void setRdocEnabled(bool enable) {
rdocEnable.base_value = enable;
}
void setVblankDiv(u32 value) {
vblankDivider.base_value = value;
void setVblankFreq(u32 value) {
vblankFrequency.base_value = value;
}
void setIsFullscreen(bool enable) {
@@ -821,7 +821,7 @@ void load(const std::filesystem::path& path, bool is_game_specific) {
directMemoryAccessEnabled.setFromToml(gpu, "directMemoryAccess", is_game_specific);
shouldDumpShaders.setFromToml(gpu, "dumpShaders", is_game_specific);
shouldPatchShaders.setFromToml(gpu, "patchShaders", is_game_specific);
vblankDivider.setFromToml(gpu, "vblankDivider", is_game_specific);
vblankFrequency.setFromToml(gpu, "vblankFrequency", is_game_specific);
isFullscreen.setFromToml(gpu, "Fullscreen", is_game_specific);
fullscreenMode.setFromToml(gpu, "FullscreenMode", is_game_specific);
presentMode.setFromToml(gpu, "presentMode", is_game_specific);
@@ -992,7 +992,7 @@ void save(const std::filesystem::path& path) {
data["GPU"]["directMemoryAccess"] = directMemoryAccessEnabled.base_value;
data["GPU"]["dumpShaders"] = shouldDumpShaders.base_value;
data["GPU"]["patchShaders"] = shouldPatchShaders.base_value;
data["GPU"]["vblankDivider"] = vblankDivider.base_value;
data["GPU"]["vblankFrequency"] = vblankFrequency.base_value;
data["GPU"]["Fullscreen"] = isFullscreen.base_value;
data["GPU"]["FullscreenMode"] = fullscreenMode.base_value;
data["GPU"]["presentMode"] = presentMode.base_value;
@@ -1103,7 +1103,7 @@ void setDefaultValues() {
directMemoryAccessEnabled = false;
shouldDumpShaders = false;
shouldPatchShaders = false;
vblankDivider = 1;
vblankFrequency = 60;
isFullscreen = false;
fullscreenMode = "Windowed";
presentMode = "Mailbox";

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -61,8 +61,8 @@ bool directMemoryAccess();
void setDirectMemoryAccess(bool enable);
bool dumpShaders();
void setDumpShaders(bool enable);
u32 vblankDiv();
void setVblankDiv(u32 value);
u32 vblankFreq();
void setVblankFreq(u32 value);
bool getisTrophyPopupDisabled();
void setisTrophyPopupDisabled(bool disable);
s16 getCursorState();

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "frame_graph.h"
@@ -13,7 +13,6 @@ using namespace ImGui;
namespace Core::Devtools::Widget {
constexpr float TARGET_FPS = 60.0f;
constexpr float BAR_WIDTH_MULT = 1.4f;
constexpr float BAR_HEIGHT_MULT = 1.25f;
constexpr float FRAME_GRAPH_PADDING_Y = 3.0f;
@@ -30,7 +29,7 @@ void FrameGraph::DrawFrameGraph() {
return;
}
float target_dt = 1.0f / (TARGET_FPS * (float)Config::vblankDiv());
float target_dt = 1.0f / (float)Config::vblankFreq();
float cur_pos_x = pos.x + full_width;
pos.y += FRAME_GRAPH_PADDING_Y;
const float final_pos_y = pos.y + FRAME_GRAPH_HEIGHT;

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/assert.h"
@@ -269,8 +269,7 @@ void VideoOutDriver::SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_
}
void VideoOutDriver::PresentThread(std::stop_token token) {
static constexpr std::chrono::nanoseconds VblankPeriod{16666667};
const auto vblank_period = VblankPeriod / Config::vblankDiv();
const std::chrono::nanoseconds vblank_period(1000000000 / Config::vblankFreq());
Common::SetCurrentThreadName("shadPS4:PresentThread");
Common::SetCurrentThreadRealtime(vblank_period);

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <filesystem>
@@ -145,7 +145,7 @@ void Emulator::Run(std::filesystem::path file, const std::vector<std::string> ar
LOG_INFO(Config, "GPU readbackLinearImages: {}", Config::readbackLinearImages());
LOG_INFO(Config, "GPU directMemoryAccess: {}", Config::directMemoryAccess());
LOG_INFO(Config, "GPU shouldDumpShaders: {}", Config::dumpShaders());
LOG_INFO(Config, "GPU vblankDivider: {}", Config::vblankDiv());
LOG_INFO(Config, "GPU vblankFrequency: {}", Config::vblankFreq());
LOG_INFO(Config, "Vulkan gpuId: {}", Config::getGpuId());
LOG_INFO(Config, "Vulkan vkValidation: {}", Config::vkValidationEnabled());
LOG_INFO(Config, "Vulkan vkValidationSync: {}", Config::vkValidationSyncEnabled());

View File

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <vector>
@@ -571,7 +571,7 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->graphicsAdapterBox->setCurrentIndex(toml::find_or<int>(data, "Vulkan", "gpuId", -1) + 1);
ui->widthSpinBox->setValue(toml::find_or<int>(data, "GPU", "screenWidth", 1280));
ui->heightSpinBox->setValue(toml::find_or<int>(data, "GPU", "screenHeight", 720));
ui->vblankSpinBox->setValue(toml::find_or<int>(data, "GPU", "vblankDivider", 1));
ui->vblankSpinBox->setValue(toml::find_or<int>(data, "GPU", "vblankFrequency", 60));
ui->dumpShadersCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "dumpShaders", false));
ui->nullGpuCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "nullGpu", false));
ui->enableHDRCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "allowHDR", false));
@@ -817,7 +817,7 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
} else if (elementName == "windowSizeGroupBox") {
text = tr("Width/Height:\\nSets the size of the emulator window at launch, which can be resized during gameplay.\\nThis is different from the in-game resolution.");
} else if (elementName == "heightDivider") {
text = tr("Vblank Divider:\\nThe frame rate at which the emulator refreshes at is multiplied by this number. Changing this may have adverse effects, such as increasing the game speed, or breaking critical game functionality that does not expect this to change!");
text = tr("Vblank Frequency:\\nThe frame rate at which the emulator refreshes at is multiplied by this number. Changing this may have adverse effects, such as increasing the game speed, or breaking critical game functionality that does not expect this to change!");
} else if (elementName == "dumpShadersCheckBox") {
text = tr("Enable Shaders Dumping:\\nFor the sake of technical debugging, saves the games shaders to a folder as they render.");
} else if (elementName == "nullGpuCheckBox") {
@@ -947,7 +947,7 @@ void SettingsDialog::UpdateSettings() {
Config::setEnableDiscordRPC(ui->discordRPCCheckbox->isChecked());
Config::setWindowWidth(ui->widthSpinBox->value());
Config::setWindowHeight(ui->heightSpinBox->value());
Config::setVblankDiv(ui->vblankSpinBox->value());
Config::setVblankFreq(ui->vblankSpinBox->value());
Config::setDumpShaders(ui->dumpShadersCheckBox->isChecked());
Config::setNullGpu(ui->nullGpuCheckBox->isChecked());
Config::setFsrEnabled(ui->FSRCheckBox->isChecked());

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
<!-- SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
SPDX-License-Identifier: GPL-2.0-or-later -->
<ui version="4.0">
<class>SettingsDialog</class>
@@ -1211,7 +1211,7 @@
<item>
<widget class="QGroupBox" name="heightDivider">
<property name="title">
<string>Vblank Divider</string>
<string>Vblank Frequency</string>
</property>
<layout class="QVBoxLayout" name="vblankLayout">
<item>
@@ -1219,6 +1219,12 @@
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
@@ -1228,6 +1234,9 @@
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string>Hz</string>
</property>
<property name="minimum">
<number>1</number>
</property>
@@ -1235,7 +1244,7 @@
<number>9999</number>
</property>
<property name="value">
<number>1</number>
<number>60</number>
</property>
</widget>
</item>