HoviTron Video Pipeline
VulkanPipelineWarping.cpp
1/* ----------------------
2* Copyright 2023 Université Libre de Bruxelles(ULB), Universidad Politécnica de Madrid(UPM), CREAL, Deutsches Zentrum für Luft - und Raumfahrt(DLR)
3
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at < http://www.apache.org/licenses/LICENSE-2.0>
7
8* Unless required by applicable law or agreed to in writing, software
9* distributed under the License is distributed on an "AS IS" BASIS,
10* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11* See the License for the specific language governing permissionsand
12* limitations under the License.
13---------------------- */
14
16#include"Shader.h"
17#include"VulkanContext.h"
19#include"VulkanRenderPass.h"
20#include"VulkanWrapper.h"
21
22
23
25{
26 this->wrapper = wraps;
27 this->context = context;
28 this->renderPass = renderPass;
29 this->colorAttachmentNb = 3;
30 this->inputId = inputCamId;
31 this->subPass = 2 * inputCamId + 0;
32
33 bufferController = std::make_unique<BuffersControllerWarping>(context, renderPass, this, inputP, wraps, inputCamId);
34
35
36 auto activation = wrapper->getCameraActivation();
37 for (int i = 0; i <= inputCamId; i++) {
38 if (!activation[i]) {
39 inputCamId++;
40 this->inputId++;
41 }
42 }
43
44
45
46 auto streamParam = inputP->enumerateStreamsParameters()[inputCamId];
47 colorSampler = streamParam.colorSampler;
48 depthSampler = streamParam.depthSampler;
49
50
51}
53{
54 //createRenderPass();
56 createGraphicsPipeline();
57
58 //for the buffer Controller
59 bufferController->init();
60
61
62}
63
65{
67 bufferController->cleanUp();
68 context->device.destroyPipeline(pipeline);
69 context->device.destroyPipelineLayout(pipelineLayout);
70
71}
72
73
74
76{
77 vk::DescriptorSetLayoutBinding depthSamplerLayoutBinding(
78 1, //binding
79 vk::DescriptorType::eCombinedImageSampler, //descriptor type
80 1, //descriptorCount
81 vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment, //stageFlags
82 &depthSampler //pimmutable sampler
83 );
84 vk::DescriptorSetLayoutBinding uboVertCamLayoutBinding(
85 2, //binding
86 vk::DescriptorType::eUniformBuffer, //descriptor type
87 1, //descriptorCount
88 vk::ShaderStageFlagBits::eVertex, //stageFlags
89 nullptr //pimmutable sampler
90 );
91 vk::DescriptorSetLayoutBinding uboVertLayoutBinding(
92 3, //binding
93 vk::DescriptorType::eUniformBuffer, //descriptor type
94 1, //descriptorCount
95 vk::ShaderStageFlagBits::eVertex, //stageFlags
96 nullptr //pimmutable sampler
97 );
98 vk::DescriptorSetLayoutBinding uboGeomLayoutBinding(
99 4, //binding
100 vk::DescriptorType::eUniformBuffer, //descriptor type
101 1, //descriptorCount
102 vk::ShaderStageFlagBits::eGeometry, //stageFlags
103 nullptr //pimmutable sampler
104 );
105 vk::DescriptorSetLayoutBinding uboFragLayoutBinding(
106 5, //binding
107 vk::DescriptorType::eUniformBuffer, //descriptor type
108 1, //descriptorCount
109 vk::ShaderStageFlagBits::eFragment, //stageFlags
110 nullptr //pimmutable sampler
111 );
112 vk::DescriptorSetLayoutBinding samplerLayoutBinding(
113 6,
114 vk::DescriptorType::eCombinedImageSampler,
115 1,
116 vk::ShaderStageFlagBits::eFragment,
117 &colorSampler
118 );
119
120 std::array<vk::DescriptorSetLayoutBinding, 6> bindings = { depthSamplerLayoutBinding, uboVertCamLayoutBinding,uboVertLayoutBinding, uboGeomLayoutBinding, uboFragLayoutBinding, samplerLayoutBinding };
121
122 vk::DescriptorSetLayoutCreateInfo layoutInfo(vk::DescriptorSetLayoutCreateFlags(), static_cast<uint32_t>(bindings.size()), bindings.data());
123
124 descriptorSetLayout = context->device.createDescriptorSetLayout(layoutInfo);
125
126}
127
128void VulkanPipelineWarping::update(std::span<InputProvider::StreamFrameInfo> infos, int view)
129{
130 bufferController->update(infos, view);
131}
132
133
134
135
136void VulkanPipelineWarping::createGraphicsPipeline()
137{
138 //ShadersList shaders = ShadersList::getInstance();
139 //shaders.loadShaders();
140 /*
141 vk::ShaderModule vertShaderModule = createShaderModule(shaders("shader.vert"));
142 vk::ShaderModule fragShaderModule = createShaderModule(shaders("shader.frag"));
143
144 std::array<vk::PipelineShaderStageCreateInfo, 2> pipelineShaderStageCreateInfos = {
145 vk::PipelineShaderStageCreateInfo(
146 vk::PipelineShaderStageCreateFlags(), vk::ShaderStageFlagBits::eVertex, vertShaderModule, "main"), //main is entry point of the shader
147 vk::PipelineShaderStageCreateInfo(
148 vk::PipelineShaderStageCreateFlags(), vk::ShaderStageFlagBits::eFragment, fragShaderModule, "main")
149 };
150 */
151 vk::ShaderModule vertShaderModule = createShaderModule(ShadersList::getInstance()("synthesis.vert"));
152 vk::ShaderModule geomShaderModule = createShaderModule(ShadersList::getInstance()("synthesis.geom"));
153 vk::ShaderModule fragShaderModule = createShaderModule(ShadersList::getInstance()("synthesis.frag"));
154
155 std::vector<vk::PipelineShaderStageCreateInfo> pipelineShaderStageCreateInfos = {
156 vk::PipelineShaderStageCreateInfo(
157 vk::PipelineShaderStageCreateFlags(), vk::ShaderStageFlagBits::eVertex, vertShaderModule, "main"), //main is entry point of the shader
158 vk::PipelineShaderStageCreateInfo(
159 vk::PipelineShaderStageCreateFlags(), vk::ShaderStageFlagBits::eGeometry, geomShaderModule, "main"),
160 vk::PipelineShaderStageCreateInfo(
161 vk::PipelineShaderStageCreateFlags(), vk::ShaderStageFlagBits::eFragment, fragShaderModule, "main")
162 };
163
164
165 this->createPipeline(pipelineShaderStageCreateInfos);
166
167 context->device.destroyShaderModule(vertShaderModule);
168 context->device.destroyShaderModule(geomShaderModule);
169 context->device.destroyShaderModule(fragShaderModule);
170}
171
172
Contains the class that loads the SPIR-V shaders from files.
File that contain the VulkanContext class to manage Vulkan Instance, Physical device,...
Class that contains helper functions for Vulkan.
Contains the class that manages the warping pipeline.
file that contains the class that manage the renderPass containing the synthesis and blending steps
file that contains the VulkanWrapper class that manages the classes related to Vulkan code and ease t...
Abstract interface around getting source views parameters and data.
Definition: InputProvider.h:35
static ShadersList & getInstance()
Definition: Shader.cpp:99
class that manages tasks related to Vulkan context (Vulkan Instance, Vulkan Physical device,...
Definition: VulkanContext.h:59
vk::Device device
Definition: VulkanContext.h:87
std::unique_ptr< BuffersController > bufferController
void createPipeline(std::vector< vk::PipelineShaderStageCreateInfo > &arr)
VulkanRenderPass * renderPass
vk::ShaderModule createShaderModule(const Shader &shader)
vk::DescriptorSetLayout descriptorSetLayout
vk::PipelineLayout pipelineLayout
void update(std::span< InputProvider::StreamFrameInfo > infos, int view)
VulkanPipelineWarping(VulkanContext *context, VulkanRenderPass *renderPass, InputProvider *inputP, VulkanWrapper *wraps, int inputCamID)
Class that manage the renderPass containing the synthesis and blending steps.
Class that manages the classes related to Vulkan code and act as a wrapper around them.
Definition: VulkanWrapper.h:66
std::vector< bool > getCameraActivation()