MayaFlux 0.4.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 734 of file VKShaderModule.cpp.

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.

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: