| 53 | } |
| 54 | |
| 55 | unique_ptr<argument_buffer> compute_kernel::create_argument_buffer(const compute_queue& cqueue, const uint32_t& arg_index, |
| 56 | const COMPUTE_MEMORY_FLAG add_mem_flags) const { |
| 57 | const auto& dev = cqueue.get_device(); |
| 58 | const auto entry = get_kernel_entry(dev); |
| 59 | if (!entry || !entry->info) { |
| 60 | log_error("no kernel entry/info for device $", dev.name); |
| 61 | return {}; |
| 62 | } |
| 63 | |
| 64 | // need to take care of argument index translation when stage_input arguments exist |
| 65 | uint32_t idx = 0; |
| 66 | for (uint32_t actual_idx = 0, count = uint32_t(entry->info->args.size()); idx <= count; ++actual_idx) { |
| 67 | if (idx >= count) { |
| 68 | log_error("argument index is out-of-bounds: $", arg_index); |
| 69 | return {}; |
| 70 | } |
| 71 | |
| 72 | const auto& arg_info = entry->info->args[idx]; |
| 73 | if (actual_idx == arg_index) { |
| 74 | if (arg_info.special_type != llvm_toolchain::SPECIAL_TYPE::ARGUMENT_BUFFER) { |
| 75 | log_error("argument #$ is not an argument buffer", arg_index); |
| 76 | return {}; |
| 77 | } |
| 78 | break; |
| 79 | } |
| 80 | |
| 81 | if (arg_info.special_type == llvm_toolchain::SPECIAL_TYPE::STAGE_INPUT) { |
| 82 | // skip to next actual arg |
| 83 | while (idx < entry->info->args.size() && |
| 84 | entry->info->args[idx].special_type == llvm_toolchain::SPECIAL_TYPE::STAGE_INPUT) { |
| 85 | ++idx; |
| 86 | } |
| 87 | } else { |
| 88 | ++idx; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return create_argument_buffer_internal(cqueue, *entry, entry->info->args[idx], arg_index, idx, add_mem_flags); |
| 93 | } |
| 94 | |
| 95 | unique_ptr<argument_buffer> compute_kernel::create_argument_buffer_internal(const compute_queue&, |
| 96 | const kernel_entry&, |
nothing calls this directly
no test coverage detected