diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-20 12:08:34 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-20 12:08:34 +0100 |
| commit | 850388bcaabf057beed8f126002b7b663183b2d8 (patch) | |
| tree | f55fad742d99dc91d2bf32ad54a27f95e8a183f3 /src | |
| parent | 1030807a58c8f4315d209c3756a9f98d8dc6bd91 (diff) | |
feat(sequence): port Scene1Effect + fix seq_compiler absolute time bug
- Add Scene1 effect: raymarching cube+sphere+ground (reflections, shadows)
- Fix scene1.wgsl: binding 0→2, CommonUniforms→UniformsSequenceParams
- Replace Heptagon+Placeholder stub in heptagon_scene with Scene1
- Fix seq_compiler.py: emit seq.start_time+effect.start/end (absolute times)
so dispatch_render active check works correctly for all sequences
Bug: effects in sequences starting after t=0 were never active because
local times (e.g. 0-8) never satisfied params.time<end for absolute time 20+.
34/34 tests passing.
handoff(Gemini): seq_compiler now emits absolute effect times. All existing
sequences affected — verify visual output across the full timeline.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/effects/scene1_effect.cc | 45 | ||||
| -rw-r--r-- | src/effects/scene1_effect.h | 21 | ||||
| -rw-r--r-- | src/effects/shaders.cc | 1 | ||||
| -rw-r--r-- | src/effects/shaders.h | 1 | ||||
| -rw-r--r-- | src/gpu/demo_effects.h | 1 | ||||
| -rw-r--r-- | src/tests/gpu/test_demo_effects.cc | 3 |
6 files changed, 72 insertions, 0 deletions
diff --git a/src/effects/scene1_effect.cc b/src/effects/scene1_effect.cc new file mode 100644 index 0000000..7c109e7 --- /dev/null +++ b/src/effects/scene1_effect.cc @@ -0,0 +1,45 @@ +// Scene1 effect implementation + +#include "effects/scene1_effect.h" +#include "effects/shaders.h" +#include "gpu/gpu.h" +#include "gpu/post_process_helper.h" +#include "util/fatal_error.h" + +Scene1::Scene1(const GpuContext& ctx, const std::vector<std::string>& inputs, + const std::vector<std::string>& outputs, float start_time, + float end_time) + : Effect(ctx, inputs, outputs, start_time, end_time) { + HEADLESS_RETURN_IF_NULL(ctx_.device); + + create_nearest_sampler(); + create_dummy_scene_texture(); + + pipeline_.set(create_post_process_pipeline( + ctx_.device, WGPUTextureFormat_RGBA8Unorm, scene1_shader_wgsl)); +} + +void Scene1::render(WGPUCommandEncoder encoder, + const UniformsSequenceParams& params, + NodeRegistry& nodes) { + WGPUTextureView output_view = nodes.get_view(output_nodes_[0]); + + pp_update_bind_group(ctx_.device, pipeline_.get(), bind_group_.get_address(), + dummy_texture_view_.get(), uniforms_buffer_.get(), + {nullptr, 0}); + + WGPURenderPassColorAttachment color_attachment = {}; + gpu_init_color_attachment(color_attachment, output_view); + + WGPURenderPassDescriptor pass_desc = {}; + pass_desc.colorAttachmentCount = 1; + pass_desc.colorAttachments = &color_attachment; + + WGPURenderPassEncoder pass = + wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc); + wgpuRenderPassEncoderSetPipeline(pass, pipeline_.get()); + wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_.get(), 0, nullptr); + wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); // Fullscreen triangle + wgpuRenderPassEncoderEnd(pass); + wgpuRenderPassEncoderRelease(pass); +} diff --git a/src/effects/scene1_effect.h b/src/effects/scene1_effect.h new file mode 100644 index 0000000..781cbae --- /dev/null +++ b/src/effects/scene1_effect.h @@ -0,0 +1,21 @@ +// Scene1 effect - raymarching cube & sphere scene + +#pragma once + +#include "gpu/effect.h" +#include "gpu/uniform_helper.h" +#include "gpu/wgpu_resource.h" + +class Scene1 : public Effect { + public: + Scene1(const GpuContext& ctx, const std::vector<std::string>& inputs, + const std::vector<std::string>& outputs, float start_time, + float end_time); + + void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params, + NodeRegistry& nodes) override; + + private: + RenderPipeline pipeline_; + BindGroup bind_group_; +}; diff --git a/src/effects/shaders.cc b/src/effects/shaders.cc index d181632..4329427 100644 --- a/src/effects/shaders.cc +++ b/src/effects/shaders.cc @@ -92,6 +92,7 @@ const char* particle_render_wgsl = const char* rotating_cube_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_ROTATING_CUBE_V2); const char* flash_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_FLASH); +const char* scene1_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_SCENE1); // Compute shaders const char* gen_noise_compute_wgsl = diff --git a/src/effects/shaders.h b/src/effects/shaders.h index b8700f5..ee6c65e 100644 --- a/src/effects/shaders.h +++ b/src/effects/shaders.h @@ -14,6 +14,7 @@ extern const char* particle_compute_wgsl; extern const char* particle_render_wgsl; extern const char* rotating_cube_wgsl; extern const char* flash_shader_wgsl; +extern const char* scene1_shader_wgsl; // Compute shaders extern const char* gen_noise_compute_wgsl; diff --git a/src/gpu/demo_effects.h b/src/gpu/demo_effects.h index 2825891..f746326 100644 --- a/src/gpu/demo_effects.h +++ b/src/gpu/demo_effects.h @@ -26,6 +26,7 @@ #include "effects/peak_meter_effect.h" #include "effects/placeholder_effect.h" #include "effects/rotating_cube_effect.h" +#include "effects/scene1_effect.h" // TODO: Port CNN effects // #include "../../cnn_v1/src/cnn_v1_effect.h" // #include "../../cnn_v2/src/cnn_v2_effect.h" diff --git a/src/tests/gpu/test_demo_effects.cc b/src/tests/gpu/test_demo_effects.cc index f193c76..132e489 100644 --- a/src/tests/gpu/test_demo_effects.cc +++ b/src/tests/gpu/test_demo_effects.cc @@ -64,6 +64,9 @@ static void test_effects() { {"PeakMeter", std::make_shared<PeakMeter>( fixture.ctx(), std::vector<std::string>{"source"}, std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, + {"Scene1", std::make_shared<Scene1>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, }; int passed = 0; |
