| 3408 | } |
| 3409 | |
| 3410 | vulkan_program::vulkan_program_entry |
| 3411 | vulkan_context::create_vulkan_program_internal(const spirv_handler::container& container, |
| 3412 | const std::vector<toolchain::function_info>& functions) { |
| 3413 | vulkan_program::vulkan_program_entry ret; |
| 3414 | ret.functions = functions; |
| 3415 | |
| 3416 | // create modules |
| 3417 | ret.programs.reserve(container.entries.size()); |
| 3418 | for(const auto& entry : container.entries) { |
| 3419 | // map functions (names) to the module index |
| 3420 | const auto mod_idx = (uint32_t)ret.programs.size(); |
| 3421 | for (const auto& func_name : entry.function_names) { |
| 3422 | ret.func_to_mod_map.emplace(func_name, mod_idx); |
| 3423 | } |
| 3424 | |
| 3425 | // we must create a copy of the program data |
| 3426 | auto program_storage = std::make_shared<uint32_t[]>(entry.data_word_count); |
| 3427 | memcpy(program_storage.get(), &container.spirv_data[entry.data_offset], entry.data_word_count * sizeof(uint32_t)); |
| 3428 | std::span<const uint32_t> code_span { program_storage.get(), entry.data_word_count }; |
| 3429 | ret.programs.emplace_back(std::move(program_storage), code_span); |
| 3430 | } |
| 3431 | |
| 3432 | ret.valid = true; |
| 3433 | return ret; |
| 3434 | } |
| 3435 | |
| 3436 | std::shared_ptr<device_program> vulkan_context::add_precompiled_program_file(const std::string& file_name, |
| 3437 | const std::vector<toolchain::function_info>& functions) { |