Skip to content

Commit

Permalink
Skip shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Xcedf committed Feb 26, 2025
1 parent 232ff1a commit 2994cd1
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 @@ -70,6 +70,7 @@ static bool separateupdatefolder = false;
static bool compatibilityData = false;
static bool checkCompatibilityOnStartup = false;
static std::string trophyKey;
std::vector<u64> skipedHashes = {};

// Gui
std::vector<std::filesystem::path> settings_install_dirs = {};
Expand Down Expand Up @@ -314,6 +315,10 @@ void setVblankDiv(u32 value) {
vblankDivider = value;
}

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

void setIsFullscreen(bool enable) {
isFullscreen = enable;
}
Expand Down Expand Up @@ -626,6 +631,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 @@ -738,6 +744,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 @@ -54,6 +54,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 @@ -254,6 +254,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 @@ -363,6 +373,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 @@ -469,6 +483,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 2994cd1

Please sign in to comment.