Skip to content

Commit

Permalink
Skip shaders from config
Browse files Browse the repository at this point in the history
  • Loading branch information
Xcedf committed Feb 27, 2025
1 parent 56ae08e commit ffa3170
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static bool separateupdatefolder = false;
static bool compatibilityData = false;
static bool checkCompatibilityOnStartup = false;
static std::string audioBackend = "cubeb";
std::vector<u64> skipedHashes = {};

// Gui
std::vector<std::filesystem::path> settings_install_dirs = {};
Expand Down Expand Up @@ -304,6 +305,10 @@ void setFullscreenMode(bool enable) {
isFullscreen = enable;
}

std::vector<u64> hashesToSkip() {
return skipedHashes;
}

void setisTrophyPopupDisabled(bool disable) {
isTrophyPopupDisabled = disable;
}
Expand Down Expand Up @@ -606,6 +611,7 @@ void load(const std::filesystem::path& path) {
shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false);
shouldPatchShaders = toml::find_or<bool>(gpu, "patchShaders", true);
vblankDivider = toml::find_or<int>(gpu, "vblankDivider", 1);
skipedHashes = toml::find_or<std::vector<u64>>(gpu, "skipShaders", {});
}

if (data.contains("Vulkan")) {
Expand Down Expand Up @@ -717,6 +723,7 @@ void save(const std::filesystem::path& path) {
data["GPU"]["dumpShaders"] = shouldDumpShaders;
data["GPU"]["patchShaders"] = shouldPatchShaders;
data["GPU"]["vblankDivider"] = vblankDivider;
data["GPU"]["skipShaders"] = skipedHashes;
data["Vulkan"]["gpuId"] = gpuId;
data["Vulkan"]["validation"] = vkValidation;
data["Vulkan"]["validation_sync"] = vkValidationSync;
Expand Down
1 change: 1 addition & 0 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool dumpShaders();
bool patchShaders();
bool isRdocEnabled();
u32 vblankDiv();
std::vector<u64> hashesToSkip();

void setDebugDump(bool enable);
void setCollectShaderForDebug(bool enable);
Expand Down
17 changes: 17 additions & 0 deletions src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ const ComputePipeline* PipelineCache::GetComputePipeline() {
return it->second.get();
}

bool ShouldSkipShader(u64 shader_hash, const char* shader_type) {
std::vector<u64> skip_hashes = Config::hashesToSkip();
shader_hash = shader_hash & INT64_MAX;
if (std::ranges::contains(skip_hashes, shader_hash)) {
//LOG_WARNING(Render_Vulkan, "Skipped {} shader hash {:#x}.", shader_type, shader_hash);
return true;
}
return false;
}

bool PipelineCache::RefreshGraphicsKey() {
std::memset(&graphics_key, 0, sizeof(GraphicsPipelineKey));

Expand Down Expand Up @@ -364,6 +374,10 @@ bool PipelineCache::RefreshGraphicsKey() {
return false;
}

if (ShouldSkipShader(bininfo.shader_hash, "graphics")) {
return false;
}

auto params = Liverpool::GetParams(*pgm);
std::optional<Shader::Gcn::FetchShaderData> fetch_shader_;
std::tie(infos[stage_out_idx], modules[stage_out_idx], fetch_shader_,
Expand Down Expand Up @@ -470,6 +484,9 @@ bool PipelineCache::RefreshComputeKey() {
Shader::Backend::Bindings binding{};
const auto& cs_pgm = liverpool->GetCsRegs();
const auto cs_params = Liverpool::GetParams(cs_pgm);
if (ShouldSkipShader(cs_params.hash, "compute")) {
return false;
}
std::tie(infos[0], modules[0], fetch_shader, compute_key.value) =
GetProgram(Shader::Stage::Compute, LogicalStage::Compute, cs_params, binding);
return true;
Expand Down

0 comments on commit ffa3170

Please sign in to comment.