summaryrefslogtreecommitdiff
path: root/src/gpu/effect.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/effect.cc')
-rw-r--r--src/gpu/effect.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc
index cfef7f9..040b523 100644
--- a/src/gpu/effect.cc
+++ b/src/gpu/effect.cc
@@ -195,6 +195,44 @@ void MainSequence::render_frame(float global_time, float beat, float peak,
wgpuTextureRelease(surface_texture.texture);
}
+void MainSequence::simulate_until(float target_time, float step_rate) {
+#ifndef STRIP_ALL
+ // Assuming 128 BPM as per main.cc.
+ // Ideally this should be passed in or shared.
+ const float bpm = 128.0f;
+ const float aspect_ratio = 16.0f / 9.0f; // Dummy aspect
+
+ for (float t = 0.0f; t < target_time; t += step_rate) {
+ WGPUCommandEncoderDescriptor encoder_desc = {};
+ WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, &encoder_desc);
+
+ float beat = fmodf(t * bpm / 60.0f, 1.0f);
+
+ // Update active lists
+ for (auto &entry : sequences_) {
+ if (t >= entry.start_time) {
+ entry.seq->update_active_list(t - entry.start_time);
+ }
+ }
+
+ // Dispatch compute
+ for (auto &entry : sequences_) {
+ if (t >= entry.start_time) {
+ // peak = 0.0f during simulation (no audio analysis)
+ entry.seq->dispatch_compute(encoder, t - entry.start_time, beat, 0.0f, aspect_ratio);
+ }
+ }
+
+ WGPUCommandBufferDescriptor cmd_desc = {};
+ WGPUCommandBuffer commands = wgpuCommandEncoderFinish(encoder, &cmd_desc);
+ wgpuQueueSubmit(queue, 1, &commands);
+ }
+#else
+ (void)target_time;
+ (void)step_rate;
+#endif
+}
+
void MainSequence::shutdown() {
for (auto &entry : sequences_) {
entry.seq->reset();