| 125 | } |
| 126 | |
| 127 | void |
| 128 | Algorithm::createParameters() |
| 129 | { |
| 130 | KP_LOG_DEBUG("Kompute Algorithm createParameters started"); |
| 131 | |
| 132 | std::vector<vk::DescriptorPoolSize> descriptorPoolSizes = { |
| 133 | vk::DescriptorPoolSize( |
| 134 | vk::DescriptorType::eStorageBuffer, |
| 135 | static_cast<uint32_t>(this->mTensors.size()) // Descriptor count |
| 136 | ) |
| 137 | }; |
| 138 | |
| 139 | vk::DescriptorPoolCreateInfo descriptorPoolInfo( |
| 140 | vk::DescriptorPoolCreateFlags(), |
| 141 | 1, // Max sets |
| 142 | static_cast<uint32_t>(descriptorPoolSizes.size()), |
| 143 | descriptorPoolSizes.data()); |
| 144 | |
| 145 | KP_LOG_DEBUG("Kompute Algorithm creating descriptor pool"); |
| 146 | this->mDescriptorPool = std::make_shared<vk::DescriptorPool>(); |
| 147 | this->mDevice->createDescriptorPool( |
| 148 | &descriptorPoolInfo, nullptr, this->mDescriptorPool.get()); |
| 149 | this->mFreeDescriptorPool = true; |
| 150 | |
| 151 | std::vector<vk::DescriptorSetLayoutBinding> descriptorSetBindings; |
| 152 | for (size_t i = 0; i < this->mTensors.size(); i++) { |
| 153 | descriptorSetBindings.push_back( |
| 154 | vk::DescriptorSetLayoutBinding(i, // Binding index |
| 155 | vk::DescriptorType::eStorageBuffer, |
| 156 | 1, // Descriptor count |
| 157 | vk::ShaderStageFlagBits::eCompute)); |
| 158 | } |
| 159 | |
| 160 | // This is the component that is fed into the pipeline |
| 161 | vk::DescriptorSetLayoutCreateInfo descriptorSetLayoutInfo( |
| 162 | vk::DescriptorSetLayoutCreateFlags(), |
| 163 | static_cast<uint32_t>(descriptorSetBindings.size()), |
| 164 | descriptorSetBindings.data()); |
| 165 | |
| 166 | KP_LOG_DEBUG("Kompute Algorithm creating descriptor set layout"); |
| 167 | this->mDescriptorSetLayout = std::make_shared<vk::DescriptorSetLayout>(); |
| 168 | this->mDevice->createDescriptorSetLayout( |
| 169 | &descriptorSetLayoutInfo, nullptr, this->mDescriptorSetLayout.get()); |
| 170 | this->mFreeDescriptorSetLayout = true; |
| 171 | |
| 172 | vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo( |
| 173 | *this->mDescriptorPool, |
| 174 | 1, // Descriptor set layout count |
| 175 | this->mDescriptorSetLayout.get()); |
| 176 | |
| 177 | KP_LOG_DEBUG("Kompute Algorithm allocating descriptor sets"); |
| 178 | this->mDescriptorSet = std::make_shared<vk::DescriptorSet>(); |
| 179 | this->mDevice->allocateDescriptorSets(&descriptorSetAllocateInfo, |
| 180 | this->mDescriptorSet.get()); |
| 181 | this->mFreeDescriptorSet = true; |
| 182 | |
| 183 | KP_LOG_DEBUG("Kompute Algorithm updating descriptor sets"); |
| 184 | for (size_t i = 0; i < this->mTensors.size(); i++) { |
no test coverage detected