-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpass.h
More file actions
224 lines (190 loc) · 5.34 KB
/
pass.h
File metadata and controls
224 lines (190 loc) · 5.34 KB
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
/*
* This file is part of the gk project (https://github.com/recp/gk)
* Copyright (c) Recep Aslantas.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef gk_pass_h
#define gk_pass_h
#include "common.h"
#include "program.h"
#include "material.h"
#include "geom-types.h"
#include <ds/forward-list.h>
#include <stdbool.h>
struct GkScene;
struct GkContext;
struct GkPrimitive;
struct GkLight;
typedef struct GkClearOp {
vec4 *color;
float depth;
bool clearColor:1;
bool clearDepth:1;
bool enabled;
} GkClearOp;
typedef struct GkBlendOp {
bool enabled;
bool separate;
GLenum src;
GLenum dst;
} GkBlendOp;
typedef struct GkDepthTest {
bool enabled;
GLenum func;
GLboolean mask;
} GkDepthTest;
/* GL_COLOR_ATTACHMENT[n] */
typedef struct GkColorOutput {
GLuint buffId;
GLsizei width;
GLsizei height;
GLenum attachment;
GLenum drawIndex;
GkClearOp *clear;
GkBlendOp *blend;
struct GkColorOutput *next;
} GkColorOutput;
typedef struct GkOutput {
GLuint fbo;
GLuint depth; /* GL_DEPTH_ATTACHMENT */
GLuint stencil; /* GL_STENCIL_ATTACHMENT */
GkColorOutput *color; /* GL_COLOR_ATTACHMENT0 */
GkClearOp *clear;
GkBlendOp *blend;
uint32_t colorCount;
bool cleared;
} GkOutput;
typedef struct GkPass {
GkPipeline *prog;
FListItem *states;
GkOutput *output;
struct GkPass *inPasses;
struct GkPass *outPass;
struct GkPass *next;
GkClearOp *clear;
GkBlendOp *blend;
GkDepthTest *depthTest;
bool noLights;
bool noMaterials;
} GkPass;
GK_EXPORT
GkOutput*
gkDefaultRenderOut(void);
GK_EXPORT
GkOutput*
gkCurrentOutput(struct GkContext * __restrict ctx);
GK_EXPORT
GkPass*
gkGetOrCreatPass(struct GkScene *scene,
struct GkLight *light,
struct GkPrimInst *primInst,
GkMaterial *mat);
GK_EXPORT
void
gkBindPass(struct GkScene * __restrict scene,
GkPass * __restrict pass);
GK_EXPORT
GkPass*
gkAllocPass(struct GkContext * __restrict ctx);
GK_EXPORT
GkOutput*
gkAllocOutput(struct GkContext * __restrict ctx);
GK_EXPORT
void
gkBindOutput(struct GkScene *scene,
GkOutput *output);
GK_EXPORT
void
gkBindOutputFor(struct GkContext * __restrict ctx, GkOutput *output);
GK_EXPORT
void
gkBindDefaultOutput(struct GkScene *scene);
GK_EXPORT
void
gkAddDepthTarget(struct GkScene *scene,
GkPass *pass);
GK_EXPORT
void
gkAddDepthTexTarget(struct GkScene *scene,
GkPass *pass,
GkSize size);
GK_EXPORT
void
gkAddDepthTexArrayTarget(struct GkScene *scene, GkPass *pass, GLsizei len);
GK_EXPORT
void
gkAddDepthCubeTexTarget(struct GkScene *scene, GkPass *pass, float size);
GK_EXPORT
GkColorOutput*
gkGetRenderTarget(GkPass *rt, int32_t index);
GK_EXPORT
void
gkBindRenderTargetTo(struct GkScene *scene,
GkPass *pass,
int32_t targetIndex,
GkPipeline *prog,
int32_t texUnit,
const char *uniformName);
GK_EXPORT
void
gkBindDepthTexTo(struct GkScene *scene,
GkPass *pass,
GkPipeline *prog,
int32_t texUnit,
const char *uniformName);
GK_EXPORT
void
gkBindDepthTexArrayTo(struct GkScene *scene,
GkPass *pass,
GkPipeline *prog,
int32_t texUnit,
const char *uniformName);
GK_EXPORT
GLuint
gkAddRenderTarget(struct GkScene *scene,
GkPass *pass,
GLenum internalformat,
GLenum format,
GLenum type);
GK_EXPORT
GLuint
gkAddRenderTargetRB(struct GkScene *scene,
GkPass *pass);
GK_EXPORT
GLuint
gkAddRenderTargetEx(struct GkScene *scene,
GkPass *pass,
GLenum internalFormat,
GLenum format,
GLsizei width,
GLsizei height,
GLenum type);
GK_EXPORT
GLuint
gkAddRenderTargetRBEx(struct GkScene *scene,
GkPass *pass,
GLenum internalFormat,
GLsizei width,
GLsizei height);
GK_EXPORT
void
gkClearColor(GkColorOutput *colorOutput);
GK_EXPORT
void
gkClearColorAt(GkOutput *output, int32_t buffIndex);
GK_EXPORT
void
gkClearColors(GkOutput *output);
#endif /* gk_pass_h */