summaryrefslogtreecommitdiff
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/gpu.cc24
-rw-r--r--src/gpu/gpu.h6
2 files changed, 19 insertions, 11 deletions
diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc
index b87c47f..f32f049 100644
--- a/src/gpu/gpu.cc
+++ b/src/gpu/gpu.cc
@@ -1,3 +1,7 @@
+// This file is part of the 64k demo project.
+// It implements the WebGPU rendering pipeline and shader management.
+// Driven by audio peaks for synchronized visual effects.
+
#include "gpu.h"
#include "platform.h"
@@ -144,9 +148,10 @@ void gpu_init(GLFWwindow *window) {
adapter_opts.compatibleSurface = g_surface;
adapter_opts.powerPreference = WGPUPowerPreference_HighPerformance;
- wgpuInstanceRequestAdapter(g_instance, &adapter_opts,
- {nullptr, WGPUCallbackMode_WaitAnyOnly,
- handle_request_adapter, &g_adapter, nullptr});
+ wgpuInstanceRequestAdapter(
+ g_instance, &adapter_opts,
+ {nullptr, WGPUCallbackMode_WaitAnyOnly, handle_request_adapter, &g_adapter,
+ nullptr});
while (!g_adapter) {
wgpuInstanceWaitAny(g_instance, 0, nullptr, 0);
@@ -158,9 +163,10 @@ void gpu_init(GLFWwindow *window) {
device_desc.uncapturedErrorCallbackInfo.callback = handle_device_error;
#endif
- wgpuAdapterRequestDevice(g_adapter, &device_desc,
- {nullptr, WGPUCallbackMode_WaitAnyOnly,
- handle_request_device, &g_device, nullptr});
+ wgpuAdapterRequestDevice(
+ g_adapter, &device_desc,
+ {nullptr, WGPUCallbackMode_WaitAnyOnly, handle_request_device, &g_device,
+ nullptr});
while (!g_device) {
wgpuInstanceWaitAny(g_instance, 0, nullptr, 0);
@@ -265,8 +271,7 @@ void gpu_draw(float audio_peak, float aspect_ratio) {
WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal)
return;
- WGPUTextureView view =
- wgpuTextureCreateView(surface_texture.texture, nullptr);
+ WGPUTextureView view = wgpuTextureCreateView(surface_texture.texture, nullptr);
struct {
float audio_peak;
@@ -312,5 +317,4 @@ void gpu_draw(float audio_peak, float aspect_ratio) {
wgpuTextureRelease(surface_texture.texture);
}
-void gpu_shutdown() {
-} \ No newline at end of file
+void gpu_shutdown() {}
diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h
index 87d4b9b..028b31b 100644
--- a/src/gpu/gpu.h
+++ b/src/gpu/gpu.h
@@ -1,6 +1,10 @@
+// This file is part of the 64k demo project.
+// It defines the public interface for the GPU rendering system.
+// Coordinates WebGPU lifecycle and draw calls.
+
#pragma once
struct GLFWwindow;
void gpu_init(GLFWwindow *window);
void gpu_draw(float audio_peak, float aspect_ratio);
-void gpu_shutdown();
+void gpu_shutdown(); \ No newline at end of file