MayaFlux 0.2.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 656 of file VKShaderModule.cpp.

657{
658 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
659 if (!file.is_open()) {
661 "Failed to open SPIR-V file: '{}'", filepath);
662 return {};
663 }
664
665 size_t file_size = static_cast<size_t>(file.tellg());
666 if (file_size == 0) {
668 "SPIR-V file is empty: '{}'", filepath);
669 return {};
670 }
671
672 if (file_size % sizeof(uint32_t) != 0) {
674 "SPIR-V file size ({} bytes) is not multiple of 4: '{}'",
675 file_size, filepath);
676 return {};
677 }
678
679 std::vector<uint32_t> buffer(file_size / sizeof(uint32_t));
680 file.seekg(0);
681 file.read(reinterpret_cast<char*>(buffer.data()), file_size);
682
683 if (!file) {
685 "Failed to read SPIR-V file: '{}'", filepath);
686 return {};
687 }
688
689 return buffer;
690}
#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: