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
66 {
67 struct ModelMatrixUniformObject
68 {
69 Matrix<fltp04> model_transform = Matrix<fltp04>(1);
70 Vector<3, sint04> model_offset = Vector<3, sint04>(0);
72 RGBColor custom_color = Constant<RGBColor>::NaN;
73 bool operator==(const ModelMatrixUniformObject& object) const
74 {
75 return model_transform == object.model_transform
76 && flags == object.flags
77 && model_offset == object.model_offset
78 && custom_color == object.custom_color;
79 }
80 bool operator!=(const ModelMatrixUniformObject& object) const
81 {
82 return model_transform != object.model_transform || flags != object.flags || model_offset != object.model_offset || custom_color != object.custom_color;
83 }
84 };
85 protected:
110
111 public:
113 VulkanRenderObject(const VulkanRenderObject& instance);
115 void cleanup();
116
117 VkPipeline getPipeline() { return m_graphics_pipeline; }
118 void setDevice(const DynamicPointer<VulkanDevice>& instance);
121 bool hasOpacity() const;
122 bool hasImage() const;
123 fltp04 fadeDistance() const;
124 uint01 parity() const { return m_parity; }
125
127
129
130 //void resetPool() { m_descriptor_pool = nullptr; }
131 bool hasCommand() const;
132 bool runCommand(GraphicsUpdateArguments& args, VkDescriptorSet camera_descriptor);
133 bool isFilledShape() const;
134
135 void setGraphicsPipeline(VkPipeline m_pipeline);
138 void setPrimitiveMode(const PrimitiveMode& type) { m_index_mode = type; }
139 void setIndexProperty(const PrimitiveProperty& property) { m_index_property = property; }
140 void setVertexManager(const DynamicPointer<VulkanVertexManager>& vertex_manager);
141 void setMaterialManager(const DynamicPointer<VulkanMaterialManager>& material_manager);
142 void setParity(uint01 parity);
143 const ConstPointer<VulkanMaterialManager>& materialManager() const { return m_material_manager;}
144 const ConstPointer<VulkanVertexManager>& vertexManager() const { return m_vertex_manager; }
145 PrimitiveMode indexMode() const { return m_index_mode; };
146 PrimitiveProperty indexProperty() const { return m_index_property; };
147 void addInstance(const Geometry& geo, const Model& parent, const Material& material);
148 void clearInstances();
149
150
151
152 //static VkDescriptorSetLayout_T* descriptorSetLayout(ConstPointer<VulkanDevice> instance);
153 static VkPipelineLayout pipelineLayout(ConstPointer<VulkanDevice> instance);
154 private:
155 void drawInstances(uint04 start, uint04 size, uint04 mesh_index, const GraphicsUpdateArguments& args, bool& is_index_bound);
156 void processGeoUniformUpdates(GeoProperties& properties, GraphicsUpdateArguments& args, uint04& matrix_index, Buffer<Model>& models_to_re_add, const Time& geo_mod_time);
157
158
159 //ExtraPropertySettings getExtraProperty(const GraphicsUpdateArguments& args) const;
160 VulkanBitflagObject getBitflagObject(const Geometry& mesh, const Model& model, const GraphicsUpdateArguments& args) const;
161 //void createDescriptorSet(VkDescriptorPool_T* pool, bool is_new_pool);
162
163 Buffer<bool> getExclusionList(const GraphicsUpdateArguments& args) const;
164 Buffer<ModelMatrixUniformObject> getMatrixUniformObject(const GraphicsUpdateArguments& args) const;
165 ModelMatrixUniformObject getMatrixUniformObject(const GraphicsUpdateArguments& args, const Geometry& mesh, const Model& model) const;
166 private:
169 PrimitiveProperty m_index_property;
170 PrimitiveMode m_index_mode;
171 Buffer<GeoProperties> m_geometries;
172 Dictionary<UUID, uint04> m_geometry_lookup;
173 //ExtraPropertySettings m_extra_settings;
174
175 //DynamicPointer<VulkanBuffer> m_bitf_uniform_buffer;
177 ConstPointer<VulkanMaterialManager> m_material_manager;
180
181 Buffer<ModelMatrixUniformObject> m_model_matrix_uniforms;
182 DynamicPointer<VulkanBuffer> m_matrix_instance_buffer;
183
185
186 VkPipeline m_graphics_pipeline;
187 //VkDescriptorPool_T* m_descriptor_pool;
188 //VkDescriptorSet_T* m_descriptor_set;
189
190 Time m_last_updated_time;
191 volatile mutable bool m_needs_matrix_commit;
192 //volatile mutable bool m_needs_bitf_commit;
193 uint01 m_parity;
194 };
195}
196bool operator!=(const VkVertexInputAttributeDescription& a, const VkVertexInputAttributeDescription& b);
197bool operator!=(const VkVertexInputBindingDescription& a, const VkVertexInputBindingDescription& b);
198bool operator==(const VkVertexInputAttributeDescription& a, const VkVertexInputAttributeDescription& b);
199bool operator==(const VkVertexInputBindingDescription& a, const VkVertexInputBindingDescription& b);
#define DEFINE_NON_DISPATCHABLE_HANDLE(object)
Definition VulkanInstance.h:49
bool operator!=(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
Definition VulkanRenderObject.cpp:10
bool operator==(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
Definition VulkanRenderObject.cpp:18
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 Dictionary.h:48
Definition Pointer.hpp:303
Definition Geometry.h:64
Definition GraphicsUpdateArguments.h:40
Definition Material.h:45
Definition Matrix.hpp:173
Definition Model.h:54
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 VulkanRenderObject.h:66
bool hasOpacity() const
Definition VulkanRenderObject.cpp:590
bool hasImage() const
Definition VulkanRenderObject.cpp:595
void setMaterialManager(const DynamicPointer< VulkanMaterialManager > &material_manager)
Definition VulkanRenderObject.cpp:810
PrimitiveMode indexMode() const
Definition VulkanRenderObject.h:145
void clearInstances()
Definition VulkanRenderObject.cpp:376
const ConstPointer< VulkanMaterialManager > & materialManager() const
Definition VulkanRenderObject.h:143
uint01 parity() const
Definition VulkanRenderObject.h:124
bool isFilledShape() const
Definition VulkanRenderObject.cpp:508
void cleanup()
Definition VulkanRenderObject.cpp:339
static VkPipelineLayout pipelineLayout(ConstPointer< VulkanDevice > instance)
Definition VulkanRenderObject.cpp:706
fltp04 fadeDistance() const
Definition VulkanRenderObject.cpp:600
void commit(GraphicsUpdateArguments &args)
Definition VulkanRenderObject.cpp:327
Buffer< VkVertexInputBindingDescription, uint04, ObjectAllocator< true > > bindingDescriptions(GraphicsUpdateArguments &args) const
Definition VulkanRenderObject.cpp:749
void setPrimitiveMode(const PrimitiveMode &type)
Definition VulkanRenderObject.h:138
void addInstance(const Geometry &geo, const Model &parent, const Material &material)
Definition VulkanRenderObject.cpp:359
Buffer< VkVertexInputAttributeDescription, uint04, ObjectAllocator< true > > attributeDescriptions(GraphicsUpdateArguments &args) const
Definition VulkanRenderObject.cpp:740
PrimitiveProperty indexProperty() const
Definition VulkanRenderObject.h:146
void setVertexManager(const DynamicPointer< VulkanVertexManager > &vertex_manager)
Definition VulkanRenderObject.cpp:805
void setGraphicsPipeline(VkPipeline m_pipeline)
Definition VulkanRenderObject.cpp:733
void updateUniformBuffer(GraphicsUpdateArguments &args)
Definition VulkanRenderObject.cpp:176
VkPipeline getPipeline()
Definition VulkanRenderObject.h:117
bool hasCommand() const
Definition VulkanRenderObject.cpp:385
bool createPipeline(GraphicsUpdateArguments &args)
Definition VulkanRenderObject.cpp:605
VulkanRenderObject(const ConstPointer< VulkanDevice > &pipeline)
Definition VulkanRenderObject.cpp:28
~VulkanRenderObject()
Definition VulkanRenderObject.cpp:52
void setDevice(const DynamicPointer< VulkanDevice > &instance)
Definition VulkanRenderObject.cpp:170
Buffer< VkPipelineShaderStageCreateInfo, uint04, ObjectAllocator< true > > getShaderCreateInfo() const
Definition VulkanRenderObject.cpp:349
void setIndexProperty(const PrimitiveProperty &property)
Definition VulkanRenderObject.h:139
bool runCommand(GraphicsUpdateArguments &args, VkDescriptorSet camera_descriptor)
Definition VulkanRenderObject.cpp:392
void setParity(uint01 parity)
Definition VulkanRenderObject.cpp:815
const ConstPointer< VulkanVertexManager > & vertexManager() const
Definition VulkanRenderObject.h:144
Definition ACIColor.h:37
PrimitiveProperty
Definition DesignObjectBase.h:44
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
PrimitiveMode
Definition DesignObjectBase.h:113
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
QAction * mesh(nullptr)
Definition BaseValues.hpp:272
Definition VulkanBitflagObject.h:38
Definition VulkanRenderObject.h:97
bool is_visible
Definition VulkanRenderObject.h:108
fltp04 pixel_thickness
Definition VulkanRenderObject.h:103
uint04 vertex_start
Definition VulkanRenderObject.h:104
GeoProperties(const Geometry &geo)
Definition VulkanRenderObject.h:98
Geometry geometry
Definition VulkanRenderObject.h:102
uint04 vertex_size
Definition VulkanRenderObject.h:105
uint04 index_start
Definition VulkanRenderObject.h:106
uint04 index_size
Definition VulkanRenderObject.h:107
Buffer< ModelProperties > model_parents
Definition VulkanRenderObject.h:101
Definition VulkanRenderObject.h:87
bool is_visible
Definition VulkanRenderObject.h:94
Material material
Definition VulkanRenderObject.h:93
Model model
Definition VulkanRenderObject.h:92
ModelProperties(const Model &model, const Material &material)
Definition VulkanRenderObject.h:88