From 69d4fecdfe70c8b9a5b27cd9d62753d6b6f57b36 Mon Sep 17 00:00:00 2001 From: jnack <55568980+jnackmclain@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:51:20 -0500 Subject: [PATCH] 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 --- .../renderer_vulkan/vk_pipeline_cache.cpp | 29 ++++++++++++++++--- .../renderer_vulkan/vk_pipeline_cache.h | 4 +-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 7e880657..f8de5ffe 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -38,7 +38,9 @@ const GraphicsPipeline* PipelineCache::GetGraphicsPipeline() { LOG_TRACE(Render_Vulkan, "FMask decompression pass skipped"); return nullptr; } - RefreshGraphicsKey(); + if (!RefreshGraphicsKey()) { + return nullptr; + } const auto [it, is_new] = graphics_pipelines.try_emplace(graphics_key); if (is_new) { it.value() = std::make_unique(instance, scheduler, graphics_key, @@ -49,7 +51,9 @@ const GraphicsPipeline* PipelineCache::GetGraphicsPipeline() { } const ComputePipeline* PipelineCache::GetComputePipeline() { - RefreshComputeKey(); + if (!RefreshComputeKey()) { + return nullptr; + } const auto [it, is_new] = compute_pipelines.try_emplace(compute_key); if (is_new) { it.value() = std::make_unique(instance, scheduler, *pipeline_cache, @@ -59,7 +63,16 @@ const ComputePipeline* PipelineCache::GetComputePipeline() { return pipeline; } -void PipelineCache::RefreshGraphicsKey() { +bool ShouldSkipShader(u64 shader_hash, const char* shader_type) { + static constexpr std::array 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& key = graphics_key; @@ -160,18 +173,26 @@ void PipelineCache::RefreshGraphicsKey() { infos[i] = nullptr; continue; } + if (ShouldSkipShader(bininfo->shader_hash, "graphics")) { + return false; + } const auto stage = Shader::Stage{i}; const GuestProgram guest_pgm{pgm, stage}; std::tie(infos[i], modules[i], key.stage_hashes[i]) = shader_cache->GetProgram(guest_pgm, binding); } + return true; } -void PipelineCache::RefreshComputeKey() { +bool PipelineCache::RefreshComputeKey() { u32 binding{}; const auto* cs_pgm = &liverpool->regs.cs_program; 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); + return true; } } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index d0eb0c66..40853b74 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h @@ -30,8 +30,8 @@ public: const ComputePipeline* GetComputePipeline(); private: - void RefreshGraphicsKey(); - void RefreshComputeKey(); + bool RefreshGraphicsKey(); + bool RefreshComputeKey(); private: const Instance& instance;