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
|
// Headless GPU implementation - functional stubs for testing
// Workspace: demo (shared across all workspaces)
#if defined(DEMO_HEADLESS)
#include "gpu.h"
#include "gpu/effect.h"
#include "platform/stub_types.h"
#include <stdio.h>
static bool g_initialized = false;
GpuBuffer gpu_create_buffer(WGPUDevice device, size_t size, uint32_t usage,
const void* data) {
(void)device;
(void)size;
(void)usage;
(void)data;
return {nullptr, 0};
}
RenderPass gpu_create_render_pass(WGPUDevice device, WGPUTextureFormat format,
const char* shader_code,
ResourceBinding* bindings, int num_bindings) {
(void)device;
(void)format;
(void)shader_code;
(void)bindings;
(void)num_bindings;
return {nullptr, nullptr, 0, 0};
}
ComputePass gpu_create_compute_pass(WGPUDevice device, const char* shader_code,
ResourceBinding* bindings,
int num_bindings) {
(void)device;
(void)shader_code;
(void)bindings;
(void)num_bindings;
return {nullptr, nullptr, 0, 0, 0};
}
void gpu_init(PlatformState* platform_state) {
(void)platform_state;
if (!g_initialized) {
printf("[headless] GPU initialized\n");
g_initialized = true;
}
}
void gpu_draw(float audio_peak, float aspect_ratio, float time, float beat_time,
float beat_phase) {
(void)audio_peak;
(void)aspect_ratio;
(void)time;
(void)beat_time;
(void)beat_phase;
}
void gpu_resize(int width, int height) {
(void)width;
(void)height;
}
void gpu_shutdown() {
if (g_initialized) {
printf("[headless] GPU shutdown\n");
g_initialized = false;
}
}
const GpuContext* gpu_get_context() {
static GpuContext ctx = {nullptr, nullptr, WGPUTextureFormat_BGRA8Unorm};
return &ctx;
}
WGPUSurface gpu_get_surface() {
return nullptr;
}
TextureWithView gpu_create_texture_2d(WGPUDevice device, uint32_t width,
uint32_t height, WGPUTextureFormat format,
WGPUTextureUsage usage,
uint32_t mip_levels) {
(void)device;
(void)width;
(void)height;
(void)format;
(void)usage;
(void)mip_levels;
return {nullptr, nullptr};
}
TextureWithView gpu_create_storage_texture_2d(WGPUDevice device, uint32_t width,
uint32_t height,
WGPUTextureFormat format) {
(void)device;
(void)width;
(void)height;
(void)format;
return {nullptr, nullptr};
}
TextureWithView gpu_create_post_process_texture(WGPUDevice device,
uint32_t width, uint32_t height,
WGPUTextureFormat format) {
(void)device;
(void)width;
(void)height;
(void)format;
return {nullptr, nullptr};
}
WGPUTextureView gpu_create_mip_view(WGPUTexture texture,
WGPUTextureFormat format,
uint32_t mip_level) {
(void)texture;
(void)format;
(void)mip_level;
return nullptr;
}
WGPUTextureView gpu_create_texture_view_2d(WGPUTexture texture,
WGPUTextureFormat format,
uint32_t mip_levels) {
(void)texture;
(void)format;
(void)mip_levels;
return nullptr;
}
#if !defined(STRIP_ALL)
void gpu_simulate_until(float time, float bpm) {
(void)time;
(void)bpm;
}
void gpu_add_custom_effect(Effect* effect, float start_time, float end_time,
int priority) {
(void)effect;
(void)start_time;
(void)end_time;
(void)priority;
}
#endif
#endif // DEMO_HEADLESS
|