MayaFlux 1.0.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 853 of file VKShaderModule.cpp.

854{
855 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
856 if (!file.is_open()) {
858 "Failed to open SPIR-V file: '{}'", filepath);
859 return {};
860 }
861
862 size_t file_size = static_cast<size_t>(file.tellg());
863 if (file_size == 0) {
865 "SPIR-V file is empty: '{}'", filepath);
866 return {};
867 }
868
869 if (file_size % sizeof(uint32_t) != 0) {
871 "SPIR-V file size ({} bytes) is not multiple of 4: '{}'",
872 file_size, filepath);
873 return {};
874 }
875
876 std::vector<uint32_t> buffer(file_size / sizeof(uint32_t));
877 file.seekg(0);
878 file.read(reinterpret_cast<char*>(buffer.data()), file_size);
879
880 if (!file) {
882 "Failed to read SPIR-V file: '{}'", filepath);
883 return {};
884 }
885
886 return buffer;
887}
#define MF_ERROR(comp, ctx,...)
std::shared_ptr< NetworkGeometryBuffer > buffer
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.

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

Referenced by create_from_spirv_file().

+ Here is the caller graph for this function: