devtools: shader editing load patch even with config disabled

This commit is contained in:
Vinicius Rangel 2024-12-08 15:46:59 -03:00
parent aa72143be7
commit 3c0ea18556
No known key found for this signature in database
GPG Key ID: A5B154D904B761D9
4 changed files with 15 additions and 13 deletions

View File

@ -179,8 +179,8 @@ void DebugStateImpl::PushRegsDump(uintptr_t base_addr, uintptr_t header_addr,
void DebugStateImpl::CollectShader(const std::string& name, vk::ShaderModule module,
std::span<const u32> spv, std::span<const u32> raw_code,
std::span<const u32> patch_spv) {
std::span<const u32> patch_spv, bool is_patched) {
shader_dump_list.emplace_back(name, module, std::vector<u32>{spv.begin(), spv.end()},
std::vector<u32>{raw_code.begin(), raw_code.end()},
std::vector<u32>{patch_spv.begin(), patch_spv.end()});
std::vector<u32>{patch_spv.begin(), patch_spv.end()}, is_patched);
}

View File

@ -91,9 +91,9 @@ struct ShaderDump {
std::string cache_patch_disasm{};
ShaderDump(std::string name, vk::ShaderModule module, std::vector<u32> spv,
std::vector<u32> isa, std::vector<u32> patch_spv)
std::vector<u32> isa, std::vector<u32> patch_spv, bool is_patched)
: name(std::move(name)), module(module), spv(std::move(spv)), isa(std::move(isa)),
patch_spv(std::move(patch_spv)) {}
patch_spv(std::move(patch_spv)), is_patched(is_patched) {}
ShaderDump(const ShaderDump& other) = delete;
ShaderDump(ShaderDump&& other) noexcept
@ -204,7 +204,8 @@ public:
const AmdGpu::Liverpool::Regs& regs, bool is_compute = false);
void CollectShader(const std::string& name, vk::ShaderModule module, std::span<const u32> spv,
std::span<const u32> raw_code, std::span<const u32> patch_spv);
std::span<const u32> raw_code, std::span<const u32> patch_spv,
bool is_patched);
};
} // namespace DebugStateType

View File

@ -232,10 +232,12 @@ void ShaderList::Draw() {
int i = 0;
for (const auto& shader : DebugState.shader_dump_list) {
char name[128];
if (shader.patch_spv.empty()) {
snprintf(name, sizeof(name), "%s", shader.name.c_str());
if (shader.is_patched) {
snprintf(name, sizeof(name), "%s (PATCH ON)", shader.name.c_str());
} else if (!shader.patch_spv.empty()) {
snprintf(name, sizeof(name), "%s (PATCH OFF)", shader.name.c_str());
} else {
snprintf(name, sizeof(name), "%s (PATCH)", shader.name.c_str());
snprintf(name, sizeof(name), "%s", shader.name.c_str());
}
if (ButtonEx(name, {width, 20.0f}, ImGuiButtonFlags_NoHoveredOnFocus)) {
open_shaders.emplace_back(i);

View File

@ -434,7 +434,8 @@ vk::ShaderModule PipelineCache::CompileModule(Shader::Info& info,
vk::ShaderModule module;
auto patch = GetShaderPatch(info.pgm_hash, info.stage, perm_idx, "spv");
if (patch) {
const bool is_patched = patch && Config::patchShaders();
if (is_patched) {
LOG_INFO(Loader, "Loaded patch for {} shader {:#x}", info.stage, info.pgm_hash);
module = CompileSPV(*patch, instance.GetDevice());
} else {
@ -444,7 +445,8 @@ vk::ShaderModule PipelineCache::CompileModule(Shader::Info& info,
const auto name = fmt::format("{}_{:#018x}_{}", info.stage, info.pgm_hash, perm_idx);
Vulkan::SetObjectName(instance.GetDevice(), module, name);
if (Config::collectShadersForDebug()) {
DebugState.CollectShader(name, module, spv, code, patch ? *patch : std::span<const u32>{});
DebugState.CollectShader(name, module, spv, code, patch ? *patch : std::span<const u32>{},
is_patched);
}
return module;
}
@ -533,9 +535,6 @@ void PipelineCache::DumpShader(std::span<const u32> code, u64 hash, Shader::Stag
std::optional<std::vector<u32>> PipelineCache::GetShaderPatch(u64 hash, Shader::Stage stage,
size_t perm_idx,
std::string_view ext) {
if (!Config::patchShaders()) {
return {};
}
using namespace Common::FS;
const auto patch_dir = GetUserPath(PathType::ShaderDir) / "patch";