blob: 17159303a772ed1eaeeaa251351b1f2b2c2ed8c8 (
plain) (
blame)
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
|
#include "video.hpp"
extern "C" {
#include "qstd/memory.h"
#include "qstd/plat.h"
}
Pipeline_Builder::Pipeline_Builder(Arena* arena):
arena(arena) {}
void Pipeline_Builder::begin_rp() {
pass = (Render_Pass*)arena_alloc(arena, sizeof *pass);
pass->target = 0;
pass->clear = { 0, 0, 0, 0 };
}
void Pipeline_Builder::rp_target(Texture_Id id, Colour clear) {
pass->target = id;
pass->clear = clear;
}
void Pipeline_Builder::validate_rp() {
assert(pass->target);
}
Render_Pass& Pipeline_Builder::build_rp() {
validate_rp();
return *pass;
}
void Pipeline_Builder::begin() {
pip = (Pipeline*)arena_alloc(arena, sizeof *pip);
pip->vertex_format = 0;
pip->shader = 0;
pip->descriptors = 0;
}
void Pipeline_Builder::shader(Shader_Id s) {
pip->shader = s;
}
void Pipeline_Builder::texture(
int binding,
Texture_Id t,
Sampler_Id s
) {
Texture_Descriptor* d = (Texture_Descriptor*)arena_alloc(
arena,
sizeof *d
);
d->slot = binding;
d->type = Descriptor::Type::texture;
d->sampler = s;
d->texture = t;
d->next = pip->descriptors;
pip->descriptors = d;
}
void Pipeline_Builder::vertex_format(Vertex_Format_Id vf) {
pip->vertex_format = vf;
}
Pipeline& Pipeline_Builder::build() {
validate();
return *pip;
}
void Pipeline_Builder::validate() {
assert(pip->vertex_format);
assert(pip->shader);
}
|