From 6573c87b8d93dd6bfb16bf8af09d90ae1e256570 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Fri, 26 Dec 2014 23:57:47 -0800 Subject: [PATCH] --dump_shaders --- src/xenia/gpu/gl4/gl4_shader.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/xenia/gpu/gl4/gl4_shader.cc b/src/xenia/gpu/gl4/gl4_shader.cc index 251e9f197..d987f4a06 100644 --- a/src/xenia/gpu/gl4/gl4_shader.cc +++ b/src/xenia/gpu/gl4/gl4_shader.cc @@ -9,6 +9,7 @@ #include +#include #include namespace xe { @@ -146,6 +147,22 @@ bool GL4Shader::CompileProgram(std::string source) { translated_disassembly_ = std::move(source); const char* source_str = translated_disassembly_.c_str(); + // Save to disk, if we asked for it. + if (FLAGS_dump_shaders.size()) { + auto base_path = FLAGS_dump_shaders.c_str(); + char file_name[poly::max_path]; + snprintf(file_name, poly::countof(file_name), "%s/gl4_gen_%.16llX.%s", + base_path, data_hash_, + shader_type_ == ShaderType::kVertex ? "vert" : "frag"); + FILE* f = fopen(file_name, "w"); + fprintf(f, translated_disassembly_.c_str()); + fprintf(f, "\n\n"); + fprintf(f, "/*\n"); + fprintf(f, ucode_disassembly_.c_str()); + fprintf(f, " */\n"); + fclose(f); + } + program_ = glCreateShaderProgramv(shader_type_ == ShaderType::kVertex ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER,