Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
Pipeline.hpp
1/*
2Copyright (C) 2017-2019,2021,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGAMES_PIPELINE_H
17#define AEONGAMES_PIPELINE_H
18
19#include <cstdint>
20#include <string>
21#include <string_view>
22#include <vector>
23#include <array>
24#include <regex>
25#include <tuple>
27#include "aeongames/Material.hpp"
28#include "aeongames/Resource.hpp"
29#include <functional>
30
31namespace AeonGames
32{
33 class PipelineMsg;
52#if 0
53 class MaterialMsg;
54
55 enum AttributeBits
56 {
57 VertexPositionBit = 0x1,
58 VertexNormalBit = 0x2,
59 VertexTangentBit = 0x4,
60 VertexBitangentBit = 0x8,
61 VertexUVBit = 0x10,
62 VertexWeightIdxBit = 0x20,
63 VertexWeightBit = 0x40,
64 VertexColorBit = 0x80,
65 VertexAllBits = VertexPositionBit |
66 VertexNormalBit |
67 VertexTangentBit |
68 VertexBitangentBit |
69 VertexUVBit |
70 VertexWeightIdxBit |
71 VertexWeightBit |
72 VertexColorBit
73 };
74
75 enum AttributeFormat
76 {
77 Vector2Float,
78 Vector3Float,
79 Vector4Byte,
80 Vector4ByteNormalized,
81 };
82
83 enum UniformType
84 {
85 SCALAR_FLOAT,
86 SCALAR_UINT,
87 SCALAR_INT,
88 VECTOR_FLOAT_2,
89 VECTOR_FLOAT_3,
90 VECTOR_FLOAT_4,
91 };
92#endif
93
105
107 const std::unordered_map<ShaderType, const char*> ShaderTypeToString
108 {
109 { VERT, "vertex" },
110 { FRAG, "fragment" },
111 { COMP, "compute" },
112 { TESC, "tessellation control" },
113 { TESE, "tessellation evaluation" },
114 { GEOM, "geometry" }
115 };
116
121 class Pipeline : public Resource
122 {
123 public:
124 static const uint32_t TOPOLOGY_CLASS_POINT{1};
125 static const uint32_t TOPOLOGY_CLASS_LINE{2};
126 static const uint32_t TOPOLOGY_CLASS_TRIANGLE{4};
127 static const uint32_t TOPOLOGY_CLASS_PATCH{8};
128
130 DLL Pipeline();
132 DLL virtual ~Pipeline();
137 DLL void LoadFromMemory ( const void* aBuffer, size_t aBufferSize ) final;
139 DLL void Unload() final;
143 DLL uint32_t GetTopologyClass() const;
144#if 0
145 DLL const std::string& GetVertexShaderCode() const;
146 DLL const std::string& GetFragmentShaderCode() const;
147 DLL const std::vector<std::tuple<UniformType, std::string >> & GetUniformDescriptors() const;
148 DLL const std::vector<std::string>& GetSamplerDescriptors() const;
149 DLL std::string GetProperties () const;
150 DLL std::string GetAttributes () const;
151 DLL uint32_t GetAttributeBitmap() const;
152#endif
157 DLL const std::string_view GetShaderCode ( ShaderType aType ) const;
158
162 DLL void LoadFromPBMsg ( const PipelineMsg& aPipelineMsg );
163 private:
164#if 0
165 Topology mTopology {};
166 std::string mVertexShaderCode{};
167 std::string mFragmentShaderCode{};
168 std::vector<std::tuple<UniformType, std::string >> mUniformDescriptors{};
169 std::vector<std::string> mSamplerDescriptors{};
170#endif
171 std::array<std::string, ShaderType::COUNT> mShaderCode {};
172 uint32_t mTopologyClass{ TOPOLOGY_CLASS_TRIANGLE };
173 };
174}
175#endif
Platform-specific macros, includes, and DLL export/import definitions.
static const uint32_t TOPOLOGY_CLASS_POINT
Point topology class bitmask.
Definition Pipeline.hpp:124
DLL void Unload() final
Release all pipeline resources.
Definition Pipeline.cpp:233
static const uint32_t TOPOLOGY_CLASS_LINE
Line topology class bitmask.
Definition Pipeline.hpp:125
static const uint32_t TOPOLOGY_CLASS_TRIANGLE
Triangle topology class bitmask.
Definition Pipeline.hpp:126
DLL const std::string_view GetShaderCode(ShaderType aType) const
Get the shader source code for the given shader stage.
Definition Pipeline.cpp:204
virtual DLL ~Pipeline()
Virtual destructor.
DLL void LoadFromMemory(const void *aBuffer, size_t aBufferSize) final
Load pipeline data from a memory buffer.
Definition Pipeline.cpp:209
DLL void LoadFromPBMsg(const PipelineMsg &aPipelineMsg)
Load pipeline configuration from a protobuf message.
Definition Pipeline.cpp:214
DLL uint32_t GetTopologyClass() const
Get the topology class bitmask for this pipeline.
Definition Pipeline.cpp:63
static const uint32_t TOPOLOGY_CLASS_PATCH
Patch topology class bitmask.
Definition Pipeline.hpp:127
DLL Pipeline()
Default constructor.
Base class for loadable engine resources.
Definition Resource.hpp:33
<- This is here just for the literals
Definition AABB.hpp:31
DLL uint32_t GetAttributes(const PipelineMsg &aPipelineMsg)
Get the packed attribute flags from a pipeline message.
const std::unordered_map< ShaderType, const char * > ShaderTypeToString
Map from ShaderType enum values to human-readable string names.
Definition Pipeline.hpp:108
ShaderType
Shader stage types.
Definition Pipeline.hpp:96
@ VERT
Vertex shader.
Definition Pipeline.hpp:97
@ COUNT
Number of shader types.
Definition Pipeline.hpp:103
@ FRAG
Fragment shader.
Definition Pipeline.hpp:98
@ GEOM
Geometry shader.
Definition Pipeline.hpp:102
@ TESC
Tessellation control shader.
Definition Pipeline.hpp:100
@ TESE
Tessellation evaluation shader.
Definition Pipeline.hpp:101
@ COMP
Compute shader.
Definition Pipeline.hpp:99
Topology
Primitive topology types for rendering.
Definition Pipeline.hpp:38
@ TRIANGLE_STRIP
Connected triangle strip.
Definition Pipeline.hpp:43
@ PATCH_LIST
Patch list for tessellation.
Definition Pipeline.hpp:50
@ LINE_LIST_WITH_ADJACENCY
Line list with adjacency information.
Definition Pipeline.hpp:46
@ TRIANGLE_LIST_WITH_ADJACENCY
Triangle list with adjacency information.
Definition Pipeline.hpp:48
@ POINT_LIST
List of individual points.
Definition Pipeline.hpp:40
@ UNDEFINED
Undefined topology.
Definition Pipeline.hpp:39
@ LINE_STRIP
Connected line segments.
Definition Pipeline.hpp:41
@ LINE_LIST
Pairs of vertices forming individual lines.
Definition Pipeline.hpp:42
@ TRIANGLE_LIST
Independent triangles.
Definition Pipeline.hpp:45
@ TRIANGLE_STRIP_WITH_ADJACENCY
Triangle strip with adjacency information.
Definition Pipeline.hpp:49
@ TRIANGLE_FAN
Triangles sharing a common vertex.
Definition Pipeline.hpp:44
@ LINE_STRIP_WITH_ADJACENCY
Line strip with adjacency information.
Definition Pipeline.hpp:47