mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 00:42:48 +00:00
devtools: shader editing load patch even with config disabled
This commit is contained in:
parent
aa72143be7
commit
3c0ea18556
@ -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,
|
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> 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()},
|
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>{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);
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,9 @@ struct ShaderDump {
|
|||||||
std::string cache_patch_disasm{};
|
std::string cache_patch_disasm{};
|
||||||
|
|
||||||
ShaderDump(std::string name, vk::ShaderModule module, std::vector<u32> spv,
|
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)),
|
: 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(const ShaderDump& other) = delete;
|
||||||
ShaderDump(ShaderDump&& other) noexcept
|
ShaderDump(ShaderDump&& other) noexcept
|
||||||
@ -204,7 +204,8 @@ public:
|
|||||||
const AmdGpu::Liverpool::Regs& regs, bool is_compute = false);
|
const AmdGpu::Liverpool::Regs& regs, bool is_compute = false);
|
||||||
|
|
||||||
void CollectShader(const std::string& name, vk::ShaderModule module, std::span<const u32> spv,
|
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
|
} // namespace DebugStateType
|
||||||
|
|
||||||
|
@ -232,10 +232,12 @@ void ShaderList::Draw() {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto& shader : DebugState.shader_dump_list) {
|
for (const auto& shader : DebugState.shader_dump_list) {
|
||||||
char name[128];
|
char name[128];
|
||||||
if (shader.patch_spv.empty()) {
|
if (shader.is_patched) {
|
||||||
snprintf(name, sizeof(name), "%s", shader.name.c_str());
|
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 {
|
} 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)) {
|
if (ButtonEx(name, {width, 20.0f}, ImGuiButtonFlags_NoHoveredOnFocus)) {
|
||||||
open_shaders.emplace_back(i);
|
open_shaders.emplace_back(i);
|
||||||
|
@ -434,7 +434,8 @@ vk::ShaderModule PipelineCache::CompileModule(Shader::Info& info,
|
|||||||
vk::ShaderModule module;
|
vk::ShaderModule module;
|
||||||
|
|
||||||
auto patch = GetShaderPatch(info.pgm_hash, info.stage, perm_idx, "spv");
|
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);
|
LOG_INFO(Loader, "Loaded patch for {} shader {:#x}", info.stage, info.pgm_hash);
|
||||||
module = CompileSPV(*patch, instance.GetDevice());
|
module = CompileSPV(*patch, instance.GetDevice());
|
||||||
} else {
|
} 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);
|
const auto name = fmt::format("{}_{:#018x}_{}", info.stage, info.pgm_hash, perm_idx);
|
||||||
Vulkan::SetObjectName(instance.GetDevice(), module, name);
|
Vulkan::SetObjectName(instance.GetDevice(), module, name);
|
||||||
if (Config::collectShadersForDebug()) {
|
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;
|
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,
|
std::optional<std::vector<u32>> PipelineCache::GetShaderPatch(u64 hash, Shader::Stage stage,
|
||||||
size_t perm_idx,
|
size_t perm_idx,
|
||||||
std::string_view ext) {
|
std::string_view ext) {
|
||||||
if (!Config::patchShaders()) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace Common::FS;
|
using namespace Common::FS;
|
||||||
const auto patch_dir = GetUserPath(PathType::ShaderDir) / "patch";
|
const auto patch_dir = GetUserPath(PathType::ShaderDir) / "patch";
|
||||||
|
Loading…
Reference in New Issue
Block a user