NDEVR
API Documentation
VulkanShaderCreator.h
1#pragma once
2#include "Design/Headers/ShaderDefinition.h"
3#include <NDEVR/VertexProperty.h>
4#include <NDEVR/Scanner.h>
5namespace NDEVR
6{
12 {
13 void readInput(Scanner& scan, VertexShaderDefinition& def)
14 {
15 uint04 location = scan.getNext().split('=')[1].getAs<uint04>();
16 scan.skip();//in
17 StringView input_value = scan.getNext();
18 switch (input_value.hash())
19 {
20 case String::hash("transform"):
21 def.transform.index = location;
22 break;
23 case String::hash("offset"):
24 def.offset.index = location;
25 break;
26 case String::hash("flags"):
27 def.flags.index = location;
28 break;
29 default:
30 {
31 VertexProperty property = input_value.getAs<VertexProperty>();
32 if (property != VertexProperty::Invalid)
33 {
34 def.geometry_channel_locations[input_value].index = location;
35 break;
36 }
37 } break;
38 }
39 }
40 void readAttributeUniform(Scanner& scan, ShaderDefinition& def)
41 {
42 ShaderUniform uniform;
43 Buffer<StringView> split = scan.getNext().split(',');
44 scan.nextLine();
45 while (!scan.currentLine().beginsWith("}"))
46 {
47 scan.getNext();
48
49 }
50 scan.skip();//skip closing }
51 def.attribute_locations[scan.getNext<String>()] = uniform;
52
53 }
54 ShaderDefinition createVertex(const String& value, VertexShaderDefinition& def)
55 {
57 Scanner scan(value, ' ');
58 while (scan.nextLine())
59 {
60 StringView value = scan.getNext();
61 switch (value.hash())
62 {
63 case String::hash("layout"):
64 {
65 if (scan.currentLine().hasSubString(" in "))
66 readInput(scan, def);
67 if (scan.currentLine().hasSubString(" uniform "))
68 readUniform(scan, def);
69 } break;
70 }
71 }
72 }
73 };
74}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Contains methods for easily reading objects in an ascii stream using set deliminators and line logic.
Definition Scanner.h:47
t_type getNext()
Reads and returns the next token parsed as the specified type.
const String & currentLine() const
Returns a const reference to the current line being parsed.
Definition Scanner.h:108
virtual bool nextLine()
Advances the scanner to the next line in the stream.
uint04 skip()
Skips the current token and advances to the next delimiter.
The core String View class for the NDEVR API.
Definition StringView.h:58
constexpr uint08 hash() const
Creates a simple, quick hash of the object.
Definition StringView.h:330
t_type getAs() const
Converts a string into an object.
Definition StringView.h:125
The core String class for the NDEVR API.
Definition String.h:95
constexpr uint08 hash() const
Creates a simple, quick hash of the object.
Definition String.h:524
bool hasSubString(const StringView &sub_string, bool ignore_case=false, uint04 start_idx=0) const
Tests if this String contains the specified substring.
bool beginsWith(const StringView &s, bool ignore_case=false) const
Tests if this String starts with the specified prefix.
Parses GLSL shader source to extract vertex input layout and uniform definitions for creating Vulkan ...
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.
@ Invalid
Sentinel value indicating no valid vertex property.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint04 index
The resolved numeric index of the location, or Invalid if not yet resolved.
Base definition for a shader program, holding source data and uniform bindings.
Dictionary< String, ShaderUniform > attribute_locations
Maps uniform block names to their ShaderUniform descriptors.
Describes the set of attribute locations associated with a single shader uniform block.
Shader definition specialized for the vertex processing stage.
ResolveableLocation offset
Location of the vertex offset uniform.
ResolveableLocation flags
Location of the rendering flags uniform.
ResolveableLocation transform
Location of the model transform matrix uniform.
Dictionary< VertexProperty, ResolveableLocation > geometry_channel_locations
Maps VertexProperty enum values to their shader input locations for geometry data.