From ebb1a07857fe25fdaa66b2f86303bc8fbd621cfe Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 10 Feb 2026 13:56:06 +0100 Subject: fix: Capture scene framebuffer before post-processing for CNN effect CNNEffect's "original" input was black because FadeEffect (priority 1) ran before CNNEffect (priority 1), fading the scene. Changed framebuffer capture to use framebuffer_a (scene output) instead of current_input (post-chain). Also add seq_compiler validation to detect post-process priority collisions within and across concurrent sequences, preventing similar render order issues. Updated stub_types.h WGPULoadOp enum values to match webgpu.h spec. Co-Authored-By: Claude Sonnet 4.5 --- src/gpu/demo_effects.h | 2 +- src/gpu/effect.cc | 7 ++++--- src/gpu/effects/cnn_effect.cc | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/gpu') diff --git a/src/gpu/demo_effects.h b/src/gpu/demo_effects.h index 6e6cb73..72b3f65 100644 --- a/src/gpu/demo_effects.h +++ b/src/gpu/demo_effects.h @@ -184,7 +184,7 @@ class DistortEffect : public PostProcessEffect { // (included above) FlashEffect now defined in gpu/effects/flash_effect.h // (included above) -class CNNEffect; +#include "gpu/effects/cnn_effect.h" // Auto-generated functions void LoadTimeline(MainSequence& main_seq, const GpuContext& ctx); diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc index 0662f26..b50acce 100644 --- a/src/gpu/effect.cc +++ b/src/gpu/effect.cc @@ -349,8 +349,9 @@ void MainSequence::render_frame(float global_time, float beat, float peak, WGPURenderPassColorAttachment capture_attachment = {}; capture_attachment.view = captured_view; capture_attachment.resolveTarget = nullptr; - capture_attachment.loadOp = WGPULoadOp_Load; + capture_attachment.loadOp = WGPULoadOp_Clear; capture_attachment.storeOp = WGPUStoreOp_Store; + capture_attachment.clearValue = {0.0f, 0.0f, 0.0f, 1.0f}; #if !defined(DEMO_CROSS_COMPILE_WIN32) capture_attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; #endif @@ -362,10 +363,10 @@ void MainSequence::render_frame(float global_time, float beat, float peak, (float)width_, (float)height_, 0.0f, 1.0f); - // Use passthrough effect to copy current_input to captured_frame + // Use passthrough effect to copy framebuffer_a (scene) to captured_frame PostProcessEffect* passthrough = (PostProcessEffect*)passthrough_effect_.get(); - passthrough->update_bind_group(current_input); + passthrough->update_bind_group(framebuffer_view_a_); passthrough->render(capture_pass, 0, 0, 0, aspect_ratio); wgpuRenderPassEncoderEnd(capture_pass); diff --git a/src/gpu/effects/cnn_effect.cc b/src/gpu/effects/cnn_effect.cc index f5d0a51..cb00455 100644 --- a/src/gpu/effects/cnn_effect.cc +++ b/src/gpu/effects/cnn_effect.cc @@ -142,7 +142,7 @@ void CNNEffect::update_bind_group(WGPUTextureView input_view) { bge[3].buffer = params_buffer_.get().buffer; bge[3].size = params_buffer_.get().size; bge[4].binding = 4; - bge[4].textureView = original_view_ ? original_view_ : input_view_; // Fallback + bge[4].textureView = original_view_ ? original_view_ : input_view_; WGPUBindGroupDescriptor bgd = {}; bgd.layout = bgl; -- cgit v1.2.3