vk_pipeline_cache: Fix invalid iterator

This commit is contained in:
IndecisiveTurtle 2024-08-27 22:25:08 +03:00
parent 97770e258d
commit d36292873b
2 changed files with 5 additions and 4 deletions

View File

@ -92,8 +92,7 @@ struct BufferResource {
u64 GetKey(const Info& info) const { u64 GetKey(const Info& info) const {
const auto sharp = GetVsharp(info); const auto sharp = GetVsharp(info);
const u32 stride = sharp.GetStride(); u64 key = sharp.GetStride();
u64 key = stride | (sharp.data_format << 14) | (sharp.num_format << 18);
if (!is_written) { if (!is_written) {
key <<= 1; key <<= 1;
key |= IsStorage(sharp); key |= IsStorage(sharp);

View File

@ -73,6 +73,7 @@ private:
Program* program = it_pgm->second; Program* program = it_pgm->second;
const auto& info = program->info; const auto& info = program->info;
vk::ShaderModule module{};
// Compile specialized module with current runtime state. // Compile specialized module with current runtime state.
const auto it = std::ranges::find(program->modules, stage_key, &Program::Module::first); 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, auto new_info = MakeShaderInfo(stage, pgm->user_data, info.pgm_base, info.pgm_hash,
liverpool->regs); liverpool->regs);
const size_t perm_idx = program->modules.size(); 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); program->modules.emplace_back(stage_key, module);
} else { } else {
binding += info.NumBindings(); binding += info.NumBindings();
module = it->second;
} }
const u64 full_hash = HashCombine(hash, stage_key); 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: private: