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
53 /**--------------------------------------------------------------------------------------------------
54 \brief A GraphicsPipeline that renders a single Viewport for Vulkan
55 **/
57 {
58 protected:
65 protected:
67 {
69 VkSemaphore image_sem = vk_null;
70 VkSemaphore draw_sem = vk_null;
72 bool image_sem_waitable = false;
73 bool fence_waitable = false;
74 };
75 public:
78 VulkanRenderPipeline(const VulkanRenderPipeline& pipeline) = delete;
80 void cleanResources() override;
82 void init(GraphicsUpdateArguments& args) override;
83 void setWindowInstance(WindowInstance* instance) override;
84 void cleanup() override;
87 bool runCommand(GraphicsUpdateArguments& args) override;
88 virtual void drawFrame(GraphicsUpdateArguments& args) override;
94 //void setSession(const DynamicPointer<VulkanSession>& session);
97 void setSwapChainImageFormat(VkFormat format);
99 void setupSwapChainImages(Buffer<VkImage>& images, uint04 multisample_count);
100
101 virtual const ConstPointer<GraphicsDevice>& device() const override;
103 void setGrabImage(Image* image);
104 void imageWait();
105 void setClearColor(const RGBColor& color);
107 protected:
110 virtual void cleanupSwapChainResources(bool clean_khr);
111 virtual void cleanupKHR();
116 bool neadsSurfaceUpdate() const;
118 virtual void getKHRImages(uint04 multisample_count);
119 void getGrabImages(uint04 multisample_count);
121 virtual void lockAllImagesCommand();
126 VkSurfaceFormatKHR chooseSwapSurfaceFormat(const Buffer<VkSurfaceFormatKHR, uint04, ObjectAllocator<true>>& availableFormats);
127 Vector<2, uint04> chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, const Vector<2, uint04>& requested_size);
128
129 bool needsCleanup() const { return m_needs_cleanup; }
132
133 virtual void commit(GraphicsUpdateArguments&) override {};
135 virtual bool hasCommand() const override { return false; };
136 protected:
138 protected:
140 VkSwapchainKHR m_khr_swap_chain;
141
145
153
158
159 WindowInstance* m_window_instance;
162
168
176
177 };
178}
uint64_t VkFence
Definition ImageResources.h:40
#define vk_null
Definition VulkanDefines.h:11
uint64_t VkSurfaceKHR
Definition VulkanInstance.h:62
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition GraphicsPipeline.h:42
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
A GraphicsPipeline is a set of resources that are chained together to correctly render something.
Definition GraphicsPipeline.h:47
Options that are used for performing an update on a Graphics Engine call.
Definition GraphicsUpdateArguments.h:43
A root class that stores an an array of pixel data that can be displayed as an Image.
Definition Image.h:40
Definition MemoryManager.h:261
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
A GraphicsPipeline that renders a single Viewport for Vulkan.
Definition VulkanRenderPipeline.h:57
RGBColor m_clear_color
Definition VulkanRenderPipeline.h:169
DynamicPointer< VulkanImageData > m_shadow_image
Definition VulkanRenderPipeline.h:151
virtual bool needsRecreateSwapchain(GraphicsUpdateArguments &args)
bool m_needs_pipeline_recreation
Definition VulkanRenderPipeline.h:173
virtual void cleanupSwapChainResources(bool clean_khr)
DynamicPointer< VulkanImageData > m_depth_image
Definition VulkanRenderPipeline.h:149
virtual void recreateSwapChainResources(GraphicsUpdateArguments &args)
Buffer< VulkanImageResources > m_khr_images
Definition VulkanRenderPipeline.h:143
virtual bool executeDrawCycle(GraphicsUpdateArguments &args)
VulkanRenderPipeline(VulkanRenderPipeline &&pipeline)
void getGrabImages(uint04 multisample_count)
VulkanRenderPipeline(VulkanSession *session)
WindowInstance * m_window_instance
Definition VulkanRenderPipeline.h:159
DynamicPointer< VulkanImageData > m_frame_grab_image
Definition VulkanRenderPipeline.h:146
void setupSwapChainImages(Buffer< VkImage > &images, uint04 multisample_count)
void setClearColor(const RGBColor &color)
void init(GraphicsUpdateArguments &args) override
void presentKHR(GraphicsUpdateArguments &args)
DynamicPointer< VulkanRenderDefinition > & getRenderDefinition()
uint08 m_khr_format
Definition VulkanRenderPipeline.h:166
ConstPointer< SwapChainSupportDetails > m_swap_chain_support_details
Definition VulkanRenderPipeline.h:157
void updateFrameSize(GraphicsUpdateArguments &args)
bool m_suboptimal_khr
Definition VulkanRenderPipeline.h:175
void setWindowInstance(WindowInstance *instance) override
virtual void submitQueue(GraphicsUpdateArguments &args)
Vector< 2, uint04 > chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities, const Vector< 2, uint04 > &requested_size)
Image * m_grab_image
Definition VulkanRenderPipeline.h:161
virtual void drawFrame(GraphicsUpdateArguments &args) override
void setGrabImage(Image *image)
void getKHRImage(GraphicsUpdateArguments &args)
VulkanSession * m_session
Definition VulkanRenderPipeline.h:155
Time m_last_render_time
Definition VulkanRenderPipeline.h:164
VkSurfaceKHR m_surface
Definition VulkanRenderPipeline.h:139
virtual void commit(GraphicsUpdateArguments &) override
Definition VulkanRenderPipeline.h:133
SwapChainSupportDetails queryKHRSupport(VkPhysicalDevice_T *device)
Buffer< VkClearValue, uint04, ObjectAllocator< true > > clearValues() const
void setShadowImages(GraphicsUpdateArguments &args)
Buffer< FrameResources > m_frames
Definition VulkanRenderPipeline.h:142
void setViewportImages(GraphicsUpdateArguments &args)
bool m_needs_grab_image
Definition VulkanRenderPipeline.h:170
DynamicPointer< VulkanImageView > m_shadow_view
Definition VulkanRenderPipeline.h:152
DynamicPointer< VulkanDevice > m_device
Definition VulkanRenderPipeline.h:154
bool m_is_init
Definition VulkanRenderPipeline.h:172
VkResult finishBlockingReadback(GraphicsUpdateArguments &args)
bool m_needs_screen_draw
Definition VulkanRenderPipeline.h:171
DynamicPointer< VulkanImageData > m_multisample_image_color
Definition VulkanRenderPipeline.h:147
uint04 m_number_of_grab_images
Definition VulkanRenderPipeline.h:167
virtual const ConstPointer< GraphicsDevice > & device() const override
virtual void updateUniformBuffer(GraphicsUpdateArguments &) override
Definition VulkanRenderPipeline.h:134
DynamicPointer< VulkanImageView > m_multisample_view_color
Definition VulkanRenderPipeline.h:148
bool needsCleanup() const
Definition VulkanRenderPipeline.h:129
void ensureLastRenderComplete() override
const DynamicPointer< GraphicsDevice > & device() override
VulkanImageResources * m_last_image
Definition VulkanRenderPipeline.h:160
bool m_needs_cleanup
Definition VulkanRenderPipeline.h:174
void setDevice(const DynamicPointer< VulkanDevice > &instance)
void cleanResources() override
Vector< 2, uint04 > m_draw_size
Definition VulkanRenderPipeline.h:163
VkSurfaceFormatKHR chooseSwapSurfaceFormat(const Buffer< VkSurfaceFormatKHR, uint04, ObjectAllocator< true > > &availableFormats)
bool runCommand(GraphicsUpdateArguments &args) override
VulkanRenderPipeline(const VulkanRenderPipeline &pipeline)=delete
virtual void getKHRImages(uint04 multisample_count)
bool createPipeline(GraphicsUpdateArguments &args) override
void addReadback(GraphicsUpdateArguments &args)
virtual void lockAllImagesCommand()
Buffer< VulkanImageResources > m_grab_images
Definition VulkanRenderPipeline.h:144
virtual bool hasCommand() const override
Definition VulkanRenderPipeline.h:135
void getGrabImage(GraphicsUpdateArguments &args)
void lockImageCommand(VulkanImageResources &image) const
VkSwapchainKHR m_khr_swap_chain
Definition VulkanRenderPipeline.h:140
DynamicPointer< VulkanRenderDefinition > m_render_definition
Definition VulkanRenderPipeline.h:156
DynamicPointer< VulkanImageView > m_depth_view
Definition VulkanRenderPipeline.h:150
void setMultisampleImages(GraphicsUpdateArguments &args)
virtual void createSwapChainKHR(GraphicsUpdateArguments &args)
void setSwapChainImageFormat(VkFormat format)
static fltp08 ScreenSizeAllocationFactor()
Time m_surface_update_time
Definition VulkanRenderPipeline.h:165
Creates and manages the resources necessary for converting a DesignObjectLookup into 3D rendered data...
Definition VulkanSession.h:49
Definition ACIColor.h:37
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Definition BaseValues.hpp:106
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Data for pointing to a specific Image target within the Vulkan Graphics space.
Definition ImageResources.h:50
Definition VulkanRenderPipeline.h:67
VkFence fence
Definition VulkanRenderPipeline.h:68
bool fence_waitable
Definition VulkanRenderPipeline.h:73
VkSemaphore image_sem
Definition VulkanRenderPipeline.h:69
bool image_sem_waitable
Definition VulkanRenderPipeline.h:72
VkSemaphore draw_sem
Definition VulkanRenderPipeline.h:70
VulkanImageResources * image_acquired
Definition VulkanRenderPipeline.h:71
Definition VulkanRenderPipeline.h:60
VkSurfaceCapabilitiesKHR capabilities
Definition VulkanRenderPipeline.h:61
Buffer< VkSurfaceFormatKHR, uint04, ObjectAllocator< true > > formats
Definition VulkanRenderPipeline.h:62
Buffer< VkPresentModeKHR > presentModes
Definition VulkanRenderPipeline.h:63