Allow graphics/compute shader list for skipping (#674)

* Allow graphics/compute shader list for skipping

* nintendo ultra 64 + formatting

* indentation..

* allow empty array in ShouldSkipShader

* simpler check for skip hashes
This commit is contained in:
jnack 2024-08-30 13:51:20 -05:00 committed by GitHub
parent 6080066f75
commit 69d4fecdfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 6 deletions

View File

@ -38,7 +38,9 @@ const GraphicsPipeline* PipelineCache::GetGraphicsPipeline() {
LOG_TRACE(Render_Vulkan, "FMask decompression pass skipped"); LOG_TRACE(Render_Vulkan, "FMask decompression pass skipped");
return nullptr; return nullptr;
} }
RefreshGraphicsKey(); if (!RefreshGraphicsKey()) {
return nullptr;
}
const auto [it, is_new] = graphics_pipelines.try_emplace(graphics_key); const auto [it, is_new] = graphics_pipelines.try_emplace(graphics_key);
if (is_new) { if (is_new) {
it.value() = std::make_unique<GraphicsPipeline>(instance, scheduler, graphics_key, it.value() = std::make_unique<GraphicsPipeline>(instance, scheduler, graphics_key,
@ -49,7 +51,9 @@ const GraphicsPipeline* PipelineCache::GetGraphicsPipeline() {
} }
const ComputePipeline* PipelineCache::GetComputePipeline() { const ComputePipeline* PipelineCache::GetComputePipeline() {
RefreshComputeKey(); if (!RefreshComputeKey()) {
return nullptr;
}
const auto [it, is_new] = compute_pipelines.try_emplace(compute_key); const auto [it, is_new] = compute_pipelines.try_emplace(compute_key);
if (is_new) { if (is_new) {
it.value() = std::make_unique<ComputePipeline>(instance, scheduler, *pipeline_cache, it.value() = std::make_unique<ComputePipeline>(instance, scheduler, *pipeline_cache,
@ -59,7 +63,16 @@ const ComputePipeline* PipelineCache::GetComputePipeline() {
return pipeline; return pipeline;
} }
void PipelineCache::RefreshGraphicsKey() { bool ShouldSkipShader(u64 shader_hash, const char* shader_type) {
static constexpr std::array<u64, 0> skip_hashes = {};
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() {
auto& regs = liverpool->regs; auto& regs = liverpool->regs;
auto& key = graphics_key; auto& key = graphics_key;
@ -160,18 +173,26 @@ void PipelineCache::RefreshGraphicsKey() {
infos[i] = nullptr; infos[i] = nullptr;
continue; continue;
} }
if (ShouldSkipShader(bininfo->shader_hash, "graphics")) {
return false;
}
const auto stage = Shader::Stage{i}; const auto stage = Shader::Stage{i};
const GuestProgram guest_pgm{pgm, stage}; const GuestProgram guest_pgm{pgm, stage};
std::tie(infos[i], modules[i], key.stage_hashes[i]) = std::tie(infos[i], modules[i], key.stage_hashes[i]) =
shader_cache->GetProgram(guest_pgm, binding); shader_cache->GetProgram(guest_pgm, binding);
} }
return true;
} }
void PipelineCache::RefreshComputeKey() { bool PipelineCache::RefreshComputeKey() {
u32 binding{}; u32 binding{};
const auto* cs_pgm = &liverpool->regs.cs_program; const auto* cs_pgm = &liverpool->regs.cs_program;
const GuestProgram guest_pgm{cs_pgm, Shader::Stage::Compute}; const GuestProgram guest_pgm{cs_pgm, Shader::Stage::Compute};
if (ShouldSkipShader(guest_pgm.hash, "compute")) {
return false;
}
std::tie(infos[0], modules[0], compute_key) = shader_cache->GetProgram(guest_pgm, binding); std::tie(infos[0], modules[0], compute_key) = shader_cache->GetProgram(guest_pgm, binding);
return true;
} }
} // namespace Vulkan } // namespace Vulkan

View File

@ -30,8 +30,8 @@ public:
const ComputePipeline* GetComputePipeline(); const ComputePipeline* GetComputePipeline();
private: private:
void RefreshGraphicsKey(); bool RefreshGraphicsKey();
void RefreshComputeKey(); bool RefreshComputeKey();
private: private:
const Instance& instance; const Instance& instance;