summaryrefslogtreecommitdiff
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/effect.cc6
-rw-r--r--src/gpu/effect.h13
-rw-r--r--src/gpu/sequence.cc7
-rw-r--r--src/gpu/sequence.h2
4 files changed, 14 insertions, 14 deletions
diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc
index d0693ec..a94b4a0 100644
--- a/src/gpu/effect.cc
+++ b/src/gpu/effect.cc
@@ -15,6 +15,7 @@ Effect::Effect(const GpuContext& ctx, const std::vector<std::string>& inputs,
FATAL_CHECK(start_time <= end_time, "Invalid time range: %f > %f\n",
start_time, end_time);
HEADLESS_RETURN_IF_NULL(ctx_.device);
+ uniforms_buffer_.init(ctx_.device);
}
void Effect::dispatch_render(WGPUCommandEncoder encoder,
@@ -28,6 +29,7 @@ void Effect::dispatch_render(WGPUCommandEncoder encoder,
if (!active && input_nodes_.size() == 1 && output_nodes_.size() == 1) {
blit_input_to_output(encoder, nodes);
} else if (active) {
+ uniforms_buffer_.update(ctx_.queue, params);
render(encoder, params, nodes);
}
// Multi-output effects: output undefined when inactive (validated at compile time)
@@ -57,10 +59,6 @@ void Effect::blit_input_to_output(WGPUCommandEncoder encoder,
&extent);
}
-void Effect::init_uniforms_buffer() {
- uniforms_buffer_.init(ctx_.device);
-}
-
void Effect::create_linear_sampler() {
sampler_.set(gpu_create_linear_sampler(ctx_.device));
}
diff --git a/src/gpu/effect.h b/src/gpu/effect.h
index d47a8b7..bfd5743 100644
--- a/src/gpu/effect.h
+++ b/src/gpu/effect.h
@@ -53,22 +53,19 @@ class Effect {
int width_ = 1280;
int height_ = 720;
- // Common resources for most effects
- UniformBuffer<UniformsSequenceParams> uniforms_buffer_;
+ // Common resources (initialized automatically in base class)
+ UniformBuffer<UniformsSequenceParams> uniforms_buffer_; // Auto-updated in dispatch_render()
Sampler sampler_;
Texture dummy_texture_;
TextureView dummy_texture_view_;
- // Helper: Initialize uniforms buffer (call in subclass constructor)
- void init_uniforms_buffer();
-
- // Helper: Create linear sampler (call in subclass constructor)
+ // Helper: Create linear sampler (call in subclass constructor if needed)
void create_linear_sampler();
- // Helper: Create nearest sampler (call in subclass constructor)
+ // Helper: Create nearest sampler (call in subclass constructor if needed)
void create_nearest_sampler();
- // Helper: Create dummy texture for scene effects (call in subclass constructor)
+ // Helper: Create dummy texture for scene effects (call in subclass constructor if needed)
void create_dummy_scene_texture();
private:
diff --git a/src/gpu/sequence.cc b/src/gpu/sequence.cc
index 901d560..9de4133 100644
--- a/src/gpu/sequence.cc
+++ b/src/gpu/sequence.cc
@@ -4,6 +4,7 @@
#include "gpu/effect.h"
#include "util/fatal_error.h"
#include <algorithm>
+#include <random>
// NodeRegistry implementation
@@ -227,7 +228,11 @@ void Sequence::preprocess(float seq_time, float beat_time, float beat_phase,
params_.beat_time = beat_time;
params_.beat_phase = beat_phase;
params_.audio_intensity = audio_intensity;
- params_._pad = 0.0f;
+
+ static std::random_device rd;
+ static std::mt19937 gen(rd());
+ static std::uniform_real_distribution<float> dis(0.0f, 1.0f);
+ params_.noise = dis(gen);
uniforms_buffer_.update(ctx_.queue, params_);
}
diff --git a/src/gpu/sequence.h b/src/gpu/sequence.h
index 3bb770f..2ad0a8f 100644
--- a/src/gpu/sequence.h
+++ b/src/gpu/sequence.h
@@ -38,7 +38,7 @@ struct UniformsSequenceParams {
float beat_time; // Musical beats
float beat_phase; // Fractional beat 0.0-1.0
float audio_intensity;
- float _pad;
+ float noise; // Random value [0..1]
};
static_assert(sizeof(UniformsSequenceParams) == 32,
"UniformsSequenceParams must be 32 bytes for WGSL alignment");