| 23 | namespace spirv_handler { |
| 24 | |
| 25 | unique_ptr<uint32_t[]> load_binary(const string& file_name, size_t& code_size) { |
| 26 | unique_ptr<uint32_t[]> code; |
| 27 | |
| 28 | file_io binary(file_name, file_io::OPEN_TYPE::READ_BINARY); |
| 29 | if(!binary.is_open()) { |
| 30 | log_error("failed to load spir-v binary (\"$\")", file_name); |
| 31 | return {}; |
| 32 | } |
| 33 | |
| 34 | code_size = (size_t)binary.get_filesize(); |
| 35 | if(code_size % 4u != 0u) { |
| 36 | log_error("invalid spir-v binary size $ (\"$\"): must be a multiple of 4!", code_size, file_name); |
| 37 | return {}; |
| 38 | } |
| 39 | |
| 40 | code = make_unique<uint32_t[]>(code_size / 4u); |
| 41 | binary.get_block((char*)code.get(), (streamsize)code_size); |
| 42 | const auto read_size = binary.get_filestream()->gcount(); |
| 43 | if(read_size != (decltype(read_size))code_size) { |
| 44 | log_error("failed to read spir-v binary (\"$\"): expected $ bytes, but only read $ bytes", file_name, code_size, read_size); |
| 45 | return {}; |
| 46 | } |
| 47 | |
| 48 | return code; |
| 49 | } |
| 50 | |
| 51 | spirv_handler::container load_container(const string& file_name) { |
| 52 | string data { "" }; |
no test coverage detected