NDEVR
API Documentation
VulkanShader.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: Shader
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "VulkanDevice.h"
34#include "VulkanDefines.h"
35#include <NDEVR/File.h>
36#include <NDEVR/Pointer.h>
37#include <NDEVR/Dictionary.h>
38DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule);
39namespace NDEVR
40{
41 enum class PrimitiveMode;
42 class VulkanInstance;
48 {
49 public:
51 VulkanShader(VulkanShader&& device) noexcept;
66 void cleanup();
72 void createShader(const File& file);
75 void createShader(const Buffer<char>& data);
76
78 VkShaderModule vkShader() const { return m_shader; }
79 private:
80 Buffer<char> m_data;
81 VkShaderModule m_shader;
83 };
84
140}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
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
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
The core String View class for the NDEVR API.
Definition StringView.h:58
The connection between the NDEVR API and the Vulkan library.
static const StringView formats[ShaderType::e_shader_type_size]
File name suffixes for each shader type.
void addShader(const StringView &name, ShaderType type, const Buffer< char > &data)
Adds a shader from raw bytecode.
void setInstance(const ConstPointer< VulkanDevice > &device)
Sets the Vulkan device for all managed shaders.
Dictionary< String, DynamicPointer< VulkanShader >[ShaderType::e_shader_type_size]> m_shader_map
Compiled shader modules keyed by name.
void ensureCreated(const StringView &name)
Ensures all shader types for the named shader set are created.
VulkanShaderManager(const ConstPointer< VulkanDevice > &device)
Constructs a shader manager for the given device.
void addShader(const StringView &name, ShaderType type, File &file)
Adds a shader from a file.
void ensureCreated(ShaderType type, const StringView &name)
Ensures a specific shader type for the named shader set is created.
ConstPointer< VulkanDevice > m_device
The Vulkan device.
Dictionary< String, Buffer< char >[ShaderType::e_shader_type_size]> m_data
Raw SPIR-V data keyed by name.
ConstPointer< VulkanShader > getShader(const StringView &file, ShaderType type)
Retrieves a shader of the given type from the named set.
ShaderType
The types of shaders available for rendering different primitives.
@ e_solid
Solid surface rendering shader.
@ e_linework
Line rendering shader.
@ e_shader_type_size
The number of shader types (sentinel).
@ e_solid_grid
Solid surface with grid overlay shader.
@ e_tbn_texture
Tangent-bitangent-normal texture mapping shader.
@ e_solid_texture
Solid surface with texture mapping shader.
@ e_simple_points
Simplified point rendering shader.
@ e_points
Full point rendering shader.
@ e_all
Represents all shader types.
VulkanShader(const Buffer< char > &data, const ConstPointer< VulkanDevice > &device)
Constructs a shader from raw SPIR-V data.
void cleanup()
Releases the Vulkan shader module.
VulkanShader(VulkanShader &&device) noexcept
Move constructor.
~VulkanShader()
Destructor.
void createShader(const Buffer< char > &data)
Creates a shader module from raw SPIR-V data.
void createShader(const File &file)
Creates a shader module from a SPIR-V file.
void setInstance(const ConstPointer< VulkanDevice > &device)
Sets the Vulkan device for this shader.
VulkanShader(const File &file, const ConstPointer< VulkanDevice > &device)
Constructs a shader from a SPIR-V file.
VkShaderModule vkShader() const
Returns the Vulkan shader module handle.
VulkanShader(const ConstPointer< VulkanDevice > &device)
Constructs an empty shader on the given device.
The primary namespace for the NDEVR SDK.
@ type
The type identifier string for this model node.
Definition Model.h:58
PrimitiveMode
Used with Geometry to describe how vertices and indices are used to form shapes.
@ file
The source file path associated with this object.
@ name
The display name of the object.