diff options
Diffstat (limited to 'src/gpu')
| -rw-r--r-- | src/gpu/gpu.cc | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index 79498e3..b87c47f 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -28,7 +28,8 @@ static WGPUBindGroup g_bind_group = nullptr; static WGPUStringView label_view(const char *str) { #ifndef STRIP_ALL - if (!str) return {nullptr, 0}; + if (!str) + return {nullptr, 0}; return {str, strlen(str)}; #else (void)str; @@ -37,7 +38,8 @@ static WGPUStringView label_view(const char *str) { } static WGPUStringView str_view(const char *str) { - if (!str) return {nullptr, 0}; + if (!str) + return {nullptr, 0}; return {str, strlen(str)}; } @@ -142,10 +144,9 @@ 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); @@ -157,10 +158,9 @@ 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); @@ -259,17 +259,21 @@ void gpu_init(GLFWwindow *window) { void gpu_draw(float audio_peak, float aspect_ratio) { WGPUSurfaceTexture surface_texture; wgpuSurfaceGetCurrentTexture(g_surface, &surface_texture); - if (surface_texture.status != WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal && - surface_texture.status != WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal) + if (surface_texture.status != + WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal && + surface_texture.status != + WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal) return; - WGPUTextureView view = wgpuTextureCreateView(surface_texture.texture, nullptr); + WGPUTextureView view = + wgpuTextureCreateView(surface_texture.texture, nullptr); struct { float audio_peak; float aspect_ratio; } uniforms = {audio_peak, aspect_ratio}; - wgpuQueueWriteBuffer(g_queue, g_uniform_buffer, 0, &uniforms, sizeof(uniforms)); + wgpuQueueWriteBuffer(g_queue, g_uniform_buffer, 0, &uniforms, + sizeof(uniforms)); WGPUCommandEncoderDescriptor encoder_desc = {}; encoder_desc.label = label_view("Command Encoder"); @@ -308,4 +312,5 @@ 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() { +}
\ No newline at end of file |
