[GPU] Remove MAX_PATH limit from Shader::Dump

This commit is contained in:
Silent 2019-08-31 15:02:38 +02:00 committed by Justin Moore
parent d3a73022fd
commit f392347673
1 changed files with 17 additions and 13 deletions

View File

@ -49,12 +49,21 @@ std::pair<std::string, std::string> Shader::Dump(const std::string& base_path,
xe::filesystem::CreateFolder(target_path);
}
char txt_file_name[kMaxPath];
std::snprintf(txt_file_name, xe::countof(txt_file_name),
"%s/shader_%s_%.16" PRIX64 ".%s", base_path.c_str(),
path_prefix, ucode_data_hash_,
shader_type_ == ShaderType::kVertex ? "vert" : "frag");
FILE* f = fopen(txt_file_name, "wb");
const std::string file_name_no_extension =
xe::format_string("%s/shader_%s_%.16" PRIX64, base_path.c_str(),
path_prefix, ucode_data_hash_);
std::string txt_file_name, bin_file_name;
if (shader_type_ == ShaderType::kVertex) {
txt_file_name = file_name_no_extension + ".vert";
bin_file_name = file_name_no_extension + ".bin.vert";
} else {
txt_file_name = file_name_no_extension + ".frag";
bin_file_name = file_name_no_extension + ".bin.frag";
}
FILE* f = fopen(txt_file_name.c_str(), "wb");
if (f) {
fwrite(translated_binary_.data(), 1, translated_binary_.size(), f);
fprintf(f, "\n\n");
@ -72,18 +81,13 @@ std::pair<std::string, std::string> Shader::Dump(const std::string& base_path,
fclose(f);
}
char bin_file_name[kMaxPath];
std::snprintf(bin_file_name, xe::countof(bin_file_name),
"%s/shader_%s_%.16" PRIX64 ".bin.%s", base_path.c_str(),
path_prefix, ucode_data_hash_,
shader_type_ == ShaderType::kVertex ? "vert" : "frag");
f = fopen(bin_file_name, "wb");
f = fopen(bin_file_name.c_str(), "wb");
if (f) {
fwrite(ucode_data_.data(), 4, ucode_data_.size(), f);
fclose(f);
}
return {std::string(txt_file_name), std::string(bin_file_name)};
return {std::move(txt_file_name), std::move(bin_file_name)};
}
} // namespace gpu