Lugdunum  0.1.0
Window.cpp
Go to the documentation of this file.
1 #include <cstring>
13 
14 #if defined(LUG_SYSTEM_WINDOWS)
16 #elif defined(LUG_SYSTEM_LINUX)
18 #elif defined(LUG_SYSTEM_ANDROID)
20 #endif
21 
22 namespace lug {
23 namespace Graphics {
24 namespace Vulkan {
25 namespace Render {
26 
27 Window::Window(lug::Graphics::Vulkan::Renderer& renderer) : _renderer(renderer), _guiInstance(_renderer, *this), _isGuiInitialized(false) {}
28 
30  destroyRender();
31 }
32 
34  if (lug::Window::Window::pollEvent(event)) {
37 
38  // Update the RenderView
39  for (auto& renderView : _renderViews) {
40  renderView->update();
41  }
42  }
43 
44  if (_isGuiInitialized == true) {
45  while (_guiInstance.processEvent(event)) {
46  if (!lug::Window::Window::pollEvent(event)) {
47  return false;
48  }
49  }
50  }
51 
52  return true;
53  }
54 
55  return false;
56 }
57 
58 bool Window::beginFrame(const lug::System::Time &elapsedTime) {
59  AcquireImageData* acquireImageData = nullptr;
60  // Retrieve free AcquireImageData
61  {
62  for (auto& acquireImageData_ : _acquireImageDatas) {
63  if (acquireImageData_.imageIdx == -1) {
64  acquireImageData = &acquireImageData_;
65  break;
66  }
67  }
68  }
69 
70  if (_isGuiInitialized == true) {
71  _guiInstance.beginFrame(elapsedTime);
72  }
73 
74  while (_swapchain.isOutOfDate() || !_swapchain.getNextImage(&_currentImageIndex, static_cast<VkSemaphore>(acquireImageData->completeSemaphore))) {
75  if (_swapchain.isOutOfDate()) {
77  return false;
78  }
79 
80  if (_isGuiInitialized == true) {
82  LUG_LOG.error("Window::beginFrame: Failed to initialise Gui framebuffers");
83  return false;
84  }
85  }
86 
87  for (auto& renderView: _renderViews) {
88  View* renderView_ = static_cast<View*>(renderView.get());
89 
92  return false;
93  }
94  }
95  } else {
96  return false;
97  }
98  }
99 
100  // Set previous AcquireImageData free
101  {
102  for (auto& acquireImageData_ : _acquireImageDatas) {
103  if (acquireImageData_.imageIdx == (int)_currentImageIndex) {
104  acquireImageData_.imageIdx = -1;
105  }
106  }
107  }
108 
109  acquireImageData->imageIdx = (int)_currentImageIndex;
110 
112  API::CommandBuffer& cmdBuffer = frameData.cmdBuffers[0];
113 
114  std::vector<VkSemaphore> imageReadyVkSemaphores(frameData.imageReadySemaphores.size());
115 
116  for (unsigned i = 0; i < frameData.imageReadySemaphores.size(); ++i) {
117  imageReadyVkSemaphores[i] = static_cast<VkSemaphore>(frameData.imageReadySemaphores[i]);
118  }
119 
120  return _presentQueue->submit(
121  cmdBuffer,
122  imageReadyVkSemaphores,
123  {static_cast<VkSemaphore>(acquireImageData->completeSemaphore)},
124  {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT}
125  );
126 }
127 
129  bool uiResult = false;
130  bool presentQueueResult = false;
131 
133 
134  API::CommandBuffer& cmdBuffer = frameData.cmdBuffers[1];
135  std::vector<VkSemaphore> waitSemaphores(_renderViews.size());
136 
137  uint32_t i = 0;
138  for (auto& renderView: _renderViews) {
139  View* renderView_ = static_cast<View*>(renderView.get());
140 
141  // Render views with no camera don't signal the semaphore as they don't draw
142  if (renderView_->getCamera()) {
143  waitSemaphores[i] = static_cast<VkSemaphore>(renderView_->getDrawCompleteSemaphore(_currentImageIndex));
144  } else {
145  waitSemaphores[i] = static_cast<VkSemaphore>(frameData.imageReadySemaphores[i]);
146  }
147 
148  ++i;
149  }
150 
151  if (_isGuiInitialized) {
152  uiResult = _guiInstance.endFrame(waitSemaphores, _currentImageIndex);
153  presentQueueResult = _presentQueue->submit(cmdBuffer,
154  { static_cast<VkSemaphore>(frameData.allDrawsFinishedSemaphore) },
155  { static_cast<VkSemaphore>(_guiInstance.getSemaphore(_currentImageIndex)) },
156  { VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT });
157  } else {
158  uiResult = true;
159  std::vector<VkPipelineStageFlags> waitDstStageMasks(waitSemaphores.size(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
160 
161  presentQueueResult = _presentQueue->submit(cmdBuffer,
162  { static_cast<VkSemaphore>(frameData.allDrawsFinishedSemaphore) },
163  waitSemaphores,
164  waitDstStageMasks);
165  }
166 
167  return uiResult
168  && presentQueueResult
169  && _swapchain.present(_presentQueue, _currentImageIndex, static_cast<VkSemaphore>(frameData.allDrawsFinishedSemaphore));
170 }
171 
173  std::unique_ptr<View> renderView = std::make_unique<View>(_renderer, this);
174 
175  if (!renderView->init(initInfo, _presentQueue, _swapchain.getImagesViews())) {
176  return nullptr;
177  }
178 
179  _renderViews.push_back(std::move(renderView));
180 
181  return _renderViews.back().get();
182 }
183 
186  uint32_t i = 0;
187 
188  for (auto& renderView: _renderViews) {
189  if (!static_cast<View*>(renderView.get())->render(frameData.imageReadySemaphores[i++], _currentImageIndex)) {
190  return false;
191  }
192  }
193 
194  return true;
195 }
196 
197 std::unique_ptr<Window>
198 
200  std::unique_ptr<Window> window(new Window(renderer));
201 
202  if (!window->init(initInfo)) {
203  return nullptr;
204  }
205 
206  return window;
207 }
208 
214  VkResult result{VK_SUCCESS};
215  API::Builder::Surface surfaceBuilder(_renderer.getInstance());
216 
217 #if defined(LUG_SYSTEM_WINDOWS) // Win32 surface
218  surfaceBuilder.setWindowInformations(_impl->getHinstance(), _impl->getHandle());
219 #elif defined(LUG_SYSTEM_LINUX) // Linux surface
220  surfaceBuilder.setWindowInformations(_impl->getDisplay(), _impl->getWindow());
221 #elif defined(LUG_SYSTEM_ANDROID) // Android Surface
222  surfaceBuilder.setWindowInformations(_impl->getWindow());
223 #endif
224 
225  if (!surfaceBuilder.build(_surface, &result)) {
226  LUG_LOG.error("RendererWindow: Can't initialize surface: {}", result);
227  return false;
228  }
229 
230  return true;
231 }
232 
234  VkResult result{VK_SUCCESS};
236 
237  LUG_ASSERT(info != nullptr, "PhysicalDeviceInfo cannot be null");
238 
239  // Get swapchain capabilities
240  {
241  result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(info->handle, static_cast<VkSurfaceKHR>(_surface), &info->swapchain.capabilities);
242 
243  if (result != VK_SUCCESS) {
244  LUG_LOG.error("RendererWindow: Can't get surface capabilities: {}", result);
245  return false;
246  }
247 
248  uint32_t formatsCount = 0;
249  result = vkGetPhysicalDeviceSurfaceFormatsKHR(info->handle, static_cast<VkSurfaceKHR>(_surface), &formatsCount, nullptr);
250 
251  if (result != VK_SUCCESS) {
252  LUG_LOG.error("RendererWindow: Can't retrieve formats count: {}", result);
253  return false;
254  }
255 
256  info->swapchain.formats.resize(formatsCount);
257  result = vkGetPhysicalDeviceSurfaceFormatsKHR(info->handle, static_cast<VkSurfaceKHR>(_surface), &formatsCount, info->swapchain.formats.data());
258 
259  if (result != VK_SUCCESS) {
260  LUG_LOG.error("RendererWindow: Can't retrieve formats: {}", result);
261  return false;
262  }
263 
264  uint32_t presentModesCount = 0;
265  result = vkGetPhysicalDeviceSurfacePresentModesKHR(info->handle, static_cast<VkSurfaceKHR>(_surface), &presentModesCount, nullptr);
266 
267  if (result != VK_SUCCESS) {
268  LUG_LOG.error("RendererWindow: Can't retrieve present modes count: {}", result);
269  return false;
270  }
271 
272  info->swapchain.presentModes.resize(presentModesCount);
273  result = vkGetPhysicalDeviceSurfacePresentModesKHR(info->handle, static_cast<VkSurfaceKHR>(_surface), &presentModesCount, info->swapchain.presentModes.data());
274 
275  if (result != VK_SUCCESS) {
276  LUG_LOG.error("RendererWindow: Can't retrieve present modes: {}", result);
277  return false;
278  }
279  }
280 
281  return true;
282 }
283 
286  LUG_LOG.error("RendererWindow: Failed to initialise Gui");
287  return false;
288  }
289 
290  _isGuiInitialized = true;
291  return _isGuiInitialized;
292 }
293 
296 
297  LUG_ASSERT(info != nullptr, "PhysicalDeviceInfo cannot be null");
298 
299  // Get present queue families
300  {
301  VkResult result{VK_SUCCESS};
302  for (auto& queueFamily : _renderer.getDevice().getQueueFamilies()) {
303  VkBool32 supported = 0;
304  result = vkGetPhysicalDeviceSurfaceSupportKHR(info->handle, queueFamily.getIdx(), static_cast<VkSurfaceKHR>(_surface), &supported);
305 
306  if (result != VK_SUCCESS) {
307  LUG_LOG.error("RendererWindow: Can't check if queue supports presentation: {}", result);
308  return false;
309  }
310 
311  queueFamily.supportsPresentation(!!supported);
312  }
313  }
314 
315  // Get present queue family and retrieve the first queue
316  {
318  if (!_presentQueueFamily) {
319  LUG_LOG.error("Window::initPresentQueue: Can't find presentation queue family");
320  return false;
321  }
323  if (!_presentQueue) {
324  LUG_LOG.error("Window::initPresentQueue: Can't find presentation queue");
325  return false;
326  }
327  }
328 
329  // Create command pool of present queue
330  {
331  VkResult result{VK_SUCCESS};
333  if (!commandPoolBuilder.build(_commandPool, &result)) {
334  LUG_LOG.error("Window::initPresentQueue: Can't create a command pool: {}", result);
335  return false;
336  }
337  }
338 
339  return true;
340 }
341 
344 
345  API::Builder::Swapchain swapchainBuilder(_renderer.getDevice());
346  swapchainBuilder.setPreferences(_renderer.getPreferences().swapchain);
347  swapchainBuilder.setImageUsage(VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
348  swapchainBuilder.setImageColorSpace(VK_COLOR_SPACE_SRGB_NONLINEAR_KHR);
349  swapchainBuilder.setMinImageCount(3);
350 
351  // If width (and height) equals the special value 0xFFFFFFFF, the size of the surface will be set by the swapchain
352  if (info->swapchain.capabilities.currentExtent.height == 0xFFFFFFFF
353  && info->swapchain.capabilities.currentExtent.width == 0xFFFFFFFF) {
354  swapchainBuilder.setImageExtent(
355  {
356  _mode.width,
357  _mode.height
358  });
359  } else {
360  swapchainBuilder.setImageExtent(
361  {
362  info->swapchain.capabilities.currentExtent.width,
363  info->swapchain.capabilities.currentExtent.height
364  });
365  }
366 
367  // Find the transformation of the surface
368  if (info->swapchain.capabilities.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) {
369  // We prefer a non-rotated transform
370  swapchainBuilder.setPreTransform(VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR);
371  } else {
372  swapchainBuilder.setPreTransform(info->swapchain.capabilities.currentTransform);
373  }
374 
375  swapchainBuilder.setSurface(static_cast<VkSurfaceKHR>(_surface));
376  swapchainBuilder.setOldSwapchain(static_cast<VkSwapchainKHR>(_swapchain));
377 
378  // Create the swapchain
379  {
380  // Check if the presentation and graphics queue are the same
381  const API::QueueFamily* graphicsQueueFamily = _renderer.getDevice().getQueueFamily(VK_QUEUE_GRAPHICS_BIT);
382  if (graphicsQueueFamily != _presentQueueFamily) {
383 
384  if (!graphicsQueueFamily) {
385  LUG_LOG.error("RendererWindow: Can't find graphics queue");
386  return false;
387  }
388 
389  swapchainBuilder.setQueueFamilyIndices({_presentQueueFamily->getIdx(), graphicsQueueFamily->getIdx()});
390  }
391  else {
392  swapchainBuilder.setQueueFamilyIndices({_presentQueueFamily->getIdx()});
393  }
394 
395  // Reset command buffers because they use the swapchain images
397  {
398  uint32_t frameDataSize = (uint32_t)_swapchain.getImages().size();
399 
400  for (uint32_t i = 0; i < frameDataSize; ++i) {
401  for (uint32_t j = 0; j < _framesData[i].cmdBuffers.size(); ++j) {
402  _framesData[i].cmdBuffers[j].reset();
403  }
404  }
405  }
406 
407  VkResult result{VK_SUCCESS};
408  if (!swapchainBuilder.build(_swapchain, &result)) {
409  LUG_LOG.error("Window::initPresentQueue: Can't create swapchain: {}", result);
410  return false;
411  }
412 
413  return true;
414  }
415 }
416 
418  uint32_t frameDataSize = (uint32_t)_swapchain.getImages().size();
419 
420  if (_framesData.size() == frameDataSize) {
421  return true;
422  }
423 
424  _framesData.resize(frameDataSize);
425  _acquireImageDatas.resize(frameDataSize + 1);
426 
428  commandBufferBuilder.setLevel(VK_COMMAND_BUFFER_LEVEL_PRIMARY);
429 
430  API::Builder::Semaphore semaphoreBuilder(_renderer.getDevice());
431 
432  for (uint32_t i = 0; i < frameDataSize; ++i) {
433  // All draws finished semaphore
434  {
435  VkResult result{VK_SUCCESS};
436  if (!semaphoreBuilder.build(_framesData[i].allDrawsFinishedSemaphore, &result)) {
437  LUG_LOG.error("Window::initFramesData: Can't create semaphore: {}", result);
438  return false;
439  }
440  }
441 
442  // Image ready semaphores
443  {
444  _framesData[i].imageReadySemaphores.resize(_initInfo.renderViewsInitInfo.size());
445 
446  for (uint32_t j = 0; j < _initInfo.renderViewsInitInfo.size(); ++j) {
447  VkResult result{VK_SUCCESS};
448  if (!semaphoreBuilder.build(_framesData[i].imageReadySemaphores[j], &result)) {
449  LUG_LOG.error("Window::initFramesData: Can't create semaphore: {}", result);
450  return false;
451  }
452  }
453  }
454 
455  // Command buffers
456  {
457  VkResult result{VK_SUCCESS};
458  _framesData[i].cmdBuffers.resize(2); // The builder will build according to the array size.
459  if (!commandBufferBuilder.build(_framesData[i].cmdBuffers, &result)) {
460  LUG_LOG.error("Window::initFramesData: Can't create the command buffer: {}", result);
461  return false;
462  }
463  }
464  }
465 
466  for (uint32_t i = 0; i < frameDataSize + 1; ++i) {
467  // Acquire image semaphore
468  {
469  VkResult result{VK_SUCCESS};
470  if (!semaphoreBuilder.build(_acquireImageDatas[i].completeSemaphore, &result)) {
471  LUG_LOG.error("Window::initFramesData: Can't create semaphore: {}", result);
472  return false;
473  }
474 
475  _acquireImageDatas[i].imageIdx = -1;
476  }
477  }
478 
479  return buildCommandBuffers();
480 }
481 
483  uint32_t frameDataSize = (uint32_t)_swapchain.getImages().size();
484 
485  for (uint32_t i = 0; i < frameDataSize; ++i) {
486  // Build command buffer
487  API::CommandBuffer& cmdBuffer = _framesData[i].cmdBuffers[0];
488 
489  if (!cmdBuffer.begin(VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) {
490  return false;
491  }
492 
493  // Presentation to dst optimal
494  {
495  API::CommandBuffer::CmdPipelineBarrier pipelineBarrier{};
496  pipelineBarrier.imageMemoryBarriers.resize(1);
497  pipelineBarrier.imageMemoryBarriers[0].srcAccessMask = 0;
498  pipelineBarrier.imageMemoryBarriers[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
499  pipelineBarrier.imageMemoryBarriers[0].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
500  pipelineBarrier.imageMemoryBarriers[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
501  pipelineBarrier.imageMemoryBarriers[0].image = &_swapchain.getImages()[i];
502 
503  cmdBuffer.pipelineBarrier(pipelineBarrier, VK_DEPENDENCY_BY_REGION_BIT);
504  }
505 
506  // Clear the image to black
507  {
508  VkClearColorValue clearColor;
509  std::memset(&clearColor, 0, sizeof(clearColor));
510 
511  const VkImageSubresourceRange range{
512  /* range.aspectMask */ VK_IMAGE_ASPECT_COLOR_BIT,
513  /* range.baseMipLevel */ 0,
514  /* range.levelCount */ 1,
515  /* range.baseArrayLayer*/ 0,
516  /* range.layerCount */ 1
517  };
518 
519  // TODO: Put this method in CommandBuffer
520  vkCmdClearColorImage(
521  static_cast<VkCommandBuffer>(cmdBuffer),
522  static_cast<VkImage>(_swapchain.getImages()[i]),
523  VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
524  &clearColor,
525  1,
526  &range
527  );
528  }
529 
530  // Dst optimal to color attachment optimal
531  {
532  API::CommandBuffer::CmdPipelineBarrier pipelineBarrier{};
533  pipelineBarrier.imageMemoryBarriers.resize(1);
534  pipelineBarrier.imageMemoryBarriers[0].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
535  pipelineBarrier.imageMemoryBarriers[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
536  pipelineBarrier.imageMemoryBarriers[0].oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
537  pipelineBarrier.imageMemoryBarriers[0].newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
538  pipelineBarrier.imageMemoryBarriers[0].image = &_swapchain.getImages()[i];
539 
540  cmdBuffer.pipelineBarrier(pipelineBarrier, VK_DEPENDENCY_BY_REGION_BIT);
541  }
542 
543  if (!cmdBuffer.end()) {
544  return false;
545  }
546  }
547 
548  return true;
549 }
550 
552  uint32_t frameDataSize = (uint32_t)_swapchain.getImages().size();
553 
554  for (uint32_t i = 0; i < frameDataSize; ++i) {
555  // Build command buffer image color attachment to present
556  API::CommandBuffer& cmdBuffer = _framesData[i].cmdBuffers[1];
557 
558  if (!cmdBuffer.begin(VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) {
559  return false;
560  }
561 
562  API::CommandBuffer::CmdPipelineBarrier pipelineBarrier{};
563  pipelineBarrier.imageMemoryBarriers.resize(1);
564  pipelineBarrier.imageMemoryBarriers[0].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
565  pipelineBarrier.imageMemoryBarriers[0].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
566  pipelineBarrier.imageMemoryBarriers[0].oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
567  pipelineBarrier.imageMemoryBarriers[0].newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
568  pipelineBarrier.imageMemoryBarriers[0].image = &_swapchain.getImages()[i];
569 
570  cmdBuffer.pipelineBarrier(pipelineBarrier, VK_DEPENDENCY_BY_REGION_BIT);
571 
572  if (!cmdBuffer.end()) {
573  return false;
574  }
575  }
576 
577  return true;
578 }
579 
582 }
583 
585  _initInfo = std::move(initInfo);
586 
587  // Init the window
589  return false;
590  }
591 
592  if (_initInfo.renderViewsInitInfo.size() == 0) {
593  _initInfo.renderViewsInitInfo.push_back({
594  { // viewport
595  { // offset
596  0.0f, // x
597  0.0f // y
598  },
599 
600  { // extent
601  1.0f, // width
602  1.0f // height
603  },
604 
605  0.0f, // minDepth
606  1.0f // maxDepth
607  },
608  { // scissor
609  { // offset
610  0.0f, // x
611  0.0f // y
612  },
613  { // extent
614  1.0f, // width
615  1.0f // height
616  }
617  },
618  nullptr // camera
619  });
620  }
621 
622  return true;
623 }
624 
627  return false;
628  }
629 
630  for (auto& renderViewInitInfo : _initInfo.renderViewsInitInfo) {
631  if (!createView(renderViewInitInfo)) {
632  return false;
633  }
634  }
635 
636  return true;
637 }
638 
640  if (_presentQueue) {
642  }
643 
644  for (auto& renderView : _renderViews) {
645  renderView->destroy();
646  }
647 
648  _renderViews.clear();
649 
651  _surface.destroy();
652 
653  _framesData.clear();
654 
655  _acquireImageDatas.clear();
656 
658 
659  if (_isGuiInitialized == true) {
661  }
662 }
663 
664 } // Render
665 } // Vulkan
666 } // Graphics
667 } // lug
struct lug::Graphics::Vulkan::Renderer::Preferences::Swapchain swapchain
Represents an event.
Definition: Event.hpp:89
const std::vector< Queue > & getQueues() const
Definition: QueueFamily.inl:9
struct lug::Graphics::Vulkan::PhysicalDeviceInfo::Swapchain swapchain
Resource::SharedPtr< Camera::Camera > getCamera() const
Definition: View.inl:39
const API::QueueFamily * getQueueFamily(VkQueueFlags flags, bool supportPresentation=false) const
Definition: Device.cpp:34
bool pollEvent(lug::Window::Event &) override
Checks if an event is available from the window implementation, and fill it in the event parameter...
Definition: Window.cpp:33
#define LUG_ASSERT(assertion, message)
Definition: Debug.hpp:38
void beginFrame(const lug::System::Time &elapsedTime)
Definition: Gui.cpp:407
const API::QueueFamily * _presentQueueFamily
Definition: Window.hpp:93
virtual bool initDepthBuffers(const std::vector< API::ImageView > &imageViews)=0
std::vector< AcquireImageData > _acquireImageDatas
Definition: Window.hpp:98
bool endFrame(const std::vector< VkSemaphore > &waitSemaphores, uint32_t currentImageIndex)
Definition: Gui.cpp:424
lug::Window::Window::InitInfo windowInitInfo
Definition: Window.hpp:17
void pipelineBarrier(const CmdPipelineBarrier &parameters, VkDependencyFlags dependencyFlags=VK_DEPENDENCY_BY_REGION_BIT, VkPipelineStageFlags srcStageMask=VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VkPipelineStageFlags dstStageMask=VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) const
priv::WindowImpl * _impl
Definition: Window.hpp:180
bool submit(const CommandBuffer &commandBuffer, const std::vector< VkSemaphore > &signalSemaphores={}, const std::vector< VkSemaphore > &waitSemaphores={}, const std::vector< VkPipelineStageFlags > &waitDstStageMasks={}, VkFence fence=VK_NULL_HANDLE) const
Definition: Queue.cpp:32
const API::Semaphore & getDrawCompleteSemaphore(uint32_t currentImageIndex) const
Definition: View.inl:5
void setLevel(VkCommandBufferLevel level)
std::vector< VkPresentModeKHR > presentModes
Definition: Vulkan.hpp:196
bool beginFrame(const lug::System::Time &elapsedTime) override final
Definition: Window.cpp:58
std::vector< FrameData > _framesData
Definition: Window.hpp:96
const std::vector< ImageView > & getImagesViews() const
Definition: Swapchain.inl:13
static std::unique_ptr< Window > create(lug::Graphics::Vulkan::Renderer &renderer, Window::InitInfo &initInfo)
Definition: Window.cpp:199
Type type
The type of the event.
Definition: Event.hpp:110
lug::Graphics::Vulkan::Gui _guiInstance
Definition: Window.hpp:102
const std::vector< QueueFamily > & getQueueFamilies() const
Definition: Device.inl:10
::lug::Graphics::Render::View * createView(::lug::Graphics::Render::View::InitInfo &initInfo) override final
Definition: Window.cpp:172
const API::Queue * _presentQueue
Definition: Window.hpp:92
bool present(const Queue *presentQueue, uint32_t imageIndex, VkSemaphore semaphore=VK_NULL_HANDLE) const
Definition: Swapchain.cpp:127
Technique::Technique * getRenderTechnique()
Definition: View.inl:1
bool init(const InitInfo &initInfo)
Definition: Window.cpp:36
std::vector< VkSurfaceFormatKHR > formats
Definition: Vulkan.hpp:195
bool render() override final
Definition: Window.cpp:184
virtual bool initFramebuffers(const std::vector< API::ImageView > &imageViews)=0
const API::Instance & getInstance() const
Definition: Renderer.inl:25
std::vector< View::InitInfo > renderViewsInitInfo
Definition: Window.hpp:18
bool processEvent(const lug::Window::Event event)
Definition: Gui.cpp:582
const Vulkan::API::Semaphore & getSemaphore(uint32_t currentImageIndex) const
Definition: Gui.cpp:646
PhysicalDeviceInfo * getPhysicalDeviceInfo()
Definition: Renderer.inl:45
lug::Graphics::Vulkan::Renderer & _renderer
Definition: Window.hpp:88
std::vector< API::Semaphore > imageReadySemaphores
Definition: Window.hpp:35
const std::vector< Image > & getImages() const
Definition: Swapchain.inl:9
bool getNextImage(uint32_t *imageIndex, VkSemaphore semaphore=VK_NULL_HANDLE)
Definition: Swapchain.cpp:111
bool endFrame() override final
Definition: Window.cpp:128
bool init(Window::InitInfo &initInfo)
Definition: Window.cpp:584
void setOutOfDate(bool outOfDate)
Definition: Swapchain.inl:1
#define LUG_LOG
Definition: Logger.hpp:73
std::vector< std::unique_ptr< View > > _renderViews
Definition: Target.hpp:33
bool init(const std::vector< API::ImageView > &imageViews)
Definition: Gui.cpp:66
Preferences & getPreferences()
Definition: Renderer.inl:61
VideoMode _mode
Definition: Window.hpp:185
bool initFramebuffers(const std::vector< API::ImageView > &)
Definition: Gui.cpp:385
std::vector< API::CommandBuffer > cmdBuffers
Definition: Window.hpp:36
bool begin(VkCommandBufferUsageFlags flags=VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) const
virtual bool pollEvent(lug::Window::Event &event)
Checks if an event is available from the window implementation, and fill it in the event parameter...
Definition: Window.cpp:197
void setPreferences(const Renderer::Preferences::Swapchain &preferences)
Definition: Swapchain.inl:1