MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ read_spirv_file()

std::vector< uint32_t > MayaFlux::Core::VKShaderModule::read_spirv_file ( const std::string &  filepath)
staticprivate

Read binary file into vector.

Parameters
filepathPath to file
Returns
File contents, or empty vector on failure

Definition at line 782 of file VKShaderModule.cpp.

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.

References MayaFlux::Journal::Core, MayaFlux::Journal::GraphicsBackend, and MF_ERROR.

Referenced by create_from_spirv_file().

+ Here is the caller graph for this function: