API Documentation
Loading...
Searching...
No Matches
VulkanRenderPipeline.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Graphics
28File: VulkanRenderPipeline
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "VulkanDefines.h"
34#include "VulkanImage.h"
36#include "ImageResources.h"
37
39#include "Base/Headers/String.h"
42namespace NDEVR
43{
44 struct SwapChainSupportDetails;
45 class File;
46 class Log;
47 class WindowInstance;
48 class VulkanSession;
49 class GraphicsUpdateArguments;
50 class VulkanRenderDefinition;
51 struct SwapChainSupportDetails;
52
54 {
55 protected:
62 protected:
64 {
65 VkFence fence = vk_null;
66 VkSemaphore image_sem = vk_null;
67 VkSemaphore draw_sem = vk_null;
69 bool image_sem_waitable = false;
70 bool fence_waitable = false;
71 };
72 public:
75 VulkanRenderPipeline(const VulkanRenderPipeline& pipeline) = delete;
76 virtual ~VulkanRenderPipeline();
77 void cleanResources() override;
78 void setDevice(const DynamicPointer<VulkanDevice>& instance);
79 void init(GraphicsUpdateArguments& args) override;
80 void setWindowInstance(WindowInstance* instance) override;
81 void cleanup() override;
84 bool runCommand(GraphicsUpdateArguments& args) override;
85 virtual void drawFrame(GraphicsUpdateArguments& args) override;
87 virtual bool executeDrawCycle(GraphicsUpdateArguments& args);
88 void invalidateImages();
89 virtual void submitQueue(GraphicsUpdateArguments& args);
91 //void setSession(const DynamicPointer<VulkanSession>& session);
92 bool createPipeline(GraphicsUpdateArguments& args) override;
93 void requestRedraw();
94 void setSwapChainImageFormat(VkFormat format);
96 void setupSwapChainImages(Buffer<VkImage>& images, uint04 multisample_count);
97
98 virtual const ConstPointer<GraphicsDevice>& device() const override;
99 const DynamicPointer<GraphicsDevice>& device() override;
100 void setGrabImage(Image* image);
101 void imageWait();
102 void setClearColor(const RGBColor& color);
103 void ensureLastRenderComplete() override;
104 protected:
107 virtual void cleanupSwapChainResources(bool clean_khr);
108 virtual void cleanupKHR();
113 bool neadsSurfaceUpdate() const;
114 void setupSurface();
115 virtual void getKHRImages(uint04 multisample_count);
116 void getGrabImages(uint04 multisample_count);
117 void createFrames();
118 virtual void lockAllImagesCommand();
120 void lockImageCommand(ImageResources& image) const;
123 VkSurfaceFormatKHR chooseSwapSurfaceFormat(const Buffer<VkSurfaceFormatKHR, uint04, ObjectAllocator<true>>& availableFormats);
124 Vector<2, uint04> chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, const Vector<2, uint04>& requested_size);
125
126 bool needsCleanup() const { return m_needs_cleanup; }
129
130 virtual void commit(GraphicsUpdateArguments&) override {};
132 virtual bool hasCommand() const override { return false; };
133 protected:
135 protected:
136 VkSurfaceKHR m_surface;
137 VkSwapchainKHR m_khr_swap_chain;
138
142
150
155
156 WindowInstance* m_window_instance;
159
165
173
174 };
175}
#define vk_null
Definition VulkanDefines.h:11
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition GraphicsPipeline.h:42
Definition Pointer.hpp:303
Definition GraphicsPipeline.h:45
Definition GraphicsUpdateArguments.h:40
Definition Image.h:39
Definition MemoryManager.h:283
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
Definition VulkanRenderPipeline.h:54
RGBColor m_clear_color
Definition VulkanRenderPipeline.h:166
virtual void getKHRImages(uint04 multisample_count)
Definition VulkanRenderPipeline.cpp:443
void lockImageCommand(ImageResources &image) const
Definition VulkanRenderPipeline.cpp:28
DynamicPointer< VulkanImageData > m_shadow_image
Definition VulkanRenderPipeline.h:148
void createFrames()
Definition VulkanRenderPipeline.cpp:573
bool m_needs_pipeline_recreation
Definition VulkanRenderPipeline.h:170
DynamicPointer< VulkanImageData > m_depth_image
Definition VulkanRenderPipeline.h:146
virtual void cleanupKHR()
Definition VulkanRenderPipeline.cpp:196
void getGrabImages(uint04 multisample_count)
Definition VulkanRenderPipeline.cpp:517
VulkanRenderPipeline(VulkanSession *session)
Definition VulkanRenderPipeline.cpp:46
WindowInstance * m_window_instance
Definition VulkanRenderPipeline.h:156
virtual void lockAllImagesCommand()
Definition VulkanRenderPipeline.cpp:592
DynamicPointer< VulkanImageData > m_frame_grab_image
Definition VulkanRenderPipeline.h:143
void setupSwapChainImages(Buffer< VkImage > &images, uint04 multisample_count)
Definition VulkanRenderPipeline.cpp:469
void setClearColor(const RGBColor &color)
Definition VulkanRenderPipeline.cpp:1286
void init(GraphicsUpdateArguments &args) override
Definition VulkanRenderPipeline.cpp:117
void setupSurface()
Definition VulkanRenderPipeline.cpp:418
void presentKHR(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:929
DynamicPointer< VulkanRenderDefinition > & getRenderDefinition()
Definition VulkanRenderPipeline.cpp:1363
void requestRedraw()
Definition VulkanRenderPipeline.cpp:1351
uint08 m_khr_format
Definition VulkanRenderPipeline.h:163
ConstPointer< SwapChainSupportDetails > m_swap_chain_support_details
Definition VulkanRenderPipeline.h:154
Buffer< ImageResources > m_khr_images
Definition VulkanRenderPipeline.h:140
void updateFrameSize(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:1259
void imageWait()
Definition VulkanRenderPipeline.cpp:963
bool m_suboptimal_khr
Definition VulkanRenderPipeline.h:172
void setWindowInstance(WindowInstance *instance) override
Definition VulkanRenderPipeline.cpp:185
Vector< 2, uint04 > chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities, const Vector< 2, uint04 > &requested_size)
Definition VulkanRenderPipeline.cpp:1147
SwapChainSupportDetails queryKHRSupport(VkPhysicalDevice_T *device)
Definition VulkanRenderPipeline.cpp:1107
Image * m_grab_image
Definition VulkanRenderPipeline.h:158
void setGrabImage(Image *image)
Definition VulkanRenderPipeline.cpp:957
void getKHRImage(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:289
virtual void drawFrame(GraphicsUpdateArguments &args) override
Definition VulkanRenderPipeline.cpp:724
virtual bool needsRecreateSwapchain(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:797
VulkanSession * m_session
Definition VulkanRenderPipeline.h:152
Time m_last_render_time
Definition VulkanRenderPipeline.h:161
VkSurfaceKHR m_surface
Definition VulkanRenderPipeline.h:136
void cleanup() override
Definition VulkanRenderPipeline.cpp:276
virtual void commit(GraphicsUpdateArguments &) override
Definition VulkanRenderPipeline.h:130
void invalidateImages()
Definition VulkanRenderPipeline.cpp:886
virtual void cleanupSwapChainResources(bool clean_khr)
Definition VulkanRenderPipeline.cpp:206
Buffer< VkClearValue, uint04, ObjectAllocator< true > > clearValues() const
Definition VulkanRenderPipeline.cpp:1318
void setShadowImages(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:680
Buffer< FrameResources > m_frames
Definition VulkanRenderPipeline.h:139
void setViewportImages(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:700
static fltp08 ScreenSizeAllocationFactor()
Definition VulkanRenderPipeline.cpp:600
bool neadsSurfaceUpdate() const
Definition VulkanRenderPipeline.cpp:672
bool m_needs_grab_image
Definition VulkanRenderPipeline.h:167
DynamicPointer< VulkanImageView > m_shadow_view
Definition VulkanRenderPipeline.h:149
DynamicPointer< VulkanDevice > m_device
Definition VulkanRenderPipeline.h:151
bool m_is_init
Definition VulkanRenderPipeline.h:169
VkResult finishBlockingReadback(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:1033
bool m_needs_screen_draw
Definition VulkanRenderPipeline.h:168
DynamicPointer< VulkanImageData > m_multisample_image_color
Definition VulkanRenderPipeline.h:144
uint04 m_number_of_grab_images
Definition VulkanRenderPipeline.h:164
void createCommandBuffers()
Definition VulkanRenderPipeline.cpp:1239
virtual void updateUniformBuffer(GraphicsUpdateArguments &) override
Definition VulkanRenderPipeline.h:131
DynamicPointer< VulkanImageView > m_multisample_view_color
Definition VulkanRenderPipeline.h:145
bool needsCleanup() const
Definition VulkanRenderPipeline.h:126
virtual void recreateSwapChainResources(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:154
void ensureLastRenderComplete() override
Definition VulkanRenderPipeline.cpp:1305
bool m_needs_cleanup
Definition VulkanRenderPipeline.h:171
void setDevice(const DynamicPointer< VulkanDevice > &instance)
Definition VulkanRenderPipeline.cpp:140
void cleanResources() override
Definition VulkanRenderPipeline.cpp:103
Vector< 2, uint04 > m_draw_size
Definition VulkanRenderPipeline.h:160
virtual void createSwapChainKHR(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:1164
VkSurfaceFormatKHR chooseSwapSurfaceFormat(const Buffer< VkSurfaceFormatKHR, uint04, ObjectAllocator< true > > &availableFormats)
Definition VulkanRenderPipeline.cpp:1130
bool runCommand(GraphicsUpdateArguments &args) override
Definition VulkanRenderPipeline.cpp:352
virtual const ConstPointer< GraphicsDevice > & device() const override
Definition VulkanRenderPipeline.cpp:461
VulkanRenderPipeline(const VulkanRenderPipeline &pipeline)=delete
Buffer< ImageResources > m_grab_images
Definition VulkanRenderPipeline.h:141
bool createPipeline(GraphicsUpdateArguments &args) override
Definition VulkanRenderPipeline.cpp:1341
ImageResources * m_last_image
Definition VulkanRenderPipeline.h:157
void addReadback(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:973
virtual ~VulkanRenderPipeline()
Definition VulkanRenderPipeline.cpp:97
virtual bool hasCommand() const override
Definition VulkanRenderPipeline.h:132
virtual bool executeDrawCycle(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:807
void getGrabImage(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:334
VkSwapchainKHR m_khr_swap_chain
Definition VulkanRenderPipeline.h:137
DynamicPointer< VulkanRenderDefinition > m_render_definition
Definition VulkanRenderPipeline.h:153
DynamicPointer< VulkanImageView > m_depth_view
Definition VulkanRenderPipeline.h:147
void setMultisampleImages(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:608
virtual void submitQueue(GraphicsUpdateArguments &args)
Definition VulkanRenderPipeline.cpp:898
void setSwapChainImageFormat(VkFormat format)
Definition VulkanRenderPipeline.cpp:1356
Time m_surface_update_time
Definition VulkanRenderPipeline.h:162
Definition VulkanSession.h:45
Definition ACIColor.h:37
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer -Can represent exact integer values 0 thro...
Definition BaseValues.hpp:132
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition ImageResources.h:47
Definition VulkanRenderPipeline.h:64
VkFence fence
Definition VulkanRenderPipeline.h:65
bool fence_waitable
Definition VulkanRenderPipeline.h:70
VkSemaphore image_sem
Definition VulkanRenderPipeline.h:66
bool image_sem_waitable
Definition VulkanRenderPipeline.h:69
VkSemaphore draw_sem
Definition VulkanRenderPipeline.h:67
ImageResources * image_acquired
Definition VulkanRenderPipeline.h:68
Definition VulkanRenderPipeline.h:57
VkSurfaceCapabilitiesKHR capabilities
Definition VulkanRenderPipeline.h:58
Buffer< VkSurfaceFormatKHR, uint04, ObjectAllocator< true > > formats
Definition VulkanRenderPipeline.h:59
Buffer< VkPresentModeKHR > presentModes
Definition VulkanRenderPipeline.h:60