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.cc40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc
index f115ac5..f24fa96 100644
--- a/src/gpu/effect.cc
+++ b/src/gpu/effect.cc
@@ -150,13 +150,17 @@ void MainSequence::init(WGPUDevice d, WGPUQueue q, WGPUTextureFormat f,
device = d;
queue = q;
format = f;
+ width_ = width;
+ height_ = height;
create_framebuffers(width, height);
passthrough_effect_ =
std::make_unique<PassthroughEffect>(device, queue, format);
+ passthrough_effect_->resize(width, height);
for (ActiveSequence& entry : sequences_) {
entry.seq->init(this);
+ entry.seq->resize(width, height);
}
}
@@ -166,6 +170,7 @@ void MainSequence::add_sequence(std::shared_ptr<Sequence> seq, float start_time,
// If MainSequence is already initialized, init the new sequence immediately
if (device) {
seq->init(this);
+ seq->resize(width_, height_);
}
std::sort(sequences_.begin(), sequences_.end(),
[](const ActiveSequence& a, const ActiveSequence& b) {
@@ -174,17 +179,29 @@ void MainSequence::add_sequence(std::shared_ptr<Sequence> seq, float start_time,
}
void MainSequence::resize(int width, int height) {
+ width_ = width;
+ height_ = height;
// Release old resources
- if (framebuffer_view_a_) wgpuTextureViewRelease(framebuffer_view_a_);
- if (framebuffer_a_) wgpuTextureRelease(framebuffer_a_);
- if (framebuffer_view_b_) wgpuTextureViewRelease(framebuffer_view_b_);
- if (framebuffer_b_) wgpuTextureRelease(framebuffer_b_);
- if (depth_view_) wgpuTextureViewRelease(depth_view_);
- if (depth_texture_) wgpuTextureRelease(depth_texture_);
+ if (framebuffer_view_a_)
+ wgpuTextureViewRelease(framebuffer_view_a_);
+ if (framebuffer_a_)
+ wgpuTextureRelease(framebuffer_a_);
+ if (framebuffer_view_b_)
+ wgpuTextureViewRelease(framebuffer_view_b_);
+ if (framebuffer_b_)
+ wgpuTextureRelease(framebuffer_b_);
+ if (depth_view_)
+ wgpuTextureViewRelease(depth_view_);
+ if (depth_texture_)
+ wgpuTextureRelease(depth_texture_);
// Recreate with new size
create_framebuffers(width, height);
+ if (passthrough_effect_) {
+ passthrough_effect_->resize(width, height);
+ }
+
// Propagate to all sequences
for (ActiveSequence& entry : sequences_) {
entry.seq->resize(width, height);
@@ -193,6 +210,11 @@ void MainSequence::resize(int width, int height) {
void MainSequence::render_frame(float global_time, float beat, float peak,
float aspect_ratio, WGPUSurface surface) {
+ static bool first_frame = true;
+ if (first_frame) {
+ printf("MainSequence First Frame: %dx%d\n", width_, height_);
+ first_frame = false;
+ }
WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
std::vector<SequenceItem*> scene_effects;
@@ -242,6 +264,8 @@ void MainSequence::render_frame(float global_time, float beat, float peak,
&depth_attachment};
WGPURenderPassEncoder scene_pass =
wgpuCommandEncoderBeginRenderPass(encoder, &scene_desc);
+ wgpuRenderPassEncoderSetViewport(scene_pass, 0.0f, 0.0f, (float)width_,
+ (float)height_, 0.0f, 1.0f);
for (const SequenceItem* item : scene_effects) {
item->effect->render(scene_pass, global_time - item->start_time, beat, peak,
aspect_ratio);
@@ -273,6 +297,8 @@ void MainSequence::render_frame(float global_time, float beat, float peak,
.colorAttachmentCount = 1, .colorAttachments = &final_attachment};
WGPURenderPassEncoder final_pass =
wgpuCommandEncoderBeginRenderPass(encoder, &final_desc);
+ wgpuRenderPassEncoderSetViewport(final_pass, 0.0f, 0.0f, (float)width_,
+ (float)height_, 0.0f, 1.0f);
passthrough_effect_->render(final_pass, 0, 0, 0, aspect_ratio);
wgpuRenderPassEncoderEnd(final_pass);
} else {
@@ -307,6 +333,8 @@ void MainSequence::render_frame(float global_time, float beat, float peak,
.colorAttachments = &pp_attachment};
WGPURenderPassEncoder pp_pass =
wgpuCommandEncoderBeginRenderPass(encoder, &pp_desc);
+ wgpuRenderPassEncoderSetViewport(pp_pass, 0.0f, 0.0f, (float)width_,
+ (float)height_, 0.0f, 1.0f);
pp->render(pp_pass, global_time - post_effects[i]->start_time, beat, peak,
aspect_ratio);
wgpuRenderPassEncoderEnd(pp_pass);