API Documentation
Loading...
Searching...
No Matches
VulkanRenderObject.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: VulkanRenderObject
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "VulkanDefines.h"
34#include "VulkanImage.h"
35#include "VulkanBuffer.h"
36#include "VulkanBitflagObject.h"
44
45
46struct VkCommandBuffer_T;
47struct VkDescriptorSetLayout_T;
48struct VkDescriptorPool_T;
49struct VkDescriptorSet_T;
50struct VkSampler_T;
51struct VkVertexInputAttributeDescription;
52struct VkVertexInputBindingDescription;
53struct VkPipelineShaderStageCreateInfo;
54
57
58namespace NDEVR
59{
60 class Camera;
61 class VulkanVertexManager;
62 class VulkanMaterialManager;
63
64 /**--------------------------------------------------------------------------------------------------
65 \brief A root render Object for Vulkan, which consists of a set Material, Model, and Geometry that
66 is used together to optimally create a 3D render.
67 **/
69 {
70 struct ModelMatrixUniformObject
71 {
72 Matrix<fltp04> model_transform = Matrix<fltp04>(1);
73 Vector<3, sint04> model_offset = Vector<3, sint04>(0);
76 bool operator==(const ModelMatrixUniformObject& object) const
77 {
78 return model_transform == object.model_transform
79 && flags == object.flags
80 && model_offset == object.model_offset
81 && custom_color == object.custom_color;
82 }
83 bool operator!=(const ModelMatrixUniformObject& object) const
84 {
85 return model_transform != object.model_transform || flags != object.flags || model_offset != object.model_offset || custom_color != object.custom_color;
86 }
87 };
88 protected:
113
114 public:
118 void cleanup();
119
120 VkPipeline getPipeline() { return m_graphics_pipeline; }
124 bool hasOpacity() const;
125 bool hasImage() const;
127 uint01 parity() const { return m_parity; }
128
130
132
133 //void resetPool() { m_descriptor_pool = nullptr; }
134 bool hasCommand() const;
135 bool runCommand(GraphicsUpdateArguments& args, VkDescriptorSet camera_descriptor);
136 bool isFilledShape() const;
137
141 void setPrimitiveMode(const PrimitiveMode& type) { m_index_mode = type; }
142 void setIndexProperty(const PrimitiveProperty& property) { m_index_property = property; }
146 const ConstPointer<VulkanMaterialManager>& materialManager() const { return m_material_manager;}
147 const ConstPointer<VulkanVertexManager>& vertexManager() const { return m_vertex_manager; }
148 PrimitiveMode indexMode() const { return m_index_mode; };
149 PrimitiveProperty indexProperty() const { return m_index_property; };
150 void addInstance(const Geometry& geo, const Model& parent, const Material& material);
152
153
154
155 //static VkDescriptorSetLayout_T* descriptorSetLayout(ConstPointer<VulkanDevice> instance);
157 private:
158 void drawInstances(uint04 start, uint04 size, uint04 mesh_index, const GraphicsUpdateArguments& args, bool& is_index_bound);
159 void processGeoUniformUpdates(GeoProperties& properties, GraphicsUpdateArguments& args, uint04& matrix_index, Buffer<Model>& models_to_re_add, const Time& geo_mod_time);
160
161
162 //ExtraPropertySettings getExtraProperty(const GraphicsUpdateArguments& args) const;
163 VulkanBitflagObject getBitflagObject(const Geometry& mesh, const Model& model, const GraphicsUpdateArguments& args) const;
164 //void createDescriptorSet(VkDescriptorPool_T* pool, bool is_new_pool);
165
166 Buffer<bool> getExclusionList(const GraphicsUpdateArguments& args) const;
167 Buffer<ModelMatrixUniformObject> getMatrixUniformObject(const GraphicsUpdateArguments& args) const;
168 ModelMatrixUniformObject getMatrixUniformObject(const GraphicsUpdateArguments& args, const Geometry& mesh, const Model& model) const;
169 private:
172 PrimitiveProperty m_index_property;
173 PrimitiveMode m_index_mode;
174 Buffer<GeoProperties> m_geometries;
175 Dictionary<UUID, uint04> m_geometry_lookup;
176 //ExtraPropertySettings m_extra_settings;
177
178 //DynamicPointer<VulkanBuffer> m_bitf_uniform_buffer;
180 ConstPointer<VulkanMaterialManager> m_material_manager;
183
184 Buffer<ModelMatrixUniformObject> m_model_matrix_uniforms;
185 DynamicPointer<VulkanBuffer> m_matrix_instance_buffer;
186
188
189 VkPipeline m_graphics_pipeline;
190 //VkDescriptorPool_T* m_descriptor_pool;
191 //VkDescriptorSet_T* m_descriptor_set;
192
193 Time m_last_updated_time;
194 volatile mutable bool m_needs_matrix_commit;
195 //volatile mutable bool m_needs_bitf_commit;
196 uint01 m_parity;
197 };
198}
199bool operator!=(const VkVertexInputAttributeDescription& a, const VkVertexInputAttributeDescription& b);
200bool operator!=(const VkVertexInputBindingDescription& a, const VkVertexInputBindingDescription& b);
201bool operator==(const VkVertexInputAttributeDescription& a, const VkVertexInputAttributeDescription& b);
202bool operator==(const VkVertexInputBindingDescription& a, const VkVertexInputBindingDescription& b);
uint64_t VkDescriptorSet
Definition VulkanCameraManager.h:41
#define DEFINE_NON_DISPATCHABLE_HANDLE(object)
Definition VulkanInstance.h:49
uint64_t VkPipelineLayout
Definition VulkanRenderObject.h:56
bool operator!=(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
uint64_t VkPipeline
Definition VulkanRenderObject.h:55
bool operator==(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
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
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
A core class within the model heirarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:64
Options that are used for performing an update on a Graphics Engine call.
Definition GraphicsUpdateArguments.h:43
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:51
Definition Matrix.hpp:176
A core class that represents a node on model heirarchy. This node may contain a Geometry or one or mo...
Definition Model.h:58
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 root render Object for Vulkan, which consists of a set Material, Model, and Geometry that is used t...
Definition VulkanRenderObject.h:69
void setMaterialManager(const DynamicPointer< VulkanMaterialManager > &material_manager)
PrimitiveMode indexMode() const
Definition VulkanRenderObject.h:148
const ConstPointer< VulkanMaterialManager > & materialManager() const
Definition VulkanRenderObject.h:146
VulkanRenderObject(const VulkanRenderObject &instance)
uint01 parity() const
Definition VulkanRenderObject.h:127
fltp04 fadeDistance() const
void commit(GraphicsUpdateArguments &args)
Buffer< VkVertexInputBindingDescription, uint04, ObjectAllocator< true > > bindingDescriptions(GraphicsUpdateArguments &args) const
void setPrimitiveMode(const PrimitiveMode &type)
Definition VulkanRenderObject.h:141
void addInstance(const Geometry &geo, const Model &parent, const Material &material)
Buffer< VkVertexInputAttributeDescription, uint04, ObjectAllocator< true > > attributeDescriptions(GraphicsUpdateArguments &args) const
PrimitiveProperty indexProperty() const
Definition VulkanRenderObject.h:149
static VkPipelineLayout pipelineLayout(ConstPointer< VulkanDevice > instance)
void setVertexManager(const DynamicPointer< VulkanVertexManager > &vertex_manager)
void setGraphicsPipeline(VkPipeline m_pipeline)
void updateUniformBuffer(GraphicsUpdateArguments &args)
VkPipeline getPipeline()
Definition VulkanRenderObject.h:120
bool createPipeline(GraphicsUpdateArguments &args)
VulkanRenderObject(const ConstPointer< VulkanDevice > &pipeline)
void setDevice(const DynamicPointer< VulkanDevice > &instance)
Buffer< VkPipelineShaderStageCreateInfo, uint04, ObjectAllocator< true > > getShaderCreateInfo() const
void setIndexProperty(const PrimitiveProperty &property)
Definition VulkanRenderObject.h:142
bool runCommand(GraphicsUpdateArguments &args, VkDescriptorSet camera_descriptor)
void setParity(uint01 parity)
const ConstPointer< VulkanVertexManager > & vertexManager() const
Definition VulkanRenderObject.h:147
Definition ACIColor.h:37
PrimitiveProperty
Definition DesignObjectBase.h:44
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
PrimitiveMode
Used with Geometry to describe how vertices and indices are used to form shapes.
Definition DesignObjectBase.h:116
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
Stores bools to be sent to both the Vertex and Fragment shaders in the Vulkan space.
Definition VulkanBitflagObject.h:41
Definition VulkanRenderObject.h:100
bool is_visible
Definition VulkanRenderObject.h:111
fltp04 pixel_thickness
Definition VulkanRenderObject.h:106
uint04 vertex_start
Definition VulkanRenderObject.h:107
GeoProperties(const Geometry &geo)
Definition VulkanRenderObject.h:101
Geometry geometry
Definition VulkanRenderObject.h:105
uint04 vertex_size
Definition VulkanRenderObject.h:108
uint04 index_start
Definition VulkanRenderObject.h:109
uint04 index_size
Definition VulkanRenderObject.h:110
Buffer< ModelProperties > model_parents
Definition VulkanRenderObject.h:104
Definition VulkanRenderObject.h:90
bool is_visible
Definition VulkanRenderObject.h:97
Material material
Definition VulkanRenderObject.h:96
Model model
Definition VulkanRenderObject.h:95
ModelProperties(const Model &model, const Material &material)
Definition VulkanRenderObject.h:91