Add a crude way to blacklist post/texture shaders from certain vendors.

Use it to work around #14530 for now.
This commit is contained in:
Henrik Rydgård 2021-09-28 23:35:57 +02:00
parent cc43ce0404
commit 992ad801e7
9 changed files with 67 additions and 13 deletions

View file

@ -28,6 +28,7 @@
#include "Common/File/DirListing.h"
#include "Common/File/VFS/VFS.h"
#include "Common/GPU/OpenGL/GLFeatures.h"
#include "Common/GPU/thin3d.h"
#include "Common/StringUtils.h"
#include "Core/Config.h"
@ -40,9 +41,14 @@ static std::vector<TextureShaderInfo> textureShaderInfo;
// Scans the directories for shader ini files and collects info about all the shaders found.
void LoadPostShaderInfo(const std::vector<Path> &directories) {
void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &directories) {
std::vector<ShaderInfo> notVisible;
Draw::GPUVendor gpuVendor = Draw::GPUVendor::VENDOR_UNKNOWN;
if (draw) {
gpuVendor = draw->GetDeviceCaps().vendor;
}
shaderInfo.clear();
ShaderInfo off{};
off.visible = true;
@ -112,11 +118,45 @@ void LoadPostShaderInfo(const std::vector<Path> &directories) {
std::string shaderType;
section.Get("Type", &shaderType, "render");
std::vector<std::string> vendorBlacklist;
section.Get("VendorBlacklist", vendorBlacklist);
bool skipped = false;
for (auto &item : vendorBlacklist) {
Draw::GPUVendor blacklistedVendor = Draw::GPUVendor::VENDOR_UNKNOWN;
// TODO: This should probably be a function somewhere.
if (item == "ARM") {
blacklistedVendor = Draw::GPUVendor::VENDOR_ARM;
} else if (item == "Qualcomm") {
blacklistedVendor = Draw::GPUVendor::VENDOR_QUALCOMM;
} else if (item == "IMGTEC") {
blacklistedVendor = Draw::GPUVendor::VENDOR_IMGTEC;
} else if (item == "NVIDIA") {
blacklistedVendor = Draw::GPUVendor::VENDOR_NVIDIA;
} else if (item == "AMD") {
blacklistedVendor = Draw::GPUVendor::VENDOR_AMD;
} else if (item == "Broadcom") {
blacklistedVendor = Draw::GPUVendor::VENDOR_BROADCOM;
} else if (item == "Apple") {
blacklistedVendor = Draw::GPUVendor::VENDOR_APPLE;
} else if (item == "Intel") {
blacklistedVendor = Draw::GPUVendor::VENDOR_INTEL;
}
if (blacklistedVendor == gpuVendor && blacklistedVendor != Draw::GPUVendor::VENDOR_UNKNOWN) {
skipped = true;
break;
}
}
if (skipped) {
continue;
}
if (section.Exists("Fragment") && section.Exists("Vertex") && strncasecmp(shaderType.c_str(), "render", shaderType.size()) == 0) {
// Valid shader!
ShaderInfo info;
std::string temp;
info.section = section.name();
section.Get("Name", &info.name, section.name().c_str());
section.Get("Parent", &info.parent, "");
section.Get("Visible", &info.visible, true);
@ -184,11 +224,11 @@ void LoadPostShaderInfo(const std::vector<Path> &directories) {
}
// Scans the directories for shader ini files and collects info about all the shaders found.
void ReloadAllPostShaderInfo() {
void ReloadAllPostShaderInfo(Draw::DrawContext *draw) {
std::vector<Path> directories;
directories.push_back(Path("shaders")); // For VFS
directories.push_back(GetSysDirectory(DIRECTORY_CUSTOM_SHADERS));
LoadPostShaderInfo(directories);
LoadPostShaderInfo(draw, directories);
}
const ShaderInfo *GetPostShaderInfo(const std::string &name) {

View file

@ -82,7 +82,7 @@ struct TextureShaderInfo {
}
};
void ReloadAllPostShaderInfo();
void ReloadAllPostShaderInfo(Draw::DrawContext *draw);
const ShaderInfo *GetPostShaderInfo(const std::string &name);
std::vector<const ShaderInfo *> GetPostShaderChain(const std::string &name);

View file

@ -218,7 +218,7 @@ static std::string ReadShaderSrc(const Path &filename) {
bool PresentationCommon::UpdatePostShader() {
std::vector<const ShaderInfo *> shaderInfo;
if (!g_Config.vPostShaderNames.empty()) {
ReloadAllPostShaderInfo();
ReloadAllPostShaderInfo(draw_);
shaderInfo = GetFullPostShadersChain(g_Config.vPostShaderNames);
}
@ -810,7 +810,7 @@ void PresentationCommon::CalculateRenderResolution(int *width, int *height, int
// Check if postprocessing shader is doing upscaling as it requires native resolution
std::vector<const ShaderInfo *> shaderInfo;
if (!g_Config.vPostShaderNames.empty()) {
ReloadAllPostShaderInfo();
ReloadAllPostShaderInfo(draw_);
shaderInfo = GetFullPostShadersChain(g_Config.vPostShaderNames);
}

View file

@ -393,7 +393,7 @@ void TextureCacheVulkan::CompileScalingShader() {
if (!g_Config.bTexHardwareScaling)
return;
ReloadAllPostShaderInfo();
ReloadAllPostShaderInfo(draw_);
const TextureShaderInfo *shaderInfo = GetTextureShaderInfo(g_Config.sTextureShaderName);
if (!shaderInfo || shaderInfo->computeShaderFile.empty())
return;

View file

@ -190,7 +190,7 @@ bool PathToVisualUsbPath(Path path, std::string &outPath) {
}
void GameSettingsScreen::CreateViews() {
ReloadAllPostShaderInfo();
ReloadAllPostShaderInfo(screenManager()->getDrawContext());
if (editThenRestore_) {
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, gamePath_, 0);

View file

@ -520,9 +520,11 @@ void PromptScreen::TriggerFinish(DialogResult result) {
UIDialogScreenWithBackground::TriggerFinish(result);
}
PostProcScreen::PostProcScreen(const std::string &title, int id) : ListPopupScreen(title), id_(id) {
PostProcScreen::PostProcScreen(const std::string &title, int id) : ListPopupScreen(title), id_(id) { }
void PostProcScreen::CreateViews() {
auto ps = GetI18NCategory("PostShaders");
ReloadAllPostShaderInfo();
ReloadAllPostShaderInfo(screenManager()->getDrawContext());
shaders_ = GetAllPostShaderInfo();
std::vector<std::string> items;
int selected = -1;
@ -535,6 +537,7 @@ PostProcScreen::PostProcScreen(const std::string &title, int id) : ListPopupScre
items.push_back(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str()));
}
adaptor_ = UI::StringVectorListAdaptor(items, selected);
ListPopupScreen::CreateViews();
}
void PostProcScreen::OnCompleted(DialogResult result) {
@ -547,9 +550,11 @@ void PostProcScreen::OnCompleted(DialogResult result) {
g_Config.vPostShaderNames.push_back(value);
}
TextureShaderScreen::TextureShaderScreen(const std::string &title) : ListPopupScreen(title) {
TextureShaderScreen::TextureShaderScreen(const std::string &title) : ListPopupScreen(title) {}
void TextureShaderScreen::CreateViews() {
auto ps = GetI18NCategory("TextureShaders");
ReloadAllPostShaderInfo();
ReloadAllPostShaderInfo(screenManager()->getDrawContext());
shaders_ = GetAllTextureShaderInfo();
std::vector<std::string> items;
int selected = -1;
@ -559,6 +564,8 @@ TextureShaderScreen::TextureShaderScreen(const std::string &title) : ListPopupSc
items.push_back(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str()));
}
adaptor_ = UI::StringVectorListAdaptor(items, selected);
ListPopupScreen::CreateViews();
}
void TextureShaderScreen::OnCompleted(DialogResult result) {

View file

@ -108,6 +108,8 @@ class PostProcScreen : public ListPopupScreen {
public:
PostProcScreen(const std::string &title, int id);
void CreateViews() override;
private:
void OnCompleted(DialogResult result) override;
bool ShowButtons() const override { return true; }
@ -119,6 +121,8 @@ class TextureShaderScreen : public ListPopupScreen {
public:
TextureShaderScreen(const std::string &title);
void CreateViews() override;
private:
void OnCompleted(DialogResult result) override;
bool ShowButtons() const override { return true; }

View file

@ -175,7 +175,9 @@ namespace MainWindow {
// We only reload this initially and when a menu is actually opened.
if (!menuShaderInfoLoaded) {
ReloadAllPostShaderInfo();
// This is on Windows where we don't currently blacklist any vendors, or similar.
// TODO: Figure out how to have the GPU data while reloading the post shader info.
ReloadAllPostShaderInfo(nullptr);
menuShaderInfoLoaded = true;
}

View file

@ -154,6 +154,7 @@ Type=Texture
Name=4xBRZ
Author=Hyllian
Compute=tex_4xbrz.csh
VendorBlacklist=ARM
[TexMMPX]
Type=Texture
Name=MMPX