Read binary file into vector.
559{
560 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
561 if (!file.is_open()) {
563 "Failed to open SPIR-V file: '{}'", filepath);
564 return {};
565 }
566
567 size_t file_size = static_cast<size_t>(file.tellg());
568 if (file_size == 0) {
570 "SPIR-V file is empty: '{}'", filepath);
571 return {};
572 }
573
574 if (file_size % sizeof(uint32_t) != 0) {
576 "SPIR-V file size ({} bytes) is not multiple of 4: '{}'",
577 file_size, filepath);
578 return {};
579 }
580
581 std::vector<uint32_t> buffer(file_size / sizeof(uint32_t));
582 file.seekg(0);
583 file.read(reinterpret_cast<char*>(buffer.data()), file_size);
584
585 if (!file) {
587 "Failed to read SPIR-V file: '{}'", filepath);
588 return {};
589 }
590
591 return buffer;
592}
#define MF_ERROR(comp, ctx,...)
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.