API Documentation
Loading...
Searching...
No Matches
VulkanMaterialManager.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: VulkanMaterialManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "VulkanDefines.h"
34#include "VulkanDefines.h"
35#include "VulkanBuffer.h"
36#include "VulkanImage.h"
37#include "VulkanShader.h"
38#include "VulkanBitflagObject.h"
41struct VkWriteDescriptorSet;
42struct VkDescriptorImageInfo;
43struct VkPipelineShaderStageCreateInfo;
48namespace NDEVR
49{
50 class GraphicsUpdateArguments;
51 /**--------------------------------------------------------------------------------------------------
52 \brief Information sent to the Vertex shader as a Uniform object
53 **/
61 static_assert(sizeof(VulkanVertexUniformObject) == 16, "Bad VertexUniformSize");
62#pragma pack(push, 1)
63 /**--------------------------------------------------------------------------------------------------
64 \brief Information sent to the Fragmentation shader as a uniform object
65 **/
107 //static_assert(sizeof(FragUniformObject) == 176, "Bad UniformSize");
108 static_assert(sizeof(FragUniformObject) == 176, "Bad FragUniformSize");
109#pragma pack(pop)
110 /**--------------------------------------------------------------------------------------------------
111 \brief Logic for creating the data in Vulkan for a specific Material.
112 **/
114 {
115 public:
117 VulkanMaterialManager(const VulkanMaterialManager& m_pipeline) = delete;
119
120 void cleanup();
123 bool hasGrid() const { return m_has_grid; }
132 bool hasOpacity() const { return m_has_opacity; }
133 bool ignoreDepth() const { return m_ignore_depth; }
134 bool writeToDepth() const { return m_write_to_depth; }
135 bool isDynamic() const { return m_is_dynamic; }
136 bool usesModelColor() const { return m_use_model_color; }
137 bool usesLayerColor() const { return m_use_layer_color; }
139 fltp04 depthBias() const { return m_depth_bias; }
140 bool hasImage() const;
141 void commit();
143
145
147
149
150 //void setFragmentShader(const Pointer<Shader>& shader) { m_fragment_shader = shader; }
152 void getShaderCreateInfo(PrimitiveMode property, Buffer<VkPipelineShaderStageCreateInfo, uint04, ObjectAllocator<true>>& buffer) const;
154
156 {
157 return m_descriptor_set;
158 }
159
160
162 UUID material() const;
163 bool isTwoSided() const { return m_is_two_sided; }
164 bool isWireframe() const { return m_is_wireframe; }
165 bool overrideCamera() const { return m_override_camera; }
167 bool useLighting() const;
168 bool smoothNormals() const;
171 UUID id() const;
173 protected:
174
176 void getDescriptorWrites(Buffer<VkWriteDescriptorSet, uint04, ObjectAllocator<true>>& descriptor_writes, Buffer<VkDescriptorImageInfo, uint04, ObjectAllocator<true>>& image_info) const;
177
182
184
185
186 protected:
187
188
194
197
200
201 //ConstPointer<Shader> m_fragment_shader;
202
207
209
211
212
216
221
222 mutable bool m_needs_to_commit_frag_buffer = true;
223 mutable bool m_needs_to_commit_vert_buffer = true;
225 bool m_has_opacity = false;
226 bool m_has_image = false;
228 bool m_is_two_sided = false;
229 bool m_override_camera = false;
230 bool m_smooth_normals = false;
231 bool m_is_wireframe = false;
232 bool m_is_dynamic = false;
233 bool m_has_grid = false;
235 bool m_use_model_color = false;
236 bool m_use_layer_color = false;
237 bool m_ignore_depth = false;
238 bool m_write_to_depth = true;
241 };
242}
uint64_t VkSampler
Definition VulkanCameraManager.h:43
uint64_t VkDescriptorSet
Definition VulkanCameraManager.h:41
uint64_t VkDescriptorPool
Definition VulkanCameraManager.h:40
uint64_t VkDescriptorSetLayout
Definition VulkanCameraManager.h:42
#define vk_null
Definition VulkanDefines.h:11
#define DEFINE_NON_DISPATCHABLE_HANDLE(object)
Definition VulkanInstance.h:49
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
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
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
ShadingModel
Definition Material.h:54
TextureCoordMode
Definition Material.h:104
Definition MemoryManager.h:261
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
The core String class for the NDEVR API.
Definition String.h:69
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
Logic for creating the data in Vulkan for a specific Material.
Definition VulkanMaterialManager.h:114
DynamicPointer< VulkanBuffer > m_frag_uniform_buffer
Definition VulkanMaterialManager.h:199
bool m_is_wireframe
Definition VulkanMaterialManager.h:231
bool m_has_image_opacity
Definition VulkanMaterialManager.h:227
void addMaterial(const Material &material)
bool hasOpacity() const
Definition VulkanMaterialManager.h:132
const VulkanVertexUniformObject & vertexUniform() const
Definition VulkanMaterialManager.h:126
DynamicPointer< VulkanShaderManager > m_shader_manager
Definition VulkanMaterialManager.h:217
void updateShader(const Material &mat, const GraphicsUpdateArguments &args, DynamicPointer< VulkanShaderManager > &shader_manager)
bool m_use_model_color
Definition VulkanMaterialManager.h:235
VkDescriptorSet m_descriptor_set
Definition VulkanMaterialManager.h:213
VulkanMaterialManager(const ConstPointer< VulkanDevice > &device)
void resetPool()
Definition VulkanMaterialManager.h:169
VkSampler m_sampler
Definition VulkanMaterialManager.h:190
bool m_needs_to_commit_vert_buffer
Definition VulkanMaterialManager.h:223
Time lastDependencyUpdate() const
Definition VulkanMaterialManager.h:161
VulkanBitflagObject uvImageFlags() const
Definition VulkanMaterialManager.h:122
void getShaderCreateInfo(PrimitiveMode property, Buffer< VkPipelineShaderStageCreateInfo, uint04, ObjectAllocator< true > > &buffer) const
String getColorByChannel(GraphicsUpdateArguments &args) const
bool useNormalForTexture() const
Definition VulkanMaterialManager.h:166
ConstPointer< VulkanShader > getFragmentShader(PrimitiveMode property) const
String getExtraPropertyChannel() const
Definition VulkanMaterialManager.h:148
bool m_write_to_depth
Definition VulkanMaterialManager.h:238
void createDescriptorSet(VkDescriptorPool pool, const GraphicsUpdateArguments &args)
bool usesLayerColor() const
Definition VulkanMaterialManager.h:137
static UUID MaterialID(const Material &material)
bool usesModelColor() const
Definition VulkanMaterialManager.h:136
ConstPointer< VulkanImageView > m_uv_view[cast< uint04 >(UVType::e_uv_size)]
Definition VulkanMaterialManager.h:204
void createSampler(const GraphicsUpdateArguments &args)
VulkanBitflagObject m_last_image_flag_object
Definition VulkanMaterialManager.h:191
VulkanMaterialManager(const VulkanMaterialManager &m_pipeline)=delete
Time m_last_push_update_time
Definition VulkanMaterialManager.h:208
String m_shader_name
Definition VulkanMaterialManager.h:219
bool m_smooth_normals
Definition VulkanMaterialManager.h:230
UUID m_id
Definition VulkanMaterialManager.h:240
bool m_has_grid
Definition VulkanMaterialManager.h:233
String m_image_address[cast< uint04 >(UVType::e_uv_size)]
Definition VulkanMaterialManager.h:210
bool m_needs_to_commit_frag_buffer
Definition VulkanMaterialManager.h:222
bool m_ignore_depth
Definition VulkanMaterialManager.h:237
VkDescriptorPool m_descriptor_pool
Definition VulkanMaterialManager.h:192
VulkanBitflagObject getUVImageFlags(const Material &material) const
uint04 m_layer_number
Definition VulkanMaterialManager.h:239
Vector< 3, Material::TileTextureMode > m_texture_tile_mode
Definition VulkanMaterialManager.h:215
Buffer< Material > m_materials
Definition VulkanMaterialManager.h:189
bool m_needs_pipeline_update
Definition VulkanMaterialManager.h:224
bool isDynamic() const
Definition VulkanMaterialManager.h:135
ConstPointer< VulkanDevice > m_device
Definition VulkanMaterialManager.h:193
Time m_last_updated_time
Definition VulkanMaterialManager.h:206
bool needsToUpdateShader(const Material &material)
void updateUniformBuffer(GraphicsUpdateArguments &args)
uint04 getNumberOfImages(const GraphicsUpdateArguments &args) const
bool hasGrid() const
Definition VulkanMaterialManager.h:123
bool m_has_opacity
Definition VulkanMaterialManager.h:225
String m_extra_channel
Definition VulkanMaterialManager.h:214
VulkanVertexUniformObject getVulkanVertexUniformObject(const Material &material, const GraphicsUpdateArguments &args) const
DynamicPointer< VulkanBuffer > m_vertex_uniform_buffer
Definition VulkanMaterialManager.h:198
fltp04 m_depth_bias
Definition VulkanMaterialManager.h:220
bool m_use_layer_color
Definition VulkanMaterialManager.h:236
bool ignoreDepth() const
Definition VulkanMaterialManager.h:133
bool m_is_dynamic
Definition VulkanMaterialManager.h:232
bool isWireframe() const
Definition VulkanMaterialManager.h:164
fltp04 depthBias() const
Definition VulkanMaterialManager.h:139
bool needsToUpdateImage(const Material &material)
bool overrideCamera() const
Definition VulkanMaterialManager.h:165
VulkanVertexUniformObject m_vert_uniform
Definition VulkanMaterialManager.h:195
static VkDescriptorSetLayout descriptorSetLayout(ConstPointer< VulkanDevice > device)
bool writeToDepth() const
Definition VulkanMaterialManager.h:134
void getDescriptorWrites(Buffer< VkWriteDescriptorSet, uint04, ObjectAllocator< true > > &descriptor_writes, Buffer< VkDescriptorImageInfo, uint04, ObjectAllocator< true > > &image_info) const
bool m_use_normal_for_texture
Definition VulkanMaterialManager.h:234
FragUniformObject getFragUniformObject(const Material &material) const
bool m_is_two_sided
Definition VulkanMaterialManager.h:228
uint04 m_number_of_uniforms
Definition VulkanMaterialManager.h:205
Material::ShadingModel m_shade_model
Definition VulkanMaterialManager.h:218
bool m_override_camera
Definition VulkanMaterialManager.h:229
void createPipeline(GraphicsUpdateArguments &args, DynamicPointer< VulkanShaderManager > &shader_manager, DynamicPointer< VulkanImageManager > &image_manager, VkDescriptorPool pool)
bool m_has_image
Definition VulkanMaterialManager.h:226
VkDescriptorSet descriptorSet() const
Definition VulkanMaterialManager.h:155
FragUniformObject m_frag_uniform
Definition VulkanMaterialManager.h:196
bool isTwoSided() const
Definition VulkanMaterialManager.h:163
uint04 getLayerNumber(const Material &material) const
void updateImages(const Material &mat, const GraphicsUpdateArguments &args, DynamicPointer< VulkanImageManager > &image_manager)
VulkanBitflagObject getBitflagObject() const
ConstPointer< VulkanImageData > m_uv_data[cast< uint04 >(UVType::e_uv_size)]
Definition VulkanMaterialManager.h:203
Definition ACIColor.h:37
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
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
Items to send to the OpenGL Fragmentation shader.
Definition VulkanMaterialManager.h:67
Vector< 16, fltp04 > float_values
Definition VulkanMaterialManager.h:81
FloatPosition
Definition VulkanMaterialManager.h:76
@ e_max_value_frag_pos
Definition GLESMaterialManager.h:71
@ e_min_value_frag_pos
Definition GLESMaterialManager.h:69
@ e_mid_value_frag_pos
Definition GLESMaterialManager.h:70
fltp04 shininess
Definition GLESMaterialManager.h:80
fltp04 opacity
Definition GLESMaterialManager.h:81
fltp04 fade_distance
Definition GLESMaterialManager.h:77
FragUniformObject()
Definition VulkanMaterialManager.h:97
fltp04 max_distance
Definition GLESMaterialManager.h:78
Vector< 4, sint04 > m_grid_lines_desc
Definition GLESMaterialManager.h:76
Vector< 12, RGBColor > palette_colors
Definition GLESMaterialManager.h:74
uint04 palette_size
Definition VulkanMaterialManager.h:93
VulkanBitflagObject tex_flags
Definition VulkanMaterialManager.h:94
void setMode(Material::TextureCoordMode mat_mode)
Definition VulkanMaterialManager.h:102
FragUniformObject(const Material &m_material)
uint04 texture_coord_mode
Definition GLESMaterialManager.h:84
Vector< 4, sint04 > m_grid_lines
Definition GLESMaterialManager.h:75
uint04 layer_number
Definition VulkanMaterialManager.h:90
ColorPosition
Definition VulkanMaterialManager.h:69
@ e_ks_frag_pos
Definition GLESMaterialManager.h:64
@ e_ka_frag_pos
Definition GLESMaterialManager.h:63
@ e_kd_frag_pos
Definition GLESMaterialManager.h:62
@ e_kr_frag_pos
Definition GLESMaterialManager.h:65
Stores bools to be sent to both the Vertex and Fragment shaders in the Vulkan space.
Definition VulkanBitflagObject.h:41
Information sent to the Vertex shader as a Uniform object.
Definition VulkanMaterialManager.h:55
fltp04 pixel_thickness
Definition VulkanMaterialManager.h:56
fltp04 reserved2
Definition VulkanMaterialManager.h:59
fltp04 reserved0
Definition VulkanMaterialManager.h:57
fltp04 reserved1
Definition VulkanMaterialManager.h:58