Read binary file into vector.
735{
736 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
737 if (!file.is_open()) {
739 "Failed to open SPIR-V file: '{}'", filepath);
740 return {};
741 }
742
743 size_t file_size = static_cast<size_t>(file.tellg());
744 if (file_size == 0) {
746 "SPIR-V file is empty: '{}'", filepath);
747 return {};
748 }
749
750 if (file_size % sizeof(uint32_t) != 0) {
752 "SPIR-V file size ({} bytes) is not multiple of 4: '{}'",
753 file_size, filepath);
754 return {};
755 }
756
757 std::vector<uint32_t> buffer(file_size / sizeof(uint32_t));
758 file.seekg(0);
759 file.read(reinterpret_cast<char*>(buffer.data()), file_size);
760
761 if (!file) {
763 "Failed to read SPIR-V file: '{}'", filepath);
764 return {};
765 }
766
767 return buffer;
768}
#define MF_ERROR(comp, ctx,...)
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.