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
|
#ifndef video_hpp
#define video_hpp
#include <stdint.h>
struct App;
struct Arena;
struct Heap;
typedef uint32_t Texture_Id;
typedef uint32_t Buffer_Id;
struct Pipeline {
};
struct Colour {
uint8_t r, g, b, a;
};
struct Render_Pass {
Texture_Id target;
Colour clear;
bool operator==(const Render_Pass& other) const {
int size = sizeof *this, i;
uint8_t* bba = (uint8_t*)this;
uint8_t* bbb = (uint8_t*)&other;
for (i = 0; i < size; i++)
if (*bba != *bbb) return false;
return true;
}
};
struct Draw {
};
struct Pipeline_Builder {
Arena* arena;
Render_Pass* pass;
Pipeline_Builder(Arena* arena);
void begin_rp();
void rp_target(Texture_Id id, Colour clear_colour);
Render_Pass& build_rp();
void validate_rp();
};
struct Texture {
int w, h;
bool alias;
};
struct Context;
struct Shader;
struct Device {
Arena* arena;
Heap* heap;
App* app;
static Device* create(Arena* a, App* ap);
void init(Arena* a, App* ap);
void destroy();
void on_resize();
void begin_frame();
void submit(Context& ctx);
void present();
Context& acquire();
Context& get_ctx();
Texture_Id get_backbuffer();
Texture& get_texture(Texture_Id id);
void destroy_texture(Texture_Id id);
Shader* load_shader(const char* fname);
};
struct Context {
void wait(Device& d);
void submit(
Device& d,
const Draw& draw,
const Pipeline& p,
const Render_Pass& rp
);
void submit(
Device& d,
const Draw* draws,
int count,
const Pipeline& p,
const Render_Pass& rp
);
void submit(Device& d, const Render_Pass& rp);
};
struct Shader {
void destroy(Device* dev);
};
#endif
|