Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -75,6 +76,18 @@ bool Replay(const char* path) {
std::printf(" region 0x%llx + 0x%zx -> %s\n", static_cast<unsigned long long>(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<const char*>(code.data()), static_cast<std::streamsize>(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).
Expand Down Expand Up @@ -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] <shader.req>...\n the driver writes shader_<address>.req files when APS5_DUMP_SHADERS is set\n");
std::fprintf(stderr, "usage: agc_shader_replay [--dis] [--asm] [--cfg] [--mem] [--spv] [--code] [--maintenance8] <shader.req>...\n the driver writes shader_<address>.req files when APS5_DUMP_SHADERS is set\n");
return 2;
}
int failures = 0;
Expand All @@ -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;
Expand Down
Loading