Devtools IV (#1910)

* devtools: fix popen in non-windows environment

* devtools: fix frame crash assertion when hidden

* devtools: add search to shader list

* devtools: add copy name to shader list

* devtools: frame dump: search by shader name
This commit is contained in:
Vinicius Rangel 2024-12-26 18:08:47 -03:00 committed by GitHub
parent 0bb1c05aff
commit edc027a8bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 159 additions and 55 deletions

View file

@ -497,7 +497,7 @@ vk::ShaderModule PipelineCache::CompileModule(Shader::Info& info, Shader::Runtim
module = CompileSPV(spv, instance.GetDevice());
}
const auto name = fmt::format("{}_{:#018x}_{}", info.stage, info.pgm_hash, perm_idx);
const auto name = GetShaderName(info.stage, info.pgm_hash, perm_idx);
Vulkan::SetObjectName(instance.GetDevice(), module, name);
if (Config::collectShadersForDebug()) {
DebugState.CollectShader(name, info.l_stage, module, spv, code,
@ -572,6 +572,14 @@ std::optional<vk::ShaderModule> PipelineCache::ReplaceShader(vk::ShaderModule mo
return new_module;
}
std::string PipelineCache::GetShaderName(Shader::Stage stage, u64 hash,
std::optional<size_t> perm) {
if (perm) {
return fmt::format("{}_{:#018x}_{}", stage, hash, *perm);
}
return fmt::format("{}_{:#018x}", stage, hash);
}
void PipelineCache::DumpShader(std::span<const u32> code, u64 hash, Shader::Stage stage,
size_t perm_idx, std::string_view ext) {
if (!Config::dumpShaders()) {
@ -583,7 +591,7 @@ void PipelineCache::DumpShader(std::span<const u32> code, u64 hash, Shader::Stag
if (!std::filesystem::exists(dump_dir)) {
std::filesystem::create_directories(dump_dir);
}
const auto filename = fmt::format("{}_{:#018x}_{}.{}", stage, hash, perm_idx, ext);
const auto filename = fmt::format("{}.{}", GetShaderName(stage, hash, perm_idx), ext);
const auto file = IOFile{dump_dir / filename, FileAccessMode::Write};
file.WriteSpan(code);
}
@ -597,7 +605,7 @@ std::optional<std::vector<u32>> PipelineCache::GetShaderPatch(u64 hash, Shader::
if (!std::filesystem::exists(patch_dir)) {
std::filesystem::create_directories(patch_dir);
}
const auto filename = fmt::format("{}_{:#018x}_{}.{}", stage, hash, perm_idx, ext);
const auto filename = fmt::format("{}.{}", GetShaderName(stage, hash, perm_idx), ext);
const auto filepath = patch_dir / filename;
if (!std::filesystem::exists(filepath)) {
return {};

View file

@ -65,6 +65,9 @@ public:
std::optional<vk::ShaderModule> ReplaceShader(vk::ShaderModule module,
std::span<const u32> spv_code);
static std::string GetShaderName(Shader::Stage stage, u64 hash,
std::optional<size_t> perm = {});
private:
bool RefreshGraphicsKey();
bool RefreshComputeKey();