33#include "VulkanDefines.h"
34#include "VulkanImage.h"
35#include "VulkanBuffer.h"
36#include "VulkanBitflagObject.h"
37#include "NDEVRGraphics/Headers/GraphicsUpdateArguments.h"
38#include "Design/Headers/Material.h"
39#include "Design/Headers/Geometry.h"
40#include "Design/Headers/Model.h"
41#include "Base/Headers/Pointer.hpp"
42#include "Base/Headers/RGBColor.h"
43#include "Base/Headers/Bounds.hpp"
46struct VkCommandBuffer_T;
47struct VkDescriptorSetLayout_T;
48struct VkDescriptorPool_T;
49struct VkDescriptorSet_T;
51struct VkVertexInputAttributeDescription;
52struct VkVertexInputBindingDescription;
53struct VkPipelineShaderStageCreateInfo;
55DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline);
56DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout);
69 class VulkanRenderObject
72 struct ModelMatrixUniformObject
77 RGBColor custom_color = Constant<RGBColor>::Invalid;
78 bool operator==(
const ModelMatrixUniformObject&
object)
const
80 return model_transform ==
object.model_transform
81 && flags ==
object.flags
82 && model_offset ==
object.model_offset
83 && custom_color ==
object.custom_color;
85 bool operator!=(
const ModelMatrixUniformObject&
object)
const
87 return model_transform !=
object.model_transform
88 || flags !=
object.flags
89 || model_offset !=
object.model_offset
90 || custom_color !=
object.custom_color;
128 VulkanRenderObject(
const VulkanRenderObject&) =
delete;
129 ~VulkanRenderObject();
131 VkPipeline getPipeline() {
return m_graphics_pipeline; }
134 bool hasOpacity()
const;
135 bool hasImage()
const;
136 bool hasParity()
const;
137 fltp04 fadeDistance()
const;
138 bool hasTangent()
const {
return m_has_tangent; }
139 bool createPipeline(GraphicsUpdateArguments& args);
141 bool runCommand(GraphicsUpdateArguments& args, VkDescriptorSet camera_descriptor);
142 bool runCommandPass(GraphicsUpdateArguments& args,
uint01 parity)
const;
143 bool isFilledShape()
const;
144 void setGraphicsPipeline(VkPipeline pipeline);
145 bool hasActiveGeo()
const;
146 void setParityGraphicsPipeline(VkPipeline pipeline);
147 Vector<2, VkPipelineShaderStageCreateInfo> getShaderCreateInfo()
const;
148 const PrimitiveBuffer<VkVertexInputAttributeDescription>& getAttributeDescriptions()
const;
149 const PrimitiveBuffer<VkVertexInputBindingDescription>& getBindingDescriptions()
const;
150 const ConstPointer<VulkanMaterialManager>& materialManager()
const {
return m_material_manager; }
151 const ConstPointer<VulkanVertexManager>& vertexManager()
const {
return m_vertex_manager; }
152 PrimitiveMode primitiveMode()
const {
return m_index_mode; };
155 void setPrimitiveProperty(
const PrimitiveProperty& property) { m_index_property = property; }
156 void setVertexManager(
const DynamicPointer<VulkanVertexManager>& vertex_manager);
157 void setMaterialManager(
const DynamicPointer<VulkanMaterialManager>& material_manager);
158 void setHasTangent(
bool has_tangent);
159 void addInstance(
const Geometry& geo);
160 bool removeInstance(
const Geometry& geo);
161 void setMaterial(
const Material& material);
162 void clearInstances();
163 void updateVertexBuffers(GraphicsUpdateArguments& args,
bool can_reallocate =
true);
164 bool needsPipelineUpdate()
const {
return m_needs_pipeline_update; }
165 void finishUpdatingPipeline() { m_needs_pipeline_update =
false; }
167 static VkPipelineLayout PipelineLayout(ConstPointer<VulkanDevice> instance);
169 bool computeHasActiveGeo();
170 void drawInstances(
uint04 start,
uint04 size,
const GeoProperties& geo,
const GraphicsUpdateArguments& args,
bool& is_index_bound)
const;
171 VulkanBitflagObject getBitflagObject(
const Geometry& mesh,
const Model& model)
const;
173 bool getExclusionList(GraphicsUpdateArguments& args,
uint01 parity)
const;
174 void updateBufferCache(GraphicsUpdateArguments& args);
175 void updateModelParents(
uint04 geo_index,
uint04& matrix_idx);
176 ModelMatrixUniformObject getMatrixUniformObject(
const Geometry& geo,
const Model& model)
const;
177 PrimitiveBuffer<VkVertexInputAttributeDescription>& calculateAttributeDescriptions(PrimitiveBuffer<VkVertexInputAttributeDescription>& buffer, GraphicsUpdateArguments& args)
const;
178 PrimitiveBuffer<VkVertexInputBindingDescription>& calculateBindingDescriptions(PrimitiveBuffer<VkVertexInputBindingDescription>& buffer, GraphicsUpdateArguments& args)
const;
180 Time m_last_buffer_time = Time(0);
184 Set<Geometry> m_added_geos;
185 Buffer<GeoProperties> m_geometries;
187 String m_extra_property;
189 DynamicPointer<VulkanVertexManager> m_vertex_manager;
190 ConstPointer<VulkanMaterialManager> m_material_manager;
191 PrimitiveBuffer<VkVertexInputAttributeDescription> m_attribute_descriptions;
192 mutable PrimitiveBuffer<VkVertexInputAttributeDescription> m_attribute_descriptions_buffer;
193 PrimitiveBuffer<VkVertexInputBindingDescription> m_binding_descriptions;
194 mutable PrimitiveBuffer<VkVertexInputBindingDescription> m_binding_descriptions_buffer;
195 VkBuffer m_vertex_buffers[9];
196 Buffer<ModelMatrixUniformObject> m_model_matrix_uniforms;
197 DynamicPointer<VulkanBuffer> m_matrix_instance_buffer;
198 ConstPointer<VulkanDevice> m_instance;
199 VkPipeline m_graphics_pipeline;
200 VkPipeline m_parity_pipeline;
201 uint04 m_matrix_index_offset = 0;
203 uint08 m_buffer_update_idx = Constant<uint08>::Invalid;
204 bool m_has_tangent =
false;
205 bool m_has_parity =
false;
206 volatile mutable bool m_needs_matrix_commit;
207 volatile mutable bool m_needs_pipeline_update =
true;
208 bool m_has_instance_difference =
false;
209 bool m_needs_command_refresh =
false;
210 bool m_has_active_geo =
false;
213bool operator!=(
const VkVertexInputAttributeDescription& a,
const VkVertexInputAttributeDescription& b);
214bool operator!=(
const VkVertexInputBindingDescription& a,
const VkVertexInputBindingDescription& b);
215bool operator==(
const VkVertexInputAttributeDescription& a,
const VkVertexInputAttributeDescription& b);
216bool operator==(
const VkVertexInputBindingDescription& a,
const VkVertexInputBindingDescription& b);
The equivelent of std::vector but with a bit more control.
A core object representing a user view as well as convenience functions for moving this view through ...
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Options that are used for performing an update on a Graphics Engine call.
Templated logic for doing matrix multiplication.
A core class that represents a node on model hierarchy.
bool isVisible() const
Checks whether this model is visible (accounting for inherited visibility).
Represents a color in the RGB space with optional alpha transparency.
Represents a timestamp with utilities for manipulation and conversion.
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Logic for creating the data in Vulkan for a specific Material.
Manages all vertices in a specific Scene object for interfacing with Vulkan.
The primary namespace for the NDEVR SDK.
@ type
The type identifier string for this model node.
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Inequality operator.
PrimitiveMode
Used with Geometry to describe how vertices and indices are used to form shapes.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
NDPO
NDPO - NDEVR Design Property Object: Values stored in the property database.
@ guid
A 128-bit globally unique identifier for the object.
PrimitiveProperty
Describes which rendering property a primitive index buffer corresponds to.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Stores bools to be sent to both the Vertex and Fragment shaders in the Vulkan space.
Cached properties of a Geometry instance within this render object.
Time modified_time
Last modification time of this geometry.
Buffer< ModelProperties > model_parents
Properties of all parent models.
uint04 index_size
Number of indices.
Geometry geometry
The geometry object reference.
uint04 vertex_start
Start index in the vertex buffer.
bool is_deleted
Whether this geometry has been deleted.
uint04 vertex_size
Number of vertices.
uint04 index_start
Start index in the index buffer.
bool is_visible
Whether this geometry is visible.
fltp04 pixel_thickness
Line/point thickness in pixels.
GeoProperties(const Geometry &geo)
Constructs geometry properties from a Geometry object.
uint01 parity
Parity flag for culling direction.
Time updated_time
Last time these properties were updated.
ModelProperties(const Model &model)
Constructs model properties from a Model object.
UUID model_id
UUID of the parent model.
bool is_visible
Whether the parent model is visible.