Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting of post processing filter in config #2136

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static bool separateupdatefolder = false;
static bool compatibilityData = false;
static bool checkCompatibilityOnStartup = false;
static std::string trophyKey;
static std::string ppFilter;

// Gui
static bool load_game_size = true;
Expand Down Expand Up @@ -235,6 +236,10 @@ u32 vblankDiv() {
return vblankDivider;
}

std::string getPostProcessingFilter() {
return ppFilter;
}

bool vkValidationEnabled() {
return vkValidation;
}
Expand Down Expand Up @@ -323,6 +328,10 @@ void setVblankDiv(u32 value) {
vblankDivider = value;
}

void setPostProcessingFilter(const std::string& type) {
ppFilter = type;
}

void setIsFullscreen(bool enable) {
isFullscreen = enable;
}
Expand Down Expand Up @@ -630,6 +639,7 @@ void load(const std::filesystem::path& path) {

screenWidth = toml::find_or<int>(gpu, "screenWidth", screenWidth);
screenHeight = toml::find_or<int>(gpu, "screenHeight", screenHeight);
ppFilter = toml::find_or<std::string>(gpu, "ppFilter", "linear");
isNullGpu = toml::find_or<bool>(gpu, "nullGpu", false);
shouldCopyGPUBuffers = toml::find_or<bool>(gpu, "copyGPUBuffers", false);
shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false);
Expand Down Expand Up @@ -743,6 +753,7 @@ void save(const std::filesystem::path& path) {
data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled;
data["GPU"]["screenWidth"] = screenWidth;
data["GPU"]["screenHeight"] = screenHeight;
data["GPU"]["ppFilter"] = ppFilter;
data["GPU"]["nullGpu"] = isNullGpu;
data["GPU"]["copyGPUBuffers"] = shouldCopyGPUBuffers;
data["GPU"]["dumpShaders"] = shouldDumpShaders;
Expand Down
2 changes: 2 additions & 0 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ bool getIsMotionControlsEnabled();

u32 getScreenWidth();
u32 getScreenHeight();
std::string getPostProcessingFilter();
s32 getGpuId();

bool debugDump();
Expand All @@ -65,6 +66,7 @@ void setNullGpu(bool enable);
void setCopyGPUCmdBuffers(bool enable);
void setDumpShaders(bool enable);
void setVblankDiv(u32 value);
void setPostProcessingFilter(const std::string& type);
void setGpuId(s32 selectedGpuId);
void setScreenWidth(u32 width);
void setScreenHeight(u32 height);
Expand Down
9 changes: 9 additions & 0 deletions src/qt_gui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Right"), "right");
ui->backButtonBehaviorComboBox->addItem(tr("None"), "none");

ui->ppFilterComboBox->addItem(tr("Linear"), "linear");
ui->ppFilterComboBox->addItem(tr("Nearest"), "nearest");

InitializeEmulatorLanguages();
LoadValuesFromConfig();

Expand Down Expand Up @@ -302,6 +305,11 @@ void SettingsDialog::LoadValuesFromConfig() {
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));
if (const auto i = ui->ppFilterComboBox->findData(
QString::fromStdString(toml::find_or<std::string>(data, "GPU", "ppFilter", "linear")));
i != -1) {
ui->ppFilterComboBox->setCurrentIndex(i);
}
ui->dumpShadersCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "dumpShaders", false));
ui->nullGpuCheckBox->setChecked(toml::find_or<bool>(data, "GPU", "nullGpu", false));
ui->playBGMCheckBox->setChecked(toml::find_or<bool>(data, "General", "playBGM", false));
Expand Down Expand Up @@ -566,6 +574,7 @@ void SettingsDialog::UpdateSettings() {
Config::setScreenWidth(ui->widthSpinBox->value());
Config::setScreenHeight(ui->heightSpinBox->value());
Config::setVblankDiv(ui->vblankSpinBox->value());
Config::setPostProcessingFilter(ui->ppFilterComboBox->currentData().toString().toStdString());
Config::setDumpShaders(ui->dumpShadersCheckBox->isChecked());
Config::setNullGpu(ui->nullGpuCheckBox->isChecked());
Config::setSeparateUpdateEnabled(ui->separateUpdatesCheckBox->isChecked());
Expand Down
24 changes: 18 additions & 6 deletions src/qt_gui/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>586</height>
<width>463</width>
<height>246</height>
</rect>
</property>
<layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0">
Expand Down Expand Up @@ -978,6 +978,18 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="ppFilterGroupBox">
<property name="title">
<string>Post-Processing Filter</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="ppFilterComboBox"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -1193,8 +1205,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>586</height>
<width>218</width>
<height>173</height>
</rect>
</property>
<layout class="QVBoxLayout" name="pathsTabLayout" stretch="0">
Expand Down Expand Up @@ -1266,8 +1278,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>586</height>
<width>510</width>
<height>269</height>
</rect>
</property>
<layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,1">
Expand Down
14 changes: 12 additions & 2 deletions src/video_core/renderer_vulkan/vk_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,19 @@ void Presenter::CreatePostProcessPipeline() {
instance.GetDevice().destroyShaderModule(fs_module);

// Create sampler resource
const auto filters = std::unordered_map<std::string, vk::Filter>{
{"linear", vk::Filter::eLinear},
{"nearest", vk::Filter::eNearest},
};
auto pp_filter = vk::Filter::eLinear;
if (const auto filter = Config::getPostProcessingFilter(); filters.contains(filter)) {
pp_filter = filters.at(filter);
} else {
LOG_WARNING(Render_Vulkan, "Unknown post processing filter: {}", filter);
}
const vk::SamplerCreateInfo sampler_ci = {
.magFilter = vk::Filter::eLinear,
.minFilter = vk::Filter::eLinear,
.magFilter = pp_filter,
.minFilter = pp_filter,
.mipmapMode = vk::SamplerMipmapMode::eNearest,
.addressModeU = vk::SamplerAddressMode::eClampToEdge,
.addressModeV = vk::SamplerAddressMode::eClampToEdge,
Expand Down