MCPcopy Create free account
hub / github.com/alibaba/MNN / _initTarget

Method _initTarget

source/backend/vulkan/buffer/render/VulkanRasterAndInterpolate.cpp:120–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120ErrorCode VulkanRasterAndInterpolate::_initTarget(int width, int height) {
121 if (mWidth == width || mHeight == height) {
122 return NO_ERROR;
123 }
124 mTarget = nullptr;
125 auto extra = static_cast<VulkanBackend*>(backend());
126 SharedPtr<VulkanImage> depth = new VulkanImage(extra->getMemoryPool(), false, std::vector<int>{width, height}, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
127 std::vector<SharedPtr<VulkanImage>> colors(4);
128 for (int i=0; i<colors.size(); ++i) {
129 colors[i] = new VulkanImage(extra->getMemoryPool(), false, std::vector<int>{width, height}, VK_FORMAT_R32G32B32A32_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_STORAGE_BIT);
130 }
131 mTarget = VulkanTarget::create(colors, depth);
132#ifdef TEST
133 auto& cmdPool = extra->getPool();
134 auto buffer = cmdPool.allocBuffer();
135 buffer->begin(0);
136 mTarget->onEnter(buffer->get());
137 mTarget->onExit(buffer->get());
138 buffer->end();
139 cmdPool.submitAndWait(buffer->get());
140 delete buffer;
141#endif
142 auto& info = mGraphicCache->info();
143 mTarget->writePipelineInfo(info);
144 mGraphicPipeline = extra->getPipelineFactory()->createGraphicPipeline(mEmptyLayout, mGraphicCache.get());
145 mWidth = width;
146 mHeight = height;
147 return NO_ERROR;
148}
149
150ErrorCode VulkanRasterAndInterpolate::onEncode(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs,
151 const VulkanCommandPool::Buffer *cmdBuffer) {

Callers

nothing calls this directly

Calls 14

backendFunction · 0.85
onEnterMethod · 0.80
onExitMethod · 0.80
submitAndWaitMethod · 0.80
writePipelineInfoMethod · 0.80
createGraphicPipelineMethod · 0.80
getPipelineFactoryMethod · 0.80
createFunction · 0.50
sizeMethod · 0.45
allocBufferMethod · 0.45
beginMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected