diff options
| -rw-r--r-- | src/gpu/demo_effects.h | 2 | ||||
| -rw-r--r-- | src/gpu/effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/cnn_effect.cc | 2 | ||||
| -rw-r--r-- | src/platform/stub_types.h | 3 | ||||
| -rw-r--r-- | tools/seq_compiler.cc | 90 |
5 files changed, 98 insertions, 6 deletions
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; diff --git a/src/platform/stub_types.h b/src/platform/stub_types.h index f532e04..ff9cccf 100644 --- a/src/platform/stub_types.h +++ b/src/platform/stub_types.h @@ -47,8 +47,9 @@ typedef enum { } WGPUBufferBindingType; typedef enum { - WGPULoadOp_Clear = 0, + WGPULoadOp_Undefined = 0, WGPULoadOp_Load = 1, + WGPULoadOp_Clear = 2, } WGPULoadOp; typedef enum { diff --git a/tools/seq_compiler.cc b/tools/seq_compiler.cc index fad2d88..ecb9908 100644 --- a/tools/seq_compiler.cc +++ b/tools/seq_compiler.cc @@ -7,6 +7,7 @@ #include <fstream> #include <iomanip> #include <iostream> +#include <map> #include <numeric> #include <sstream> #include <string> @@ -58,6 +59,25 @@ parse_parameters(const std::string& args) { return params; } +// Check if an effect is a post-process effect +bool is_post_process_effect(const std::string& class_name) { + // List of known post-process effects + static const std::vector<std::string> post_process_effects = { + "FadeEffect", + "FlashEffect", + "GaussianBlurEffect", + "SolarizeEffect", + "VignetteEffect", + "ChromaAberrationEffect", + "DistortEffect", + "ThemeModulationEffect", + "CNNEffect", + "PassthroughEffect", + "CircleMaskEffect"}; + return std::find(post_process_effects.begin(), post_process_effects.end(), + class_name) != post_process_effects.end(); +} + // Calculate adaptive tick interval based on timeline duration int calculate_tick_interval(float max_time) { if (max_time <= 5) @@ -882,6 +902,76 @@ int main(int argc, char* argv[]) { }); } + // Validate: detect priority collisions among post-process effects + for (size_t seq_idx = 0; seq_idx < sequences.size(); ++seq_idx) { + const auto& seq = sequences[seq_idx]; + std::map<int, std::vector<std::string>> priority_map; + + // Group post-process effects by priority + for (const auto& eff : seq.effects) { + if (is_post_process_effect(eff.class_name)) { + int prio = std::stoi(eff.priority); + priority_map[prio].push_back(eff.class_name); + } + } + + // Check for collisions + for (const auto& [prio, effects] : priority_map) { + if (effects.size() > 1) { + std::cerr << "Warning: Priority collision detected in sequence at time " + << seq.start_time << "s\n"; + std::cerr << " Multiple post-process effects have priority " << prio + << ":\n"; + for (const auto& effect : effects) { + std::cerr << " - " << effect << "\n"; + } + std::cerr << " This may cause unexpected render order. Consider " + "adjusting priorities.\n"; + } + } + } + + // Validate: detect cross-sequence priority collisions for concurrent sequences + std::map<std::string, std::vector<size_t>> time_groups; + for (size_t i = 0; i < sequences.size(); ++i) { + time_groups[sequences[i].start_time].push_back(i); + } + + for (const auto& [start_time, seq_indices] : time_groups) { + if (seq_indices.size() > 1) { + // Multiple sequences start at the same time + std::map<int, std::vector<std::pair<std::string, size_t>>> cross_priority_map; + + for (size_t seq_idx : seq_indices) { + const auto& seq = sequences[seq_idx]; + for (const auto& eff : seq.effects) { + if (is_post_process_effect(eff.class_name)) { + int prio = std::stoi(eff.priority); + cross_priority_map[prio].push_back({eff.class_name, seq_idx}); + } + } + } + + // Check for cross-sequence collisions + for (const auto& [prio, effects] : cross_priority_map) { + if (effects.size() > 1) { + std::cerr << "Warning: Cross-sequence priority collision at time " + << start_time << "s\n"; + std::cerr << " Multiple post-process effects across sequences have " + "priority " + << prio << ":\n"; + for (const auto& [effect, seq_idx] : effects) { + std::cerr << " - " << effect << " (sequence #" << seq_idx << ")\n"; + } + std::cerr << " Post-process effects from different sequences at the " + "same time will be\n"; + std::cerr << " merged into a single render chain. Consider adjusting " + "priorities to clarify order.\n"; + } + } + } + } + // Generate C++ code if output file is specified if (!output_cc.empty()) { std::ofstream out_file(output_cc); |
