diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-03 08:23:00 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-03 08:23:00 +0100 |
| commit | dd849f36c09d08c4cd7a66348232206032455700 (patch) | |
| tree | bb78fa259b504cb440a1aa96ff73ae34805981c4 /src/gpu | |
| parent | f9b91fac0f4611bd344eb57c8596b2da04926d02 (diff) | |
fix: Resolve shader initialization crashes and build errors
Fixes crashes in demo64k and test_3d_render caused by uninitialized ShaderComposer. Moves InitShaderComposer() call before effect initialization in gpu.cc and adds explicit call in test_3d_render.cc. Also fixes include paths for generated assets.h in multiple files.
Diffstat (limited to 'src/gpu')
| -rw-r--r-- | src/gpu/effects/shaders.h | 5 | ||||
| -rw-r--r-- | src/gpu/gpu.cc | 7 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/gpu/effects/shaders.h b/src/gpu/effects/shaders.h index a23c41c..f8e45ba 100644 --- a/src/gpu/effects/shaders.h +++ b/src/gpu/effects/shaders.h @@ -1,8 +1,11 @@ // This file is part of the 64k demo project. -// It declares the WGSL shader strings. +// It declares the WGSL shader strings and initialization function. #pragma once +// Initializes the ShaderComposer with snippet assets. +void InitShaderComposer(); + // Shader declarations (defined in shaders.cc) extern const char* main_shader_wgsl; extern const char* particle_compute_wgsl; diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index 7406113..8342c94 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -6,6 +6,7 @@ #include "demo_effects.h" #include "effect.h" #include "platform.h" +#include "gpu/effects/shaders.h" #include <GLFW/glfw3.h> #include <math.h> @@ -52,8 +53,6 @@ static WGPUSurfaceConfiguration g_config = {}; static MainSequence g_main_sequence; -extern void InitShaderComposer(); - // --- Helper Functions --- GpuBuffer gpu_create_buffer(WGPUDevice device, size_t size, uint32_t usage, @@ -373,11 +372,11 @@ void gpu_init(PlatformState* platform_state) { g_config.alphaMode = WGPUCompositeAlphaMode_Opaque; wgpuSurfaceConfigure(g_surface, &g_config); + InitShaderComposer(); + g_main_sequence.init(g_device, g_queue, g_config.format, platform_state->width, platform_state->height); - InitShaderComposer(); - LoadTimeline(g_main_sequence, g_device, g_queue, g_config.format); } |
