HoviTron Video Pipeline
WindowAbstract.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
15
16
17#include"WindowAbstract.h"
18//#include"RVSConfig/include/Application.h"
22
24{
26}
27
28
30{
31 return needSwapchain;
32}
33
35{
37}
38
39
41{
42 wrapper = wraps;
43}
44
45
47{
48 throw std::logic_error(std::string(__func__) + " not implemented");
49 return vk::Buffer();
50}
51
53{
54 return currentTranslation;
55}
56
58{
59 return currentRotation;
60}
61
62std::vector<vk::Image> WindowAbstract::getBlitDestinations(int view, int elem)
63{
64 auto res = std::vector<vk::Image>();
65 return res;
66}
67
68std::vector<vk::Extent2D> WindowAbstract::getBlitExtentDestinations(int view, int elem)
69{
70 auto res = std::vector<vk::Extent2D>();
71 /*
72 if (isIndepFromWindowDimension()) {
73 assert(view < swapchains.size());
74 res.push_back(swapchains[view]->swapchainExtent);
75 }*/
76 return res;
77}
78
79std::vector<vk::Semaphore> WindowAbstract::getSemaphoreWait(int view, int elem)
80{
81 return std::vector<vk::Semaphore>();
82}
83
84std::vector<vk::Semaphore> WindowAbstract::getSemaphoreSignal(int view, int elem)
85{
86 return std::vector<vk::Semaphore>();
87}
88
89vk::ImageView WindowAbstract::getSwapchainImageView(int view, int elem)
90{
91 assert(view < swapchains.size());
92 return swapchains[view]->getSwapchainImageView(elem);
93}
94
95vk::ImageView WindowAbstract::getDepthSwapchainImageView(int view, int elem)
96{
97 assert(view < depthSwapchains.size());
98 return depthSwapchains[view]->getSwapchainImageView(elem);
99}
100
102{
103 return swapchains.size();
104}
105
106
107void WindowAbstract::setRotation(float v0,float v1,float v2) {
108 currentRotation[0] = v0;
109 currentRotation[1] = v1;
110 currentRotation[2] = v2;
111}
112
114 return false;
115}
116
118{
119 return false;
120}
121
122/*
123vk::SurfaceFormatKHR WindowAbstract::chooseSwapSurfaceFormat(const std::vector<vk::SurfaceFormatKHR>& availableFormats)
124{
125 for (const auto& availableFormat : availableFormats) {
126
127 //if (availableFormat.format == vk::Format::eB8G8R8A8Srgb && availableFormat.colorSpace == vk::ColorSpaceKHR::eSrgbNonlinear) {
128 // return availableFormat;
129 //}
130
131 if (availableFormat.format == vk::Format::eB8G8R8Unorm && availableFormat.colorSpace == vk::ColorSpaceKHR::eSrgbNonlinear) {
132 return availableFormat;
133 }
134 else if (availableFormat.format == vk::Format::eB8G8R8A8Unorm && availableFormat.colorSpace == vk::ColorSpaceKHR::eSrgbNonlinear) {
135 return availableFormat;
136 }
137 }
138 return availableFormats[0];
139}*/
140
141/*
142vk::PresentModeKHR WindowAbstract::chooseSwapPresentMode(const std::vector<vk::PresentModeKHR>& availablePresentModes)
143{
144#ifndef __ANDROID__
145 for (const auto& availablePresentMode : availablePresentModes) {
146 if (availablePresentMode == vk::PresentModeKHR::eMailbox) {
147 return availablePresentMode;
148 }
149 }
150#endif
151 return vk::PresentModeKHR::eFifo;
152}
153
154vk::Extent2D WindowAbstract::chooseSwapExtent(const vk::SurfaceCapabilitiesKHR& capabilities)
155{
156 if (capabilities.currentExtent.width != UINT32_MAX) {
157 return capabilities.currentExtent;
158 }
159 else {
160 int width, height;
161
162 getFrameBufferSize(&width, &height, wrapper->context.physicalDevice);
163#ifdef __ANDROID__
164 LOGI("swap size w= %d, h = %d", width, height);
165#endif
166
167 vk::Extent2D actualExtent = {
168 static_cast<uint32_t>(width),
169 static_cast<uint32_t>(height)
170 };
171
172
173 actualExtent.width = std::max(capabilities.minImageExtent.width, std::min(capabilities.maxImageExtent.width, actualExtent.width));
174 actualExtent.height = std::max(capabilities.minImageExtent.height, std::min(capabilities.maxImageExtent.height, actualExtent.height));
175
176 return actualExtent;
177 }
178}
179
180*/
181
182/*
183void WindowAbstract::createSwapchainImageViews()
184{
185 swapChainImageViews.resize(swapChainExtent.size());
186
187 for (uint32_t view = 0; view < swapChainExtent.size(); view++) {
188 int swapSize = swapChainImages[view].size();
189 swapChainImageViews[view].resize(swapSize);
190 for (uint32_t i = 0; i < swapSize; i++) {
191 swapChainImageViews[view][i] = createImageView(wrapper->context.device, swapChainImages[view][i], swapChainImageFormat[view], vk::ImageAspectFlagBits::eColor);
192
193 }
194 }
195
196}
197*/
198
199vk::Image WindowAbstract::getSwapchainImage(int view, int index) {
200 assert(view < swapchains.size());
201 return swapchains[view]->getSwapchainImage(index);
202}
203
204vk::Image WindowAbstract::getDepthSwapchainImage(int view, int index)
205{
206 assert(view < depthSwapchains.size());
207 return depthSwapchains[view]->getSwapchainImage(index);
208}
209
211{
212 assert(view < swapchains.size());
213 return swapchains[view]->swapchainExtent;
214}
215
217{
218 assert(view < swapchains.size());
219 return swapchains[view]->swapchainFormat;
220}
221
223{
224 assert(view < depthSwapchains.size());
225 return depthSwapchains[view]->swapchainFormat;
226}
227
229{
230 int res = 1;
231 for (int i = 0; i < swapchains.size();i++) {
232 int s = swapchains[i]->getAttachmentSize();
233 res = s > res ? s : res;
234 }
235 return res;
236}
237
238/*
239void WindowAbstract::continueInit()
240{
241
242 if (isSwapChainNeeded()) {
243
244 createSwapChain();
245 createSwapchainImageViews();
246 }
247}
248*/
249
250
File that contain the VulkanContext class to manage Vulkan Instance, Physical device,...
Class that contains helper functions for Vulkan.
file that contains the VulkanWrapper class that manages the classes related to Vulkan code and ease t...
Contain the class WindowAbstract.
Class that manages the classes related to Vulkan code and act as a wrapper around them.
Definition: VulkanWrapper.h:66
virtual const bool useOpenXR()
vk::ImageView getSwapchainImageView(int view, int elem)
virtual vk::Buffer getRenderingDestination()
glm::vec3 currentTranslation
vk::ImageView getDepthSwapchainImageView(int view, int elem)
glm::vec3 getTranslation()
const bool isValidationLayersEnabled()
glm::vec3 getRotation()
std::vector< std::unique_ptr< SwapchainAbstract > > depthSwapchains
virtual vk::Image getDepthSwapchainImage(int view, int index)
virtual vk::Extent2D getSwapchainExtent(int view)
void setWrapper(VulkanWrapper *wraps)
virtual vk::Format getDepthSwapchainFormat(int view)
bool isIndepFromWindowDimension()
bool isSwapChainNeeded()
glm::vec3 currentRotation
bool separateFromWindowDim
void setRotation(float v0, float v1, float v3)
virtual std::vector< vk::Extent2D > getBlitExtentDestinations(int view, int elem)
virtual vk::Format getSwapchainFormat(int view)
virtual std::vector< vk::Semaphore > getSemaphoreSignal(int view, int elem)
virtual std::vector< vk::Image > getBlitDestinations(int view, int elem)
virtual std::vector< vk::Semaphore > getSemaphoreWait(int view, int elem)
std::vector< std::unique_ptr< SwapchainAbstract > > swapchains
virtual bool isDepthRecquired()
VulkanWrapper * wrapper
virtual vk::Image getSwapchainImage(int view, int index)
const bool enableValidationLayers