| 52 | delete mContent; |
| 53 | } |
| 54 | ErrorCode VulkanRasterSort::onEncode(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs, |
| 55 | const VulkanCommandPool::Buffer *cmdBuffer) { |
| 56 | auto attr = inputs[0]; |
| 57 | auto numAttr = attr->length(1); |
| 58 | auto extra = static_cast<VulkanBackend*>(backend()); |
| 59 | { |
| 60 | std::vector<uint32_t> spc = {(uint32_t)mLocalSize, 1, 1, (uint32_t)mLocalSize}; |
| 61 | std::vector<VkDescriptorType> types { |
| 62 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 63 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 64 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 65 | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER |
| 66 | }; |
| 67 | if (4 == numAttr) { |
| 68 | mContent->rastersort_count_valid_number = extra->getPipelineFactory()->getPipeline("glsl_rastersort_count_valid_number_comp", types, spc); |
| 69 | } else { |
| 70 | mContent->rastersort_count_valid_number = extra->getPipelineFactory()->getPipeline("glsl_rastersort_count_valid_number_USE_HALF_comp", types, spc); |
| 71 | } |
| 72 | } |
| 73 | { |
| 74 | std::vector<uint32_t> spc = {(uint32_t)mLocalSize, 1, 1, (uint32_t)mLocalSize}; |
| 75 | std::vector<VkDescriptorType> types { |
| 76 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 77 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 78 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 79 | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 80 | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 81 | }; |
| 82 | if (4 == numAttr) { |
| 83 | mContent->rastersort_collect_key = extra->getPipelineFactory()->getPipeline("glsl_rastersort_collect_key_comp", types, spc); |
| 84 | } else { |
| 85 | mContent->rastersort_collect_key = extra->getPipelineFactory()->getPipeline("glsl_rastersort_collect_key_USE_HALF_comp", types, spc); |
| 86 | } |
| 87 | } |
| 88 | mContent->reset(); |
| 89 | if(extra->isSupportAutotune()){ |
| 90 | autoTune(inputs, outputs); |
| 91 | } |
| 92 | auto memPool = extra->getDynamicMemoryPool(); |
| 93 | auto viewProj = inputs[1]; |
| 94 | auto numberPoint = attr->length(0); |
| 95 | auto pointOffsetBytes = mLocalSize * mGroupSize * sizeof(uint32_t); |
| 96 | auto pointOffsets = memPool->alloc(pointOffsetBytes); |
| 97 | std::shared_ptr<VulkanBuffer> imageConstant = extra->allocUniform(nullptr, sizeof(ImageConstant)); |
| 98 | { |
| 99 | auto ptr = (ImageConstant*)imageConstant->map(); |
| 100 | ptr->point[0] = numberPoint; |
| 101 | //ptr->point[1] = attr->length(1) / 4; |
| 102 | imageConstant->unmap(); |
| 103 | } |
| 104 | mContent->uniforms.emplace_back(imageConstant); |
| 105 | // Compute valid pointNumber |
| 106 | { |
| 107 | SharedPtr<VulkanLayout::DescriptorSet> des = mContent->rastersort_count_valid_number->createSet(); |
| 108 | des->writeBuffer(((VulkanBuffer*)pointOffsets.first)->buffer(), 0, pointOffsetBytes, pointOffsets.second); |
| 109 | des->writeBuffer(extra->getBuffer(attr), 1); |
| 110 | des->writeBuffer(extra->getBuffer(viewProj), 2); |
| 111 | des->writeBuffer(imageConstant->buffer(), 3, imageConstant->size()); |
nothing calls this directly
no test coverage detected