Allow setting of post processing filter in config

This commit is contained in:
Quang Ngô 2025-01-12 19:36:34 +07:00
parent 1ea5f8f092
commit 8885f4377b
3 changed files with 20 additions and 2 deletions

View File

@ -71,6 +71,7 @@ static bool separateupdatefolder = false;
static bool compatibilityData = false; static bool compatibilityData = false;
static bool checkCompatibilityOnStartup = false; static bool checkCompatibilityOnStartup = false;
static std::string trophyKey; static std::string trophyKey;
static std::string ppFilter;
// Gui // Gui
static bool load_game_size = true; static bool load_game_size = true;
@ -232,6 +233,10 @@ u32 vblankDiv() {
return vblankDivider; return vblankDivider;
} }
std::string getPostProcessingFilter() {
return ppFilter;
}
bool vkValidationEnabled() { bool vkValidationEnabled() {
return vkValidation; return vkValidation;
} }
@ -633,6 +638,7 @@ void load(const std::filesystem::path& path) {
screenWidth = toml::find_or<int>(gpu, "screenWidth", screenWidth); screenWidth = toml::find_or<int>(gpu, "screenWidth", screenWidth);
screenHeight = toml::find_or<int>(gpu, "screenHeight", screenHeight); 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); isNullGpu = toml::find_or<bool>(gpu, "nullGpu", false);
shouldCopyGPUBuffers = toml::find_or<bool>(gpu, "copyGPUBuffers", false); shouldCopyGPUBuffers = toml::find_or<bool>(gpu, "copyGPUBuffers", false);
shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false); shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false);
@ -747,6 +753,7 @@ void save(const std::filesystem::path& path) {
data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled; data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled;
data["GPU"]["screenWidth"] = screenWidth; data["GPU"]["screenWidth"] = screenWidth;
data["GPU"]["screenHeight"] = screenHeight; data["GPU"]["screenHeight"] = screenHeight;
data["GPU"]["ppFilter"] = ppFilter;
data["GPU"]["nullGpu"] = isNullGpu; data["GPU"]["nullGpu"] = isNullGpu;
data["GPU"]["copyGPUBuffers"] = shouldCopyGPUBuffers; data["GPU"]["copyGPUBuffers"] = shouldCopyGPUBuffers;
data["GPU"]["dumpShaders"] = shouldDumpShaders; data["GPU"]["dumpShaders"] = shouldDumpShaders;

View File

@ -44,6 +44,7 @@ bool getIsMotionControlsEnabled();
u32 getScreenWidth(); u32 getScreenWidth();
u32 getScreenHeight(); u32 getScreenHeight();
std::string getPostProcessingFilter();
s32 getGpuId(); s32 getGpuId();
bool debugDump(); bool debugDump();

View File

@ -278,9 +278,19 @@ void Presenter::CreatePostProcessPipeline() {
instance.GetDevice().destroyShaderModule(fs_module); instance.GetDevice().destroyShaderModule(fs_module);
// Create sampler resource // 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 = { const vk::SamplerCreateInfo sampler_ci = {
.magFilter = vk::Filter::eLinear, .magFilter = pp_filter,
.minFilter = vk::Filter::eLinear, .minFilter = pp_filter,
.mipmapMode = vk::SamplerMipmapMode::eNearest, .mipmapMode = vk::SamplerMipmapMode::eNearest,
.addressModeU = vk::SamplerAddressMode::eClampToEdge, .addressModeU = vk::SamplerAddressMode::eClampToEdge,
.addressModeV = vk::SamplerAddressMode::eClampToEdge, .addressModeV = vk::SamplerAddressMode::eClampToEdge,