Read binary file into vector.
783{
784 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
785 if (!file.is_open()) {
787 "Failed to open SPIR-V file: '{}'", filepath);
788 return {};
789 }
790
791 size_t file_size = static_cast<size_t>(file.tellg());
792 if (file_size == 0) {
794 "SPIR-V file is empty: '{}'", filepath);
795 return {};
796 }
797
798 if (file_size % sizeof(uint32_t) != 0) {
800 "SPIR-V file size ({} bytes) is not multiple of 4: '{}'",
801 file_size, filepath);
802 return {};
803 }
804
805 std::vector<uint32_t> buffer(file_size / sizeof(uint32_t));
806 file.seekg(0);
807 file.read(reinterpret_cast<char*>(buffer.data()), file_size);
808
809 if (!file) {
811 "Failed to read SPIR-V file: '{}'", filepath);
812 return {};
813 }
814
815 return buffer;
816}
#define MF_ERROR(comp, ctx,...)
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.