Module: Mesa Branch: master Commit: 8016a098fcd494281522f48d69d99808d13773a1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8016a098fcd494281522f48d69d99808d13773a1
Author: Michael Tang <[email protected]> Date: Thu Mar 11 10:27:11 2021 -0800 microsoft/spirv_to_dxil: Fix spirv2dxil I/O to use binary mode Reviewed-by: Jesse Natalie <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9513> --- src/microsoft/spirv_to_dxil/spirv2dxil.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/microsoft/spirv_to_dxil/spirv2dxil.c b/src/microsoft/spirv_to_dxil/spirv2dxil.c index 47be6d49d0b..6d89d3ace70 100644 --- a/src/microsoft/spirv_to_dxil/spirv2dxil.c +++ b/src/microsoft/spirv_to_dxil/spirv2dxil.c @@ -113,14 +113,20 @@ main(int argc, char **argv) return 1; } + if (file_size % WORD_SIZE != 0) { + fprintf(stderr, "%s size == %zu is not a multiple of %d\n", filename, + file_size, WORD_SIZE); + return 1; + } + size_t word_count = file_size / WORD_SIZE; void *data; size_t size; - if (spirv_to_dxil((void *)file_contents, word_count, NULL, 0, + if (spirv_to_dxil((uint32_t *)file_contents, word_count, NULL, 0, (dxil_spirv_shader_stage)shader_stage, entry_point, &data, &size)) { - FILE *file = fopen(output_file, "w"); + FILE *file = fopen(output_file, "wb"); if (!file) { fprintf(stderr, "Failed to open %s, %s\n", output_file, strerror(errno)); @@ -129,7 +135,7 @@ main(int argc, char **argv) return 1; } - fwrite(data, 1, size, file); + fwrite(data, sizeof(char), size, file); fclose(file); spirv_to_dxil_free(data); } else { _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
