MayaFlux 0.3.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 677 of file VKShaderModule.cpp.

678{
679 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
680 if (!file.is_open()) {
682 "Failed to open SPIR-V file: '{}'", filepath);
683 return {};
684 }
685
686 size_t file_size = static_cast<size_t>(file.tellg());
687 if (file_size == 0) {
689 "SPIR-V file is empty: '{}'", filepath);
690 return {};
691 }
692
693 if (file_size % sizeof(uint32_t) != 0) {
695 "SPIR-V file size ({} bytes) is not multiple of 4: '{}'",
696 file_size, filepath);
697 return {};
698 }
699
700 std::vector<uint32_t> buffer(file_size / sizeof(uint32_t));
701 file.seekg(0);
702 file.read(reinterpret_cast<char*>(buffer.data()), file_size);
703
704 if (!file) {
706 "Failed to read SPIR-V file: '{}'", filepath);
707 return {};
708 }
709
710 return buffer;
711}
#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 compile_glsl_to_spirv_external(), and create_from_spirv_file().

+ Here is the caller graph for this function: