Read binary file into vector.
657{
658 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
659 if (!file.is_open()) {
661 "Failed to open SPIR-V file: '{}'", filepath);
662 return {};
663 }
664
665 size_t file_size = static_cast<size_t>(file.tellg());
666 if (file_size == 0) {
668 "SPIR-V file is empty: '{}'", filepath);
669 return {};
670 }
671
672 if (file_size % sizeof(uint32_t) != 0) {
674 "SPIR-V file size ({} bytes) is not multiple of 4: '{}'",
675 file_size, filepath);
676 return {};
677 }
678
679 std::vector<uint32_t> buffer(file_size / sizeof(uint32_t));
680 file.seekg(0);
681 file.read(reinterpret_cast<char*>(buffer.data()), file_size);
682
683 if (!file) {
685 "Failed to read SPIR-V file: '{}'", filepath);
686 return {};
687 }
688
689 return buffer;
690}
#define MF_ERROR(comp, ctx,...)
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.