From d36292873bf9168202cb2eb05571ba11e59569d5 Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:25:08 +0300 Subject: [PATCH] vk_pipeline_cache: Fix invalid iterator --- src/shader_recompiler/runtime_info.h | 3 +-- src/video_core/renderer_vulkan/vk_pipeline_cache.h | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/shader_recompiler/runtime_info.h b/src/shader_recompiler/runtime_info.h index b8f888d2..b185005a 100644 --- a/src/shader_recompiler/runtime_info.h +++ b/src/shader_recompiler/runtime_info.h @@ -92,8 +92,7 @@ struct BufferResource { u64 GetKey(const Info& info) const { const auto sharp = GetVsharp(info); - const u32 stride = sharp.GetStride(); - u64 key = stride | (sharp.data_format << 14) | (sharp.num_format << 18); + u64 key = sharp.GetStride(); if (!is_written) { key <<= 1; key |= IsStorage(sharp); diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index 87e17fad..4d262a50 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h @@ -73,6 +73,7 @@ private: Program* program = it_pgm->second; const auto& info = program->info; + vk::ShaderModule module{}; // Compile specialized module with current runtime state. const auto it = std::ranges::find(program->modules, stage_key, &Program::Module::first); @@ -80,14 +81,15 @@ private: auto new_info = MakeShaderInfo(stage, pgm->user_data, info.pgm_base, info.pgm_hash, liverpool->regs); const size_t perm_idx = program->modules.size(); - const auto module = CompileModule(new_info, pgm->Code(), perm_idx, binding); + module = CompileModule(new_info, pgm->Code(), perm_idx, binding); program->modules.emplace_back(stage_key, module); } else { binding += info.NumBindings(); + module = it->second; } const u64 full_hash = HashCombine(hash, stage_key); - return std::make_tuple(&info, it->second, full_hash); + return std::make_tuple(&info, module, full_hash); } private: