summaryrefslogtreecommitdiff
path: root/src/gpu/gpu.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gpu.cc')
-rw-r--r--src/gpu/gpu.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc
index 63a30ff..fe71d3e 100644
--- a/src/gpu/gpu.cc
+++ b/src/gpu/gpu.cc
@@ -21,12 +21,13 @@
static WGPUInstance g_instance = nullptr;
static WGPUAdapter g_adapter = nullptr;
-WGPUDevice g_device = nullptr; // Non-static for external access (debug builds)
-WGPUQueue g_queue = nullptr; // Non-static for external access (debug builds)
+static WGPUDevice g_device = nullptr;
+static WGPUQueue g_queue = nullptr;
static WGPUSurface g_surface = nullptr;
static WGPUSurfaceConfiguration g_config = {};
-WGPUTextureFormat g_format = WGPUTextureFormat_BGRA8Unorm; // Exposed for custom effects
+static WGPUTextureFormat g_format = WGPUTextureFormat_BGRA8Unorm;
+static GpuContext g_gpu_context = {};
static MainSequence g_main_sequence;
// --- Helper Functions ---
@@ -355,7 +356,12 @@ void gpu_init(PlatformState* platform_state) {
g_config.device = g_device;
g_config.format = swap_chain_format;
- g_format = swap_chain_format; // Update global format for external access
+ g_format = swap_chain_format;
+
+ // Update GPU context for accessor
+ g_gpu_context.device = g_device;
+ g_gpu_context.queue = g_queue;
+ g_gpu_context.format = g_format;
g_config.usage = WGPUTextureUsage_RenderAttachment;
g_config.width = platform_state->width;
g_config.height = platform_state->height;
@@ -365,10 +371,9 @@ void gpu_init(PlatformState* platform_state) {
InitShaderComposer();
- g_main_sequence.init(g_device, g_queue, g_config.format,
- platform_state->width, platform_state->height);
+ g_main_sequence.init(g_gpu_context, platform_state->width, platform_state->height);
- LoadTimeline(g_main_sequence, g_device, g_queue, g_config.format);
+ LoadTimeline(g_main_sequence, g_gpu_context);
}
void gpu_draw(float audio_peak, float aspect_ratio, float time, float beat) {
@@ -395,6 +400,10 @@ void gpu_add_custom_effect(Effect* effect, float start_time, float end_time, int
seq->init(&g_main_sequence);
g_main_sequence.add_sequence(seq, 0.0f, priority);
}
+
+const GpuContext* gpu_get_context() {
+ return &g_gpu_context;
+}
#endif /* !defined(STRIP_ALL) */
void gpu_shutdown() {