NDEVR
API Documentation
VulkanSession.h
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: VulkanSession
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "VulkanDefines.h"
34#include "VulkanDevice.h"
35#include "VulkanCameraManager.h"
36#include "VulkanVertexManager.h"
37#include "VulkanMaterialManager.h"
38#include <NDEVR/GraphicsSession.h>
39#include <NDEVR/ModelGeoMaterial.h>
40DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache);
41namespace NDEVR
42{
50 class VulkanSession : public GraphicsSession
51 {
52 public:
53 VulkanSession(const DynamicPointer<VulkanDevice>& instance);
54 ~VulkanSession();
55 //virtual void setDevice(const DynamicPointer<GraphicsDevice>& instance) override;
56 virtual const ConstPointer<GraphicsDevice>& device() const final override { return m_graphics_device; };
57 virtual const DynamicPointer<GraphicsDevice>& device() final override { return m_graphics_device; };
58 void ensureCameraExists(const UUID & camera);
59 void setupRasterizers();
60 void setupAssemblyInputs();
62 void destroySceneManager(const UUID& scene);
63 void destroyMaterialManager(const UUID& mat);
64 void destroyCameraManager(const UUID& camera);
65 void cleanupOldPipelines(GraphicsUpdateArguments& args);
66 static UUID VulkanRenderEngineID() { return UUID::CreateUUID("Vulkan Render Engine"); }
67 void updateUniformBuffer(GraphicsUpdateArguments& args) final override;
68 bool createPipeline(GraphicsUpdateArguments& args) final override;
69 void commit(GraphicsUpdateArguments& args) final override;
70 bool hasCommand() const override;
71 UUID uuid() const { return m_uuid; }
72 virtual void postClearAll() final override;
73 bool runCommand(GraphicsUpdateArguments& args) final override;
74 DynamicPointer<VulkanCameraManager> getCameraManager(const UUID& camera);
75 DynamicPointer<VulkanMaterialManager> getMaterialManager(const Material& mat);
76 DynamicPointer<VulkanMaterialManager> getMaterialManager(const UUID& id);
77 DynamicPointer<VulkanVertexManager> getVertexManager(const Scene& mesh);
78 void setRenderDefinition(const DynamicPointer<VulkanRenderDefinition>& def);
79 DynamicPointer<VulkanShaderManager> shaderManager() { return m_shader_manager; }
80 virtual UUID uuid() final override { return m_device->id(); };
81 //virtual void setDevice(const DynamicPointer<GraphicsDevice>& instance) = 0;
82 virtual void drawFrame(GraphicsUpdateArguments&) final override {};
83 virtual void ensureLastRenderComplete() final override {};
84 virtual void setWindowInstance(WindowInstance*) final override {};
85 virtual void cleanResources() final override {};
86 virtual void init(GraphicsUpdateArguments&) final override {};
87 protected:
88 virtual void clearAll();
89 void clearScene();
90 void updateCameraPipeline(GraphicsUpdateArguments& args);
91 bool addRenderGeometry(const Geometry& geo) override;
92 void removeRenderGeometry(const Geometry& geo) override;
93 bool checkPipeline(bool add_if_needed);
94 bool checkPipeline(GeometryUpdateObject& geo, bool add_if_needed);
95 void pipelineSort(GraphicsUpdateArguments& args);
96 void createModelPipeline(GraphicsUpdateArguments& args);
97 bool createDescriptorPool(GraphicsUpdateArguments& args);
98 //bool createModelDescriptorPool(GraphicsUpdateArguments& args);
99 void cleanup() final override;
100 private:
101 void createPipelineInput();
102 protected:
106 Dictionary<size_t, VulkanRenderObject*> m_render_objects;
107 Buffer<VulkanRenderObject*> m_pipelines;
108 Buffer<VkGraphicsPipelineCreateInfo> m_pipeline_info_buffer;
118 Buffer<GeometryUpdateObject> m_geometries;
120 Vector<cast<uint01>(VkPrimitiveTopology::VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN + 1), VkPipelineInputAssemblyStateCreateInfo> m_assembly_input;
124 DynamicPointer<VulkanRenderDefinition> m_render_definition;
125 DynamicPointer<GraphicsDevice> m_graphics_device;
127 VkDescriptorPool m_descriptor_pool;
128 //VkDescriptorPool_T* m_model_descriptor_pool;
129 VkPipelineCache m_model_pipeline_cache;
130 uint04 m_num_of_images;
131 uint04 m_num_of_materials;
132 uint04 m_num_of_cameras;
133
134 UUID m_uuid;
135 bool m_needs_pipeline_update = false;
136 //bool m_is_grab_pipeline;
137 //uint04 m_model_descriptor_pool_size;
138 };
139}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
A GraphicsPipeline that is responsible for setting up and rendering the resources of a DesignObjectLo...
Options that are used for performing an update on a Graphics Engine call.
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
The root Model that is responsible for storing the underlying data for all Scene Models.
Definition Scene.h:52
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
static UUID CreateUUID()
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
A structure for managing Viewport interactions with in the Vulkan Graphics Space.
Logic for creating the data in Vulkan for a specific Material.
Creates specific information for performing a render pass within Vulkan.
A root render Object for Vulkan, which consists of a set Material, Model, and Geometry that is used t...
virtual void postClearAll() final override
Called after all scene objects have been cleared.
void updateUniformBuffer(GraphicsUpdateArguments &args) final override
Updates the camera uniform buffer on the GPU.
void removeRenderGeometry(const Geometry &geo) override
Removes a geometry from rendering.
bool createPipeline(GraphicsUpdateArguments &args) final override
Creates or recreates the rendering pipeline.
virtual const ConstPointer< GraphicsDevice > & device() const final override
Returns the graphics device (const).
virtual UUID uuid() final override
Returns the unique identifier for this session.
void cleanup() final override
Releases all GPU resources.
virtual void drawFrame(GraphicsUpdateArguments &) final override
Renders a single frame.
void commit(GraphicsUpdateArguments &args) final override
Commits pending changes to the GPU.
bool addRenderGeometry(const Geometry &geo) override
Adds a geometry for rendering.
virtual void setWindowInstance(WindowInstance *) final override
Associates a window instance with this pipeline.
bool runCommand(GraphicsUpdateArguments &args) final override
Executes a queued rendering command.
bool hasCommand() const override
Checks whether there are pending commands to execute.
virtual void ensureLastRenderComplete() final override
Blocks until the last submitted render is complete.
virtual const DynamicPointer< GraphicsDevice > & device() final override
Returns the graphics device.
virtual void init(GraphicsUpdateArguments &) final override
Initializes the pipeline with the given arguments.
virtual void cleanResources() final override
Cleans up stale or unused GPU resources.
RasterizerType
Types of rasterizer configurations used during rendering.
@ e_filled_cull_cw
Filled polygons with clockwise face culling.
@ e_outline
Outline/wireframe rendering.
@ e_filled_cull_ccw
Filled polygons with counter-clockwise face culling.
@ e_filled_cull_none
Filled polygons with no face culling.
@ e_size
The number of rasterizer types (sentinel).
DynamicPointer< GraphicsPipeline > createRenderPipeline() final override
Creates a new render pipeline for a viewport.
Manages all active shaders in a VulkanSession.
Manages all vertices in a specific Scene object for interfacing with Vulkan.
Contains core information about a Viewport.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Tracks a geometry and its last modification time for incremental updates.