HoviTron Video Pipeline
Public Member Functions | Data Fields
VulkanRenderPass Class Reference

Class that manage the renderPass containing the synthesis and blending steps. More...

#include <VulkanRenderPass.h>

Inheritance diagram for VulkanRenderPass:
VulkanRenderPassAbstract

Public Member Functions

 VulkanRenderPass (VulkanContext *context, VulkanWrapper *wraps)
 
void init (InputProvider *inputProvider) override
 
void cleanUp () override
 
void updateBuffer (uint32_t currentImage, bool initAll, std::span< InputProvider::StreamFrameInfo > infos, int view) override
 
void recordCommandBuffer (vk::CommandBuffer &commandBuffer, int i, std::span< InputProvider::StreamFrameInfo > frameInfos, int view) override
 
bool isInitialized () override
 
std::vector< vk::ImageView > getAttachmentView (int swapIndex, int view)
 
vk::Image getImageToBlit (int imageIndex) override
 
std::vector< vk::Format > getSupportedDepthFormats () const override
 
- Public Member Functions inherited from VulkanRenderPassAbstract
 VulkanRenderPassAbstract (VulkanContext *context, VulkanWrapper *wraps)
 
virtual void init (InputProvider *inputProvider)
 
virtual void cleanUp ()
 
virtual void updateBuffer (uint32_t currentImage, bool initAll, std::span< InputProvider::StreamFrameInfo > infos, int view)
 
virtual void recordCommandBuffer (vk::CommandBuffer &commandBuffer, int i, std::span< InputProvider::StreamFrameInfo > frameInfos, int view)
 
virtual bool isInitialized ()
 
virtual vk::Image getImageToBlit (int imageIndex)=0
 
virtual std::vector< vk::Format > getSupportedDepthFormats () const =0
 

Data Fields

std::vector< std::unique_ptr< VulkanPipelineWarping > > warpingPipelines
 
std::vector< std::unique_ptr< VulkanPipelineBlending > > blendingPipelines
 
vk::RenderPass renderPass
 
std::vector< ImageStructattachementColor
 
std::vector< ImageStructattachementDepthFloat
 
std::vector< ImageStructattachementQualityFloat
 
std::vector< ImageStructattachementAccuColor
 
std::vector< ImageStructattachementAccuQuality
 
std::vector< ImageStructattachementAccuDepth
 
std::vector< ImageStructattachementAccuColor2
 
std::vector< ImageStructattachementAccuQuality2
 
std::vector< ImageStructattachementAccuDepth2
 
std::vector< std::vector< vk::Framebuffer > > swapChainFramebuffers
 
- Data Fields inherited from VulkanRenderPassAbstract
std::vector< ImageStructdepthImages
 
vk::Extent2D renderingExtent
 
int inputImage = 1
 
vk::CommandPool commandPoolBuffer = nullptr
 
vk::Viewport viewport
 
vk::Rect2D scissor
 

Additional Inherited Members

- Protected Member Functions inherited from VulkanRenderPassAbstract
void createCommandPoolForBuffer ()
 
void createDepthResources ()
 
- Protected Attributes inherited from VulkanRenderPassAbstract
bool initialized = false
 
InputProviderinput = nullptr
 
VulkanContextcontext = nullptr
 
VulkanWrapperwrapper = nullptr
 
vk::Format depthFormat
 

Detailed Description

Class that manage the renderPass containing the synthesis and blending steps.

Class that manage the renderPass containing the synthesis and blending steps It also create additional attachments for the rendering

Definition at line 41 of file VulkanRenderPass.h.

Constructor & Destructor Documentation

◆ VulkanRenderPass()

VulkanRenderPass::VulkanRenderPass ( VulkanContext context,
VulkanWrapper wraps 
)

Constructor

Definition at line 50 of file VulkanRenderPass.cpp.

51{}
An abstract class that contains a common base of code for the class that inherit from it.

Member Function Documentation

◆ cleanUp()

void VulkanRenderPass::cleanUp ( )
overridevirtual

Clean up ressources

Reimplemented from VulkanRenderPassAbstract.

Definition at line 136 of file VulkanRenderPass.cpp.

137{
138 for (int i = 0; i < inputImage; i++) {
139 blendingPipelines[i]->cleanUp();
140 warpingPipelines[i]->cleanUp();
141 }
142 blendingPipelines.clear();
143 warpingPipelines.clear();
144
145 for (auto & im : attachementColor) {
146 im.destroy(context->device);
147 }
148
149 for (auto& im : attachementQualityFloat) {
150 im.destroy(context->device);
151 }
152 for (auto& im : attachementDepthFloat) {
153 im.destroy(context->device);
154 }
155 for (auto& im : attachementAccuColor) {
156 im.destroy(context->device);
157 }
158 for (auto& im : attachementAccuQuality) {
159 im.destroy(context->device);
160 }
161 for (auto& im : attachementAccuDepth) {
162 im.destroy(context->device);
163 }
164 for (auto& im : attachementAccuColor2) {
165 im.destroy(context->device);
166 }
167 for (auto& im : attachementAccuQuality2) {
168 im.destroy(context->device);
169 }
170 for (auto& im : attachementAccuDepth2) {
171 im.destroy(context->device);
172 }
173
174 attachementColor.clear();
176 attachementDepthFloat.clear();
177 attachementAccuColor.clear();
179 attachementAccuDepth.clear();
180 attachementAccuColor2.clear();
182 attachementAccuDepth2.clear();
183
184
185 for (auto& im : depthImages) {
186 im.destroy(context->device);
187 }
188 depthImages.clear();
189
190 context->device.destroyRenderPass(renderPass);
191 context->device.destroyCommandPool(commandPoolBuffer);
192
193 for (auto framebuffers : swapChainFramebuffers)
194 for(auto framebuffer:framebuffers) {
195 {
196 context->device.destroyFramebuffer(framebuffer);
197 }
198 }
199 swapChainFramebuffers.clear();
200}
vk::Device device
Definition: VulkanContext.h:87
std::vector< ImageStruct > depthImages
vk::RenderPass renderPass
std::vector< ImageStruct > attachementAccuQuality2
std::vector< ImageStruct > attachementAccuColor2
std::vector< ImageStruct > attachementDepthFloat
std::vector< std::unique_ptr< VulkanPipelineWarping > > warpingPipelines
std::vector< ImageStruct > attachementAccuDepth2
std::vector< ImageStruct > attachementQualityFloat
std::vector< std::vector< vk::Framebuffer > > swapChainFramebuffers
std::vector< ImageStruct > attachementAccuDepth
std::vector< ImageStruct > attachementAccuColor
std::vector< ImageStruct > attachementAccuQuality
std::vector< std::unique_ptr< VulkanPipelineBlending > > blendingPipelines
std::vector< ImageStruct > attachementColor

◆ getAttachmentView()

std::vector< vk::ImageView > VulkanRenderPass::getAttachmentView ( int  swapIndex,
int  view 
)

Return the vk::ImageView for the framebuffer at swapIndex for the specified view

Definition at line 848 of file VulkanRenderPass.cpp.

849{
850 int i = wrapper->multiviewSetup ? view : swapIndex;
851 std::vector<vk::ImageView> result = { attachementColor[i].imageView,
852 attachementDepthFloat[i].imageView,
853 attachementQualityFloat[i].imageView,
854 attachementAccuColor[i].imageView,
855 attachementAccuQuality[i].imageView};
856
857
859 result.push_back(attachementAccuDepth[i].imageView);
860 }
861
862 result.push_back(attachementAccuColor2[i].imageView);
863 result.push_back(attachementAccuQuality2[i].imageView);
864
866 result.push_back(attachementAccuDepth2[i].imageView);
867 }
868
870 result.push_back(depthImages[i].imageView);
871 }
872
873 return result;
874}
bool isIndepFromWindowDimension()
bool isDepthOutputRecquired()
const bool multiviewSetup

◆ getImageToBlit()

vk::Image VulkanRenderPass::getImageToBlit ( int  imageIndex)
overridevirtual

Return the image that should be the source for the blit operation

Implements VulkanRenderPassAbstract.

Definition at line 876 of file VulkanRenderPass.cpp.

876 {
877 if (inputImage % 2 == 1) {
878 //copy attachment 6
879 return attachementAccuColor2[imageIndex].image;
880 } else {
881 return attachementAccuColor[imageIndex].image;
882 }
883}

◆ getSupportedDepthFormats()

std::vector< vk::Format > VulkanRenderPass::getSupportedDepthFormats ( ) const
overridevirtual

Return the depth format supported by the application

Implements VulkanRenderPassAbstract.

Definition at line 53 of file VulkanRenderPass.cpp.

53 {
54 return {vk::Format::eD16Unorm, vk::Format::eD32Sfloat, vk::Format::eD24UnormS8Uint};
55}

◆ init()

void VulkanRenderPass::init ( InputProvider inputProvider)
overridevirtual

Init process

Reimplemented from VulkanRenderPassAbstract.

Definition at line 57 of file VulkanRenderPass.cpp.

57 {
58
59 VulkanRenderPassAbstract::init(inputProvider);
60
61 resetViewPortAndScissor = wrapper->isUsingDifferentViewSize();
62
63
64 for (int i = 0; i < inputImage; i++) {
65 warpingPipelines.push_back(std::make_unique<VulkanPipelineWarping>(context, this, input, wrapper, i));
66 blendingPipelines.push_back(std::make_unique<VulkanPipelineBlending>(context, this, wrapper, i));
67 }
68
70 PRINT("Rendering Size w= %d, h = %d", renderingExtent.width, renderingExtent.height);
71
72
73 createAttachementsRessources();
74 createDepthResources();
75 createRenderPass();
76 createFramebuffers();
77
78 //resetViewPortAndScissor = wrapper->isUsingDifferentViewSize();
79
80 //https://www.saschawillems.de/blog/2019/03/29/flipping-the-vulkan-viewport/
81 viewport = vk::Viewport{
82 0.0f, //x
83 (float)renderingExtent.height, //y
84 (float)renderingExtent.width, //width
85 (float)-1 * renderingExtent.height, //height
86 0.0f, //mindepth
87 1.0f }; //maxdepth
88
89 scissor = vk::Rect2D{ {0,0} , renderingExtent };
90
91 for (int i = 0; i < inputImage; i++) {
92 D(std::cout << "Create pipeline: " << i <<std::endl;)
94 blendingPipelines[i]->init();
95 }
96
97
98 initialized = true;
99
100
101}
virtual void init(InputProvider *inputProvider)
void init(InputProvider *inputProvider) override
vk::Extent2D getRenderOutputExtent()
bool isUsingDifferentViewSize()

◆ isInitialized()

bool VulkanRenderPass::isInitialized ( )
overridevirtual

Return true if the ressources were initialized for this renderpass

Reimplemented from VulkanRenderPassAbstract.

Definition at line 844 of file VulkanRenderPass.cpp.

844 {
845 return initialized;
846}

◆ recordCommandBuffer()

void VulkanRenderPass::recordCommandBuffer ( vk::CommandBuffer &  commandBuffer,
int  i,
std::span< InputProvider::StreamFrameInfo frameInfos,
int  view 
)
overridevirtual

Record the command buffer

D(std::cout << "\n record Command Buffer : " << i << std::endl;)

Reimplemented from VulkanRenderPassAbstract.

Definition at line 221 of file VulkanRenderPass.cpp.

222{
223 vk::ClearColorValue clearColor(std::array<float, 4>({ {0.0f, 0.0f, 0.0f, 1.0f} }));
224 /*
225 if (g_color_space == ColorSpace::YUV) {
226 //better black than green
227 vk::ClearColorValue clearColor(std::array<float, 4>({ {0.0f, 0.5f, 0.5f, 1.0f} }));
228 }*/
229
230
231 std::vector<vk::ClearValue> clearValues;
233 clearValues.resize(9);
234 clearValues[0].color = clearColor;
235 clearValues[1].color = clearColor;
236 clearValues[2].color = clearColor;
237 clearValues[3].color = clearColor;
238 clearValues[4].color = clearColor;
239 clearValues[5].color = clearColor;
240 clearValues[6].color = clearColor;
241 clearValues[7].depthStencil = vk::ClearDepthStencilValue{ 1.0f, 0 }; //{ 1.0f, 0};
242 clearValues[8].color = clearColor;
243 }
244 else {
245 clearValues.resize(11);
246 clearValues[0].color = clearColor;
247 clearValues[1].color = clearColor;
248 clearValues[2].color = clearColor;
249 clearValues[3].color = clearColor;
250 clearValues[4].color = clearColor;
251 clearValues[5].color = clearColor;
252 clearValues[6].color = clearColor;
253 clearValues[7].color = clearColor;
254 clearValues[8].color = clearColor;
255 clearValues[9].depthStencil = vk::ClearDepthStencilValue{ 1.0f, 0 }; //{ 1.0f, 0};
256 clearValues[10].color = clearColor;
257 }
258
260
261 vk::RenderPassBeginInfo renderPassBeginInfo(
262 renderPass, //renderpass
263 swapChainFramebuffers[view][i], //framebuffer
264 vk::Rect2D(vk::Offset2D(0, 0),
265 extend),//presentation->swapChainExtent), //offset + extent
266 static_cast<uint32_t>(clearValues.size()),
267 clearValues.data()
268 );
269
270 if (resetViewPortAndScissor) {
271
272 renderPassBeginInfo.renderArea = vk::Rect2D(vk::Offset2D(0, 0),
274 }
275
276 commandBuffer.beginRenderPass(renderPassBeginInfo, vk::SubpassContents::eInline);
277
278
279 if (wrapper->multiviewSetup) {
280 auto ext = wrapper->getSwapchainExtend(view);
281 viewport = vk::Viewport{
282 0.0f, //x
283 (float)ext.height, //y
284 (float)ext.width, //width
285 (float)-1 * ext.height, //height
286 0.0f, //mindepth
287 1.0f }; //maxdepth
288 scissor = vk::Rect2D{ {0, 0}, ext };
289 commandBuffer.setViewport(0, {viewport});
290 commandBuffer.setScissor(0, {scissor});
291 }
293 for (int input = 0; input < inputImage; input++) {
294 //D(std::cout << "\n record Command Buffer for input : " << input << std::endl;)
295 if (input > 0) {
296 //no need to clean the first time
297 vk::ClearColorValue clearColor(std::array<float, 4>({ {0.0f, 0.0f, 0.0f, 1.0f} }));
298 /*
299 if (g_color_space == ColorSpace::YUV) {
300 //better black than green
301 vk::ClearColorValue clearColor(std::array<float, 4>({ {0.0f, 0.5f, 0.5f, 1.0f} }));
302 }*/
303 vk::ClearAttachment clear0(vk::ImageAspectFlagBits::eColor, 0, vk::ClearValue(clearColor));
304 vk::ClearAttachment clear1(vk::ImageAspectFlagBits::eColor, 1, vk::ClearValue(clearColor));
305 vk::ClearAttachment clear2(vk::ImageAspectFlagBits::eColor, 2, vk::ClearValue(clearColor));
306 vk::ClearAttachment clear3(vk::ImageAspectFlagBits::eDepth, 0, vk::ClearValue(vk::ClearDepthStencilValue{ 1.0f,0 }));
307 /*
308 if (input == inputImage - 1) {
309 clear3 = vk::ClearAttachment(vk::ImageAspectFlagBits::eDepth, 0, vk::ClearValue(vk::ClearDepthStencilValue{ 0.0f,0 }));
310 }*/
311 std::array<vk::ClearAttachment, 4> clearAttachments = { clear0,clear1,clear2, clear3};
312 vk::ClearRect rect0 = vk::ClearRect(scissor, 0, 1);
313 vk::ClearRect rect1 = vk::ClearRect(scissor, 0, 1);
314 vk::ClearRect rect2 = vk::ClearRect(scissor, 0, 1);
315 std::array<vk::ClearRect, 3> clearRects = { rect0,rect1,rect2};
316 commandBuffer.clearAttachments(clearAttachments, clearRects);
317 }
318 commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, warpingPipelines[input]->pipeline);
319 warpingPipelines[input]->cmdBufferBindBuffer(commandBuffer, i, frameInfos[input], view);
320 commandBuffer.drawIndexed(warpingPipelines[input]->getIndexNumber(), 1, 0, 0, 0);
321
322 //next subPass
323 commandBuffer.nextSubpass(vk::SubpassContents::eInline);
324 //D(std::cout << "\n next subpass (input: " << input << ")" << std::endl;)
325
326
328 //farplane is value 0
329 vk::ClearAttachment clearD(vk::ImageAspectFlagBits::eDepth, 0, vk::ClearValue(vk::ClearDepthStencilValue{ 0.0f,0 }));
330 std::array<vk::ClearAttachment, 1> clearAttachments = { clearD };
331 vk::ClearRect rect0 = vk::ClearRect(scissor , 0, 1);
332 std::array<vk::ClearRect, 1> clearRect = { rect0 };
333 commandBuffer.clearAttachments(clearAttachments, clearRect);
334 }
335
336 commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, blendingPipelines[input]->pipeline);
337 blendingPipelines[input]->cmdBufferBindBuffer(commandBuffer, i, frameInfos[input], view);
338 commandBuffer.drawIndexed(blendingPipelines[input]->getIndexNumber(), 1, 0, 0, 0);
339
340
341
342 if(input != inputImage - 1){
343 //next subPass
344 commandBuffer.nextSubpass(vk::SubpassContents::eInline);
345 }
346 }
347
348 commandBuffer.endRenderPass();
349}
vk::Extent2D getSwapchainExtend(int view=0)

◆ updateBuffer()

void VulkanRenderPass::updateBuffer ( uint32_t  currentImage,
bool  initAll,
std::span< InputProvider::StreamFrameInfo infos,
int  view 
)
overridevirtual

Update buffer

Reimplemented from VulkanRenderPassAbstract.

Definition at line 202 of file VulkanRenderPass.cpp.

203{
204 if (initAll) {
205 for (int i = 0; i < inputImage; i++) {
206 warpingPipelines[i]->update(infos,view);
207 warpingPipelines[i]->updateAllBuffer(currentImage,view);
208 blendingPipelines[i]->updateAllBuffer(currentImage, view);
209
210 }
211 }
212 else {
213 for (int i = 0; i < inputImage; i++) {
214 warpingPipelines[i]->update(infos, view);
215 warpingPipelines[i]->updateBuffer(currentImage, view);
216 blendingPipelines[i]->updateBuffer(currentImage, view);
217 }
218 }
219}

Field Documentation

◆ attachementAccuColor

std::vector<ImageStruct> VulkanRenderPass::attachementAccuColor

Color attachments (for blending)

Definition at line 84 of file VulkanRenderPass.h.

◆ attachementAccuColor2

std::vector<ImageStruct> VulkanRenderPass::attachementAccuColor2

Color attachments 2 (for blending)

Definition at line 90 of file VulkanRenderPass.h.

◆ attachementAccuDepth

std::vector<ImageStruct> VulkanRenderPass::attachementAccuDepth

Depth attachment (for blending)

Definition at line 88 of file VulkanRenderPass.h.

◆ attachementAccuDepth2

std::vector<ImageStruct> VulkanRenderPass::attachementAccuDepth2

Depth attachments 2 (for blending)

Definition at line 94 of file VulkanRenderPass.h.

◆ attachementAccuQuality

std::vector<ImageStruct> VulkanRenderPass::attachementAccuQuality

Quality attachments (for blending)

Definition at line 86 of file VulkanRenderPass.h.

◆ attachementAccuQuality2

std::vector<ImageStruct> VulkanRenderPass::attachementAccuQuality2

Quality attachments 2 (for blending)

Definition at line 92 of file VulkanRenderPass.h.

◆ attachementColor

std::vector<ImageStruct> VulkanRenderPass::attachementColor

Color attachments (warping output)

Definition at line 74 of file VulkanRenderPass.h.

◆ attachementDepthFloat

std::vector<ImageStruct> VulkanRenderPass::attachementDepthFloat

depth datas (warping output)

Definition at line 76 of file VulkanRenderPass.h.

◆ attachementQualityFloat

std::vector<ImageStruct> VulkanRenderPass::attachementQualityFloat

quality attachments (warping output)

Definition at line 78 of file VulkanRenderPass.h.

◆ blendingPipelines

std::vector<std::unique_ptr<VulkanPipelineBlending> > VulkanRenderPass::blendingPipelines

Blending pipeline

Definition at line 66 of file VulkanRenderPass.h.

◆ renderPass

vk::RenderPass VulkanRenderPass::renderPass

vk::renderpass object

Definition at line 69 of file VulkanRenderPass.h.

◆ swapChainFramebuffers

std::vector<std::vector<vk::Framebuffer> > VulkanRenderPass::swapChainFramebuffers

Framebuffers for the differents swapchain. There is one vector of Framebuffer by view

Definition at line 97 of file VulkanRenderPass.h.

◆ warpingPipelines

std::vector<std::unique_ptr<VulkanPipelineWarping> > VulkanRenderPass::warpingPipelines

Warping pipeline

Definition at line 64 of file VulkanRenderPass.h.


The documentation for this class was generated from the following files: