Dump shaders in binary mode

Use binary mode when writing shaders to file, so that 0x0a is not
considered a LF and then converted to CRLF.
This commit is contained in:
sephiroth99 2016-06-21 23:05:19 -04:00
parent e95a08fc87
commit 7bf2f23bef
1 changed files with 2 additions and 2 deletions

View File

@ -54,7 +54,7 @@ std::pair<std::string, std::string> Shader::Dump(const std::string& base_path,
"%s/shader_%s_%.16" PRIX64 ".%s", base_path.c_str(), "%s/shader_%s_%.16" PRIX64 ".%s", base_path.c_str(),
path_prefix, ucode_data_hash_, path_prefix, ucode_data_hash_,
shader_type_ == ShaderType::kVertex ? "vert" : "frag"); shader_type_ == ShaderType::kVertex ? "vert" : "frag");
FILE* f = fopen(txt_file_name, "w"); FILE* f = fopen(txt_file_name, "wb");
if (f) { if (f) {
fwrite(translated_binary_.data(), 1, translated_binary_.size(), f); fwrite(translated_binary_.data(), 1, translated_binary_.size(), f);
fprintf(f, "\n\n"); fprintf(f, "\n\n");
@ -77,7 +77,7 @@ std::pair<std::string, std::string> Shader::Dump(const std::string& base_path,
"%s/shader_%s_%.16" PRIX64 ".bin.%s", base_path.c_str(), "%s/shader_%s_%.16" PRIX64 ".bin.%s", base_path.c_str(),
path_prefix, ucode_data_hash_, path_prefix, ucode_data_hash_,
shader_type_ == ShaderType::kVertex ? "vert" : "frag"); shader_type_ == ShaderType::kVertex ? "vert" : "frag");
f = fopen(bin_file_name, "w"); f = fopen(bin_file_name, "wb");
if (f) { if (f) {
fwrite(ucode_data_.data(), 4, ucode_data_.size(), f); fwrite(ucode_data_.data(), 4, ucode_data_.size(), f);
fclose(f); fclose(f);