From f3ba8fb334613f98e6264b648f260dfd8957c685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 3 Dec 2022 19:30:50 +0100 Subject: [PATCH] Address feedback, also sort texture shaders --- Common/File/Path.h | 3 +++ GPU/Common/PostShader.cpp | 13 +++++++------ GPU/Common/PostShader.h | 22 +++++++++++++++++----- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Common/File/Path.h b/Common/File/Path.h index ab49fb10cf..aded7b5bde 100644 --- a/Common/File/Path.h +++ b/Common/File/Path.h @@ -118,6 +118,9 @@ public: bool operator <(const Path &other) const { return path_ < other.path_; } + bool operator >(const Path &other) const { + return path_ > other.path_; + } private: // The internal representation is currently always the plain string. diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index 0c525f766e..c282d541c1 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -51,12 +51,6 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct shaderInfo.clear(); - textureShaderInfo.clear(); - TextureShaderInfo textureOff{}; - textureOff.name = "Off"; - textureOff.section = "Off"; - textureShaderInfo.push_back(textureOff); - auto appendShader = [&](const ShaderInfo &info) { auto beginErase = std::remove(shaderInfo.begin(), shaderInfo.end(), info.name); if (beginErase != shaderInfo.end()) { @@ -221,6 +215,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct // Sort shaders alphabetically. std::sort(shaderInfo.begin(), shaderInfo.end()); + std::sort(textureShaderInfo.begin(), textureShaderInfo.end()); ShaderInfo off{}; off.visible = true; @@ -235,6 +230,12 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct } shaderInfo.insert(shaderInfo.begin(), off); + textureShaderInfo.clear(); + TextureShaderInfo textureOff{}; + textureOff.name = "Off"; + textureOff.section = "Off"; + textureShaderInfo.push_back(textureOff); + // We always want the not visible ones at the end. Makes menus easier. for (const auto &info : notVisible) { appendShader(info); diff --git a/GPU/Common/PostShader.h b/GPU/Common/PostShader.h index befa5847ce..ef4e2c83b5 100644 --- a/GPU/Common/PostShader.h +++ b/GPU/Common/PostShader.h @@ -60,16 +60,19 @@ struct ShaderInfo { // TODO: Add support for all kinds of fun options like mapping the depth buffer, // SRGB texture reads, etc. prev shader? - bool operator == (const std::string &other) { + bool operator == (const std::string &other) const { return name == other; } - bool operator == (const ShaderInfo &other) { + bool operator == (const ShaderInfo &other) const { return name == other.name; } - bool operator < (const ShaderInfo &other) { + bool operator < (const ShaderInfo &other) const { if (name < other.name) return true; if (name > other.name) return false; + // Tie breaker + if (iniFile < other.iniFile) return true; + if (iniFile > other.iniFile) return false; return false; } }; @@ -84,12 +87,21 @@ struct TextureShaderInfo { // Upscaling shaders have a fixed scale factor. int scaleFactor; - bool operator == (const std::string &other) { + bool operator == (const std::string &other) const { return name == other; } - bool operator == (const TextureShaderInfo &other) { + bool operator == (const TextureShaderInfo &other) const { return name == other.name; } + + bool operator < (const TextureShaderInfo &other) const { + if (name < other.name) return true; + if (name > other.name) return false; + // Tie breaker + if (iniFile < other.iniFile) return true; + if (iniFile > other.iniFile) return false; + return false; + } }; void ReloadAllPostShaderInfo(Draw::DrawContext *draw);