NDEVR
API Documentation
VulkanVertexManager.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: VulkanVertexManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "VulkanDefines.h"
34#include "VulkanBuffer.h"
35#include "VulkanShader.h"
36#include <NDEVR/DesignObjectBase.h>
37enum VkIndexType;
38struct VkVertexInputAttributeDescription;
39struct VkVertexInputBindingDescription;
40struct VkPipelineShaderStageCreateInfo;
41namespace NDEVR
42{
43 class Scene;
49 class VulkanVertexManager
50 {
51 public:
52 VulkanVertexManager(const ConstPointer<VulkanDevice>& device);
53 VulkanVertexManager(const VulkanVertexManager& m_pipeline) = delete;
54 ~VulkanVertexManager();
55 uint08 bufferHash() const { lib_assert(calculateBufferHash() == m_buffer_hash, "Invalid buffer hash"); return m_buffer_hash; }
56 Time lastUpdateTime() const { return m_last_updated_time; }
57 Time lastBufferUpdateTime() const { return m_last_buffer_update_time; }
58 uint08 calculateBufferHash() const;
59 void updateUniformBuffer(GraphicsUpdateArguments& args);
60 bool needsPipelineUpdate() const { return m_needs_pipeline_update; }
61 void setScene(const Scene& scene);
62 void commit();
63 void updateExtraBuffer(GraphicsUpdateArguments& args, const StringView& extra_property, bool can_rebuild);
64 void updateExtraBuffer(GraphicsUpdateArguments& args, const Scene& scene, const StringView& extra_property, bool can_rebuild);
65 void getRenderBuffers(VkBuffer* vertex_buffers, GraphicsUpdateArguments& args, const StringView& extra_property) const;
66 VkIndexType indexType() const;
67 void getAttributeDescriptions(PrimitiveBuffer<VkVertexInputAttributeDescription>& descriptions, GraphicsUpdateArguments& args, const StringView& extra_property, uint04 offset) const;
68 void getBindingDescriptions(PrimitiveBuffer<VkVertexInputBindingDescription>& buffer, GraphicsUpdateArguments& args, const StringView& extra_property, uint04 offset) const;
69 VkPipelineShaderStageCreateInfo getShaderCreateInfo(VulkanShaderManager::ShaderType shader_type) const;
71 VulkanShaderManager::ShaderType getShaderType(PrimitiveMode mode, bool has_grid, bool has_image, bool simple_allowed, bool has_tangent) const;
72 ConstPointer<GraphicsBuffer> indexBuffer() const;
73 BitFlag vertexFlags() const { return m_vertex_flags; };
74 void createPipeline(GraphicsUpdateArguments& args, DynamicPointer<VulkanShaderManager>& shader_manager);
75 void updateBuffers(GraphicsUpdateArguments& args);
76#ifdef VULKAN_FAN_CONVERSION
77 void setFanToStripBounds(UUID bounds_id, const Bounds<1, uint04>& bounds);
78 void clearFanToStripBounds();
79 void removeFanToStripBounds(UUID bounds_id);
80#endif
81 VkVertexInputBindingDescription getExtraDescription(const Scene& scene, const StringView& channel, uint04 offset) const;
82 VkVertexInputAttributeDescription getAttribute(const Scene& scene, const StringView& channel, uint04 offset) const;
83 ConstPointer<GraphicsBuffer> getRenderBuffer(const Scene& scene, const StringView& channel) const;
84 uint04 vertexSize() const { return m_vertex_buffer[cast<uint04>(VertexProperty::Position)]->size(); }
85 UUID scene() const { return m_scene; }
86 protected:
87 UUID m_scene;
88
89 void updateShader(DynamicPointer<VulkanShaderManager>& shader_manager);
90 void updateBuffer(const Scene& scene, GraphicsUpdateArguments& args, bool can_rebuild);
91 void updateIndexBuffer(const Scene& scene, bool can_rebuild);
92 void updateVertexBuffer(const Scene& scene, VertexProperty property, bool can_rebuild);
94 mutable DynamicPointer<GraphicsBuffer> m_index_buffer;
96 mutable bool m_using_vertex_buffer[cast<uint04>(VertexProperty::BitFlag) + 1] = {false, false, false, false, false, false};
99 Time m_last_updated_time;
100 Time m_last_buffer_update_time = Time(0);
101 uint08 m_buffer_hash;
102 BitFlag m_vertex_flags;
103 bool m_needs_pipeline_update = true;
104 bool m_needs_buffer_update = true;
105 bool m_needs_index_buffer_update = false;
106#ifdef VULKAN_FAN_CONVERSION
107 Dictionary<UUID, Bounds<1, uint04>> m_fan_to_strip_sections;
108#endif
109 };
110}
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
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
Options that are used for performing an update on a Graphics Engine call.
The root Model that is responsible for storing the underlying data for all Scene Models.
Definition Scene.h:52
The core String View class for the NDEVR API.
Definition StringView.h:58
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
ShaderType
The types of shaders available for rendering different primitives.
The primary namespace for the NDEVR SDK.
VertexProperty
Per-vertex data channels that can be stored in the vertex table to be used by Geometry.
@ Position
XYZ position of the vertex.
@ BitFlag
Per-vertex bit flags (selected, hidden, etc.).
PrimitiveMode
Used with Geometry to describe how vertices and indices are used to form shapes.
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...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Definition Angle.h:408