-
-
Notifications
You must be signed in to change notification settings - Fork 271
/
PipelineItem.h
235 lines (201 loc) · 5.04 KB
/
PipelineItem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#pragma once
#include "../Engine/Model.h"
#include "ShaderVariableContainer.h"
#include "AudioShaderStream.h"
#include "ShaderMacro.h"
#include "InputLayout.h"
#include "../Options.h"
#include <glm/glm.hpp>
#ifdef _WIN32
#include <windows.h>
#endif
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#include <string>
namespace ed
{
struct PipelineItem
{
enum class ItemType
{
ShaderPass,
Geometry,
RenderState,
Model,
ComputePass,
AudioPass,
Count
};
PipelineItem() : Data(0) { memset(Name, 0, PIPELINE_ITEM_NAME_LENGTH * sizeof(char)); }
PipelineItem(const char* name, ItemType type, void* data) {
strcpy(Name, name);
Type = type;
Data = data;
}
char Name[PIPELINE_ITEM_NAME_LENGTH];
ItemType Type;
void* Data;
};
namespace pipe
{
struct ComputePass
{
ComputePass() {
Macros.clear();
memset(Path, 0, sizeof(char) * MAX_PATH);
memset(Entry, 0, sizeof(char) * 32);
WorkX = WorkY = WorkZ = 1;
}
char Path[MAX_PATH];
char Entry[32];
GLuint WorkX, WorkY, WorkZ;
ShaderVariableContainer Variables;
std::vector<ShaderMacro> Macros;
};
struct AudioPass
{
AudioPass() {
Macros.clear();
memset(Path, 0, sizeof(char) * MAX_PATH);
}
ed::AudioShaderStream Stream;
char Path[MAX_PATH];
ShaderVariableContainer Variables;
std::vector<ShaderMacro> Macros;
};
struct ShaderPass
{
ShaderPass() {
memset(RenderTextures, 0, sizeof(GLuint) * MAX_RENDER_TEXTURES);
DepthTexture = 0;
FBO = 0;
RTCount = 0;
GSUsed = false;
Active = true;
Macros.clear();
memset(VSPath, 0, sizeof(char) * MAX_PATH);
memset(PSPath, 0, sizeof(char) * MAX_PATH);
memset(GSPath, 0, sizeof(char) * MAX_PATH);
memset(VSEntry, 0, sizeof(char) * 32);
memset(PSEntry, 0, sizeof(char) * 32);
memset(GSEntry, 0, sizeof(char) * 32);
}
GLbyte RTCount;
GLuint RenderTextures[MAX_RENDER_TEXTURES];
GLuint DepthTexture; // pointer to actual depth & stencil texture
GLuint FBO; // actual framebuffer
bool Active;
char VSPath[MAX_PATH];
char VSEntry[32];
char PSPath[MAX_PATH];
char PSEntry[32];
char GSPath[MAX_PATH];
char GSEntry[32];
bool GSUsed;
ShaderVariableContainer Variables;
std::vector<ShaderMacro> Macros;
std::vector<InputLayoutItem> InputLayout;
std::vector<PipelineItem*> Items;
};
struct GeometryItem
{
GeometryItem()
{
Position = glm::vec3(0, 0, 0);
Rotation = glm::vec3(0, 0, 0);
Scale = glm::vec3(1, 1, 1);
Size = glm::vec3(1, 1, 1);
Topology = GL_TRIANGLES;
Type = GeometryType::Cube;
VAO = VBO = 0;
Instanced = false;
InstanceCount = 0;
InstanceBuffer = nullptr;
}
enum GeometryType {
Cube,
Rectangle, // ScreenQuad
Circle,
Triangle,
Sphere,
Plane,
ScreenQuadNDC
} Type;
GLuint VAO;
GLuint VBO;
unsigned int Topology;
glm::vec3 Position, Rotation, Scale, Size;
bool Instanced;
int InstanceCount;
void* InstanceBuffer;
};
struct RenderState
{
GLenum PolygonMode;
bool CullFace;
GLenum CullFaceType;
GLenum FrontFace;
bool Blend;
bool AlphaToCoverage;
GLenum BlendSourceFactorRGB;
GLenum BlendDestinationFactorRGB;
GLenum BlendFunctionColor;
GLenum BlendSourceFactorAlpha;
GLenum BlendDestinationFactorAlpha;
GLenum BlendFunctionAlpha;
glm::vec4 BlendFactor;
bool DepthTest;
bool DepthClamp;
bool DepthMask;
GLenum DepthFunction;
GLfloat DepthBias;
bool StencilTest;
GLuint StencilMask;
GLenum StencilFrontFaceFunction, StencilBackFaceFunction;
GLuint StencilReference;
GLenum StencilFrontFaceOpStencilFail, StencilFrontFaceOpDepthFail, StencilFrontFaceOpPass;
GLenum StencilBackFaceOpStencilFail, StencilBackFaceOpDepthFail, StencilBackFaceOpPass;
RenderState() {
PolygonMode = GL_FILL;
CullFace = true;
CullFaceType = GL_BACK;
FrontFace = GL_CCW;
Blend = false;
AlphaToCoverage = false;
BlendSourceFactorRGB = GL_SRC_ALPHA;
BlendDestinationFactorRGB = GL_ONE_MINUS_SRC_ALPHA;
BlendFunctionColor = GL_FUNC_ADD;
BlendSourceFactorAlpha = GL_SRC_ALPHA;
BlendDestinationFactorAlpha = GL_ONE_MINUS_SRC_ALPHA;
BlendFunctionAlpha = GL_FUNC_ADD;
BlendFactor = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
DepthTest = true;
DepthClamp = true;
DepthMask = true;
DepthFunction = GL_LESS;
DepthBias = 0.0f;
StencilTest = false;
StencilMask = 0x00;
StencilFrontFaceFunction = StencilBackFaceFunction = GL_EQUAL;
StencilReference = 0xFF;
StencilFrontFaceOpPass = StencilFrontFaceOpDepthFail = StencilFrontFaceOpStencilFail = GL_KEEP;
StencilBackFaceOpPass = StencilBackFaceOpDepthFail = StencilBackFaceOpStencilFail = GL_KEEP;
}
};
struct Model
{
bool OnlyGroup; // render only a group
char GroupName[MODEL_GROUP_NAME_LENGTH];
char Filename[MAX_PATH];
eng::Model* Data;
glm::vec3 Position, Rotation, Scale;
bool Instanced;
int InstanceCount;
void* InstanceBuffer;
};
}
}