summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-17 08:12:05 +0100
committerskal <pascal.massimino@gmail.com>2026-02-17 08:12:05 +0100
commit50350344d289c3389161cd6914c57f88d1a04dcc (patch)
tree5394a9b7781e3ccbbd332af8b043ea28d9d6a99f /src
parentfef8f1a9b7ff513963fbcae7590c24f95a06081c (diff)
refactor: move shaders.{h,cc} to src/effects and remove v2 suffix
- Removed unused v1 shader declarations (13 variables) - Removed _v2 suffix from active shader names - Moved shaders.{h,cc} from src/gpu to src/effects - Updated all includes and build references - All tests pass (34/34) handoff(Claude): Cleaned up shader management, tests passing
Diffstat (limited to 'src')
-rw-r--r--src/effects/flash_effect.cc2
-rw-r--r--src/effects/gaussian_blur_effect.cc6
-rw-r--r--src/effects/heptagon_effect.cc8
-rw-r--r--src/effects/particles_effect.cc6
-rw-r--r--src/effects/passthrough_effect.cc6
-rw-r--r--src/effects/placeholder_effect.cc8
-rw-r--r--src/effects/rotating_cube_effect.cc8
-rw-r--r--src/effects/shaders.cc (renamed from src/gpu/shaders.cc)105
-rw-r--r--src/effects/shaders.h25
-rw-r--r--src/gpu/demo_effects.h2
-rw-r--r--src/gpu/gpu.cc2
-rw-r--r--src/gpu/shaders.h39
-rw-r--r--src/tests/3d/test_3d_physics.cc2
-rw-r--r--src/tests/3d/test_3d_render.cc2
-rw-r--r--src/tests/3d/test_mesh.cc2
-rw-r--r--src/tests/gpu/test_noise_functions.cc2
-rw-r--r--src/tests/gpu/test_sequence_e2e.cc2
-rw-r--r--src/tests/gpu/test_shader_compilation.cc2
18 files changed, 70 insertions, 159 deletions
diff --git a/src/effects/flash_effect.cc b/src/effects/flash_effect.cc
index 787e33d..9f0a6fa 100644
--- a/src/effects/flash_effect.cc
+++ b/src/effects/flash_effect.cc
@@ -3,7 +3,7 @@
#include "effects/flash_effect.h"
#include "gpu/post_process_helper.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "util/fatal_error.h"
Flash::Flash(const GpuContext& ctx,
diff --git a/src/effects/gaussian_blur_effect.cc b/src/effects/gaussian_blur_effect.cc
index f2e0197..d163e51 100644
--- a/src/effects/gaussian_blur_effect.cc
+++ b/src/effects/gaussian_blur_effect.cc
@@ -1,9 +1,9 @@
-// Gaussian blur effect v2 implementation
+// Gaussian blur effect implementation
#include "effects/gaussian_blur_effect.h"
#include "util/fatal_error.h"
#include "gpu/post_process_helper.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
GaussianBlur::GaussianBlur(const GpuContext& ctx,
const std::vector<std::string>& inputs,
@@ -15,7 +15,7 @@ GaussianBlur::GaussianBlur(const GpuContext& ctx,
// Create pipeline
pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- gaussian_blur_v2_shader_wgsl);
+ gaussian_blur_shader_wgsl);
// Create sampler
WGPUSamplerDescriptor sampler_desc = {};
diff --git a/src/effects/heptagon_effect.cc b/src/effects/heptagon_effect.cc
index 1bc9d06..20761dc 100644
--- a/src/effects/heptagon_effect.cc
+++ b/src/effects/heptagon_effect.cc
@@ -1,10 +1,10 @@
-// Heptagon effect v2 implementation
+// Heptagon effect implementation
#include "effects/heptagon_effect.h"
#include "util/fatal_error.h"
#include "gpu/gpu.h"
#include "gpu/post_process_helper.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
Heptagon::Heptagon(const GpuContext& ctx,
const std::vector<std::string>& inputs,
@@ -16,9 +16,9 @@ Heptagon::Heptagon(const GpuContext& ctx,
// Init uniforms
uniforms_buffer_.init(ctx_.device);
- // Create pipeline (standard v2 post-process, no depth)
+ // Create pipeline (standard post-process, no depth)
pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- heptagon_v2_shader_wgsl);
+ heptagon_shader_wgsl);
// Create dummy sampler (scene effects don't use texture input)
WGPUSamplerDescriptor sampler_desc = {};
diff --git a/src/effects/particles_effect.cc b/src/effects/particles_effect.cc
index f93133f..7a8d94d 100644
--- a/src/effects/particles_effect.cc
+++ b/src/effects/particles_effect.cc
@@ -4,7 +4,7 @@
#include "util/fatal_error.h"
#include "effects/particles_effect.h"
#include "gpu/gpu.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include <vector>
Particles::Particles(const GpuContext& ctx,
@@ -49,7 +49,7 @@ Particles::Particles(const GpuContext& ctx,
ResourceBinding compute_bindings[] = {
{particles_buffer_, WGPUBufferBindingType_Storage},
{uniforms_.get(), WGPUBufferBindingType_Uniform}};
- compute_pass_ = gpu_create_compute_pass(ctx_.device, particle_compute_v2_wgsl,
+ compute_pass_ = gpu_create_compute_pass(ctx_.device, particle_compute_wgsl,
compute_bindings, 2);
compute_pass_.workgroup_size_x = (NUM_PARTICLES + 63) / 64;
@@ -58,7 +58,7 @@ Particles::Particles(const GpuContext& ctx,
{particles_buffer_, WGPUBufferBindingType_ReadOnlyStorage},
{uniforms_.get(), WGPUBufferBindingType_Uniform}};
render_pass_ = gpu_create_render_pass(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- particle_render_v2_wgsl, render_bindings, 2);
+ particle_render_wgsl, render_bindings, 2);
render_pass_.vertex_count = 6;
render_pass_.instance_count = NUM_PARTICLES;
}
diff --git a/src/effects/passthrough_effect.cc b/src/effects/passthrough_effect.cc
index 7c1cf09..94da241 100644
--- a/src/effects/passthrough_effect.cc
+++ b/src/effects/passthrough_effect.cc
@@ -1,9 +1,9 @@
-// Passthrough effect v2 implementation
+// Passthrough effect implementation
#include "effects/passthrough_effect.h"
#include "util/fatal_error.h"
#include "gpu/post_process_helper.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
Passthrough::Passthrough(const GpuContext& ctx,
const std::vector<std::string>& inputs,
@@ -17,7 +17,7 @@ Passthrough::Passthrough(const GpuContext& ctx,
uniforms_buffer_.init(ctx_.device);
// Create pipeline (simple version without effect params)
pipeline_ = create_post_process_pipeline_simple(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- passthrough_v2_shader_wgsl);
+ passthrough_shader_wgsl);
// Create sampler
WGPUSamplerDescriptor sampler_desc = {};
diff --git a/src/effects/placeholder_effect.cc b/src/effects/placeholder_effect.cc
index 6127e0c..73ee5a8 100644
--- a/src/effects/placeholder_effect.cc
+++ b/src/effects/placeholder_effect.cc
@@ -1,9 +1,9 @@
-// Placeholder effect v2 implementation - logs TODO warning once
+// Placeholder effect implementation - logs TODO warning once
#include "effects/placeholder_effect.h"
#include "util/fatal_error.h"
#include "gpu/post_process_helper.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include <cstdio>
Placeholder::Placeholder(const GpuContext& ctx,
@@ -13,14 +13,14 @@ Placeholder::Placeholder(const GpuContext& ctx,
: Effect(ctx, inputs, outputs), pipeline_(nullptr), bind_group_(nullptr),
sampler_(nullptr), name_(placeholder_name) {
// Log once on construction
- fprintf(stderr, "TODO: %s not yet ported to v2, using passthrough\n", name_);
+ fprintf(stderr, "TODO: %s not yet implemented, using passthrough\n", name_);
// Headless mode: skip GPU resource creation (compiled out in STRIP_ALL)
HEADLESS_RETURN_IF_NULL(ctx_.device);
uniforms_buffer_.init(ctx_.device);
pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- passthrough_v2_shader_wgsl);
+ passthrough_shader_wgsl);
WGPUSamplerDescriptor sampler_desc = {};
sampler_desc.addressModeU = WGPUAddressMode_ClampToEdge;
diff --git a/src/effects/rotating_cube_effect.cc b/src/effects/rotating_cube_effect.cc
index a91bc78..c892dfe 100644
--- a/src/effects/rotating_cube_effect.cc
+++ b/src/effects/rotating_cube_effect.cc
@@ -1,11 +1,11 @@
// This file is part of the 64k demo project.
-// It implements RotatingCube (simplified v2 port).
+// It implements RotatingCube.
#include "util/fatal_error.h"
#include "effects/rotating_cube_effect.h"
#include "gpu/bind_group_builder.h"
#include "gpu/gpu.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
RotatingCube::RotatingCube(const GpuContext& ctx,
const std::vector<std::string>& inputs,
@@ -39,10 +39,10 @@ RotatingCube::RotatingCube(const GpuContext& ctx,
WGPUPipelineLayout pipeline_layout =
wgpuDeviceCreatePipelineLayout(ctx_.device, &pl_desc);
- // Load shader (TODO: create rotating_cube_v2.wgsl)
+ // Load shader
WGPUShaderSourceWGSL wgsl_src = {};
wgsl_src.chain.sType = WGPUSType_ShaderSourceWGSL;
- wgsl_src.code = str_view(rotating_cube_v2_wgsl);
+ wgsl_src.code = str_view(rotating_cube_wgsl);
WGPUShaderModuleDescriptor shader_desc = {};
shader_desc.nextInChain = &wgsl_src.chain;
diff --git a/src/gpu/shaders.cc b/src/effects/shaders.cc
index 4017726..a9a82de 100644
--- a/src/gpu/shaders.cc
+++ b/src/effects/shaders.cc
@@ -1,22 +1,16 @@
// This file is part of the 64k demo project.
// It defines WGSL shader code for various effects.
-#include "demo_effects.h"
+#include "effects/shaders.h"
+#include "gpu/shader_composer.h"
+#include "util/asset_manager.h"
#if defined(USE_TEST_ASSETS)
-
#include "test_assets.h"
-
#else
-
#include "generated/assets.h"
-
#endif
-#include "gpu/shader_composer.h"
-
-#include "util/asset_manager.h"
-
void InitShaderComposer() {
auto& sc = ShaderComposer::Get();
@@ -79,106 +73,37 @@ void InitShaderComposer() {
}
// Helper to get asset string or empty string
-
static const char* SafeGetAsset(AssetId id) {
const uint8_t* data = GetAsset(id);
-
return data ? (const char*)data : "";
}
-const char* main_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_MAIN);
-
+// Effect shaders
+const char* passthrough_shader_wgsl =
+ SafeGetAsset(AssetId::ASSET_SHADER_PASSTHROUGH_V2);
+const char* gaussian_blur_shader_wgsl =
+ SafeGetAsset(AssetId::ASSET_SHADER_GAUSSIAN_BLUR_V2);
+const char* heptagon_shader_wgsl =
+ SafeGetAsset(AssetId::ASSET_SHADER_HEPTAGON_V2);
const char* particle_compute_wgsl =
-
SafeGetAsset(AssetId::ASSET_SHADER_PARTICLE_COMPUTE);
-
const char* particle_render_wgsl =
-
SafeGetAsset(AssetId::ASSET_SHADER_PARTICLE_RENDER);
+const char* rotating_cube_wgsl =
+ SafeGetAsset(AssetId::ASSET_SHADER_ROTATING_CUBE_V2);
+const char* flash_shader_wgsl =
+ SafeGetAsset(AssetId::ASSET_SHADER_FLASH);
-const char* passthrough_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_PASSTHROUGH);
-
-const char* ellipse_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_ELLIPSE);
-
-const char* particle_spray_compute_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_PARTICLE_SPRAY_COMPUTE);
-
-const char* gaussian_blur_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_GAUSSIAN_BLUR);
-
-const char* solarize_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_SOLARIZE);
-
-// const char* scene1_shader_wgsl =
-// SafeGetAsset(AssetId::ASSET_SHADER_SCENE1);
-
-// const char* sdf_test_shader_wgsl =
-// SafeGetAsset(AssetId::ASSET_SHADER_SDF_TEST);
-
-const char* distort_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_DISTORT);
-
-const char* chroma_aberration_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_CHROMA_ABERRATION);
-
-// const char* cnn_layer_shader_wgsl =
-// SafeGetAsset(AssetId::ASSET_SHADER_CNN_LAYER);
-
+// Compute shaders
const char* gen_noise_compute_wgsl =
-
SafeGetAsset(AssetId::ASSET_SHADER_COMPUTE_GEN_NOISE);
-
const char* gen_perlin_compute_wgsl =
-
SafeGetAsset(AssetId::ASSET_SHADER_COMPUTE_GEN_PERLIN);
-
const char* gen_grid_compute_wgsl =
-
SafeGetAsset(AssetId::ASSET_SHADER_COMPUTE_GEN_GRID);
-
#if !defined(STRIP_GPU_COMPOSITE)
const char* gen_blend_compute_wgsl =
-
SafeGetAsset(AssetId::ASSET_SHADER_COMPUTE_GEN_BLEND);
-
const char* gen_mask_compute_wgsl =
-
SafeGetAsset(AssetId::ASSET_SHADER_COMPUTE_GEN_MASK);
#endif
-
-const char* vignette_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_VIGNETTE);
-
-// Sequence v2 shaders
-const char* passthrough_v2_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_PASSTHROUGH_V2);
-
-const char* gaussian_blur_v2_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_GAUSSIAN_BLUR_V2);
-
-const char* heptagon_v2_shader_wgsl =
-
- SafeGetAsset(AssetId::ASSET_SHADER_HEPTAGON_V2);
-
-const char* particle_compute_v2_wgsl =
- SafeGetAsset(AssetId::ASSET_SHADER_PARTICLE_COMPUTE);
-
-const char* particle_render_v2_wgsl =
- SafeGetAsset(AssetId::ASSET_SHADER_PARTICLE_RENDER);
-
-const char* rotating_cube_v2_wgsl =
- SafeGetAsset(AssetId::ASSET_SHADER_ROTATING_CUBE_V2);
-
-const char* flash_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_FLASH);
diff --git a/src/effects/shaders.h b/src/effects/shaders.h
new file mode 100644
index 0000000..b8700f5
--- /dev/null
+++ b/src/effects/shaders.h
@@ -0,0 +1,25 @@
+// This file is part of the 64k demo project.
+// It declares the WGSL shader strings and initialization function.
+
+#pragma once
+
+// Initializes the ShaderComposer with snippet assets.
+void InitShaderComposer();
+
+// Effect shaders
+extern const char* passthrough_shader_wgsl;
+extern const char* gaussian_blur_shader_wgsl;
+extern const char* heptagon_shader_wgsl;
+extern const char* particle_compute_wgsl;
+extern const char* particle_render_wgsl;
+extern const char* rotating_cube_wgsl;
+extern const char* flash_shader_wgsl;
+
+// Compute shaders
+extern const char* gen_noise_compute_wgsl;
+extern const char* gen_perlin_compute_wgsl;
+extern const char* gen_grid_compute_wgsl;
+#if !defined(STRIP_GPU_COMPOSITE)
+extern const char* gen_blend_compute_wgsl;
+extern const char* gen_mask_compute_wgsl;
+#endif
diff --git a/src/gpu/demo_effects.h b/src/gpu/demo_effects.h
index 999deb1..d98045e 100644
--- a/src/gpu/demo_effects.h
+++ b/src/gpu/demo_effects.h
@@ -12,7 +12,7 @@
#include "gpu/effect.h"
#include "gpu/post_process_helper.h"
#include "gpu/sequence.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "gpu/texture_manager.h"
#include "gpu/uniform_helper.h"
diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc
index 805e555..9955169 100644
--- a/src/gpu/gpu.cc
+++ b/src/gpu/gpu.cc
@@ -5,7 +5,7 @@
#include "gpu.h"
#include "generated/timeline.h"
#include "gpu/shader_composer.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "platform/platform.h"
#include <cassert>
diff --git a/src/gpu/shaders.h b/src/gpu/shaders.h
deleted file mode 100644
index 4fee863..0000000
--- a/src/gpu/shaders.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// This file is part of the 64k demo project.
-// 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;
-extern const char* particle_render_wgsl;
-extern const char* passthrough_shader_wgsl;
-extern const char* ellipse_shader_wgsl;
-extern const char* particle_spray_compute_wgsl;
-extern const char* gaussian_blur_shader_wgsl;
-extern const char* solarize_shader_wgsl;
-extern const char* scene1_shader_wgsl;
-extern const char* sdf_test_shader_wgsl;
-extern const char* distort_shader_wgsl;
-extern const char* chroma_aberration_shader_wgsl;
-extern const char* vignette_shader_wgsl;
-extern const char* cnn_layer_shader_wgsl;
-extern const char* gen_noise_compute_wgsl;
-extern const char* gen_perlin_compute_wgsl;
-extern const char* gen_grid_compute_wgsl;
-#if !defined(STRIP_GPU_COMPOSITE)
-extern const char* gen_blend_compute_wgsl;
-extern const char* gen_mask_compute_wgsl;
-#endif
-
-// Sequence v2 shaders
-extern const char* passthrough_v2_shader_wgsl;
-extern const char* gaussian_blur_v2_shader_wgsl;
-extern const char* heptagon_v2_shader_wgsl;
-extern const char* particle_compute_v2_wgsl;
-extern const char* particle_render_v2_wgsl;
-extern const char* rotating_cube_v2_wgsl;
-extern const char* flash_shader_wgsl;
diff --git a/src/tests/3d/test_3d_physics.cc b/src/tests/3d/test_3d_physics.cc
index 26b9bfa..7858f2f 100644
--- a/src/tests/3d/test_3d_physics.cc
+++ b/src/tests/3d/test_3d_physics.cc
@@ -9,7 +9,7 @@
#include "3d/renderer.h"
#include "3d/renderer_helpers.h"
#include "3d/scene.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "gpu/texture_manager.h"
#include "platform/platform.h"
#include "procedural/generator.h"
diff --git a/src/tests/3d/test_3d_render.cc b/src/tests/3d/test_3d_render.cc
index 9398649..f802a40 100644
--- a/src/tests/3d/test_3d_render.cc
+++ b/src/tests/3d/test_3d_render.cc
@@ -8,7 +8,7 @@
#include "3d/renderer_helpers.h"
#include "3d/scene.h"
#include "generated/assets.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "gpu/texture_manager.h"
#include "platform/platform.h"
#include "procedural/generator.h"
diff --git a/src/tests/3d/test_mesh.cc b/src/tests/3d/test_mesh.cc
index 2a13125..746cfb1 100644
--- a/src/tests/3d/test_mesh.cc
+++ b/src/tests/3d/test_mesh.cc
@@ -7,7 +7,7 @@
#include "3d/renderer.h"
#include "3d/renderer_helpers.h"
#include "3d/scene.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "gpu/texture_manager.h"
#include "platform/platform.h"
#include "procedural/generator.h"
diff --git a/src/tests/gpu/test_noise_functions.cc b/src/tests/gpu/test_noise_functions.cc
index eddd88e..4e1791f 100644
--- a/src/tests/gpu/test_noise_functions.cc
+++ b/src/tests/gpu/test_noise_functions.cc
@@ -3,7 +3,7 @@
#include "generated/assets.h"
#include "gpu/shader_composer.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include <cassert>
#include <cstdio>
#include <cstring>
diff --git a/src/tests/gpu/test_sequence_e2e.cc b/src/tests/gpu/test_sequence_e2e.cc
index 46c6ec1..6ae82bd 100644
--- a/src/tests/gpu/test_sequence_e2e.cc
+++ b/src/tests/gpu/test_sequence_e2e.cc
@@ -6,7 +6,7 @@
#include "effects/gaussian_blur_effect.h"
#include "effects/heptagon_effect.h"
#include "effects/passthrough_effect.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "tests/common/webgpu_test_fixture.h"
#include <cassert>
#include <cstdio>
diff --git a/src/tests/gpu/test_shader_compilation.cc b/src/tests/gpu/test_shader_compilation.cc
index 3a7c2cf..3f2219d 100644
--- a/src/tests/gpu/test_shader_compilation.cc
+++ b/src/tests/gpu/test_shader_compilation.cc
@@ -7,7 +7,7 @@
#include "generated/assets.h"
#include "gpu/shader_composer.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "platform/platform.h"
#include <cassert>
#include <cstdio>