diff --git a/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp b/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp index 626f9cd6b..b62ee64a7 100644 --- a/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp +++ b/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp @@ -43,6 +43,7 @@ bool g_memory = false; bool g_spirv = false; bool g_graph = false; bool g_maintenance8 = false; +bool g_code = false; bool Replay(const char* path) { auto request = ShaderRecompiler::RequestSerializer{}.Deserialize(ReadText(path)); @@ -75,6 +76,18 @@ bool Replay(const char* path) { std::printf(" region 0x%llx + 0x%zx -> %s\n", static_cast(region.guestAddress), region.bytes.size(), name); } } + if (g_code) { + std::string name(path); + name = name.substr(name.find_last_of("/\\") + 1) + ".code"; + const auto& code = request.request.shader.code; + std::ofstream file(name, std::ios::binary); + file.write(reinterpret_cast(code.data()), static_cast(code.size() * sizeof(code[0]))); + if (!file) { + std::printf(" could not write %s\n", name.c_str()); + return false; + } + std::printf(" code -> %s\n", name.c_str()); + } if (g_assembly) { const auto program = ShaderRecompiler::RdnaInstructionDecoder{}.Decode(request.request.shader.code); // Raw first words carry what the text omits (branch offsets, waitcnt fields). @@ -139,7 +152,7 @@ bool Replay(const char* path) { int main(int argc, char** argv) { if (argc < 2) { - std::fprintf(stderr, "usage: agc_shader_replay [--dis] [--asm] [--cfg] [--mem] [--spv] [--maintenance8] ...\n the driver writes shader_
.req files when APS5_DUMP_SHADERS is set\n"); + std::fprintf(stderr, "usage: agc_shader_replay [--dis] [--asm] [--cfg] [--mem] [--spv] [--code] [--maintenance8] ...\n the driver writes shader_
.req files when APS5_DUMP_SHADERS is set\n"); return 2; } int failures = 0; @@ -164,6 +177,10 @@ int main(int argc, char** argv) { g_memory = true; continue; } + if (std::string(argv[i]) == "--code") { + g_code = true; + continue; + } if (std::string(argv[i]) == "--spv") { g_spirv = true; continue;