summaryrefslogtreecommitdiff
path: root/src/effects
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-16 08:58:46 +0100
committerskal <pascal.massimino@gmail.com>2026-02-16 08:58:46 +0100
commit04938fc4a3335e1459e5fb23d0d091fd2a40c296 (patch)
tree769ab31b1545e17e42e10bf5b35b5ea9d35564f3 /src/effects
parent79fc9fc1e56ef78dfb7b9732febc8c8777fac9fb (diff)
feat(sequence): complete phase 3 - v2 shader integration and effect ports
- Create v2-compatible WGSL shaders with UniformsSequenceParams - Add sequence_v2_uniforms snippet for ShaderComposer - Port 3 effects: PassthroughEffectV2, GaussianBlurEffectV2, HeptagonEffectV2 - Enable and fix end-to-end test (test_sequence_v2_e2e) - Fix shader binding order (sampler at 0, texture at 1) - Fix WebGPU validation (maxAnisotropy=1, explicit depthSlice) - Add v2 shaders to main and test workspace assets - All tests passing (36/36) handoff(Claude): Phase 3 complete, v2 effects functional, ready for phase 4
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/gaussian_blur_effect_v2.cc3
-rw-r--r--src/effects/heptagon_effect_v2.cc2
-rw-r--r--src/effects/passthrough_effect_v2.cc44
-rw-r--r--src/effects/passthrough_effect_v2.h2
4 files changed, 21 insertions, 30 deletions
diff --git a/src/effects/gaussian_blur_effect_v2.cc b/src/effects/gaussian_blur_effect_v2.cc
index 6b37f0b..f87de8b 100644
--- a/src/effects/gaussian_blur_effect_v2.cc
+++ b/src/effects/gaussian_blur_effect_v2.cc
@@ -11,7 +11,7 @@ GaussianBlurEffectV2::GaussianBlurEffectV2(const GpuContext& ctx,
sampler_(nullptr) {
// Create pipeline
pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- gaussian_blur_shader_wgsl);
+ gaussian_blur_v2_shader_wgsl);
// Create sampler
WGPUSamplerDescriptor sampler_desc = {};
@@ -19,6 +19,7 @@ GaussianBlurEffectV2::GaussianBlurEffectV2(const GpuContext& ctx,
sampler_desc.addressModeV = WGPUAddressMode_ClampToEdge;
sampler_desc.magFilter = WGPUFilterMode_Linear;
sampler_desc.minFilter = WGPUFilterMode_Linear;
+ sampler_desc.maxAnisotropy = 1;
sampler_ = wgpuDeviceCreateSampler(ctx_.device, &sampler_desc);
// Init uniform buffers
diff --git a/src/effects/heptagon_effect_v2.cc b/src/effects/heptagon_effect_v2.cc
index 4478327..3512ec7 100644
--- a/src/effects/heptagon_effect_v2.cc
+++ b/src/effects/heptagon_effect_v2.cc
@@ -14,7 +14,7 @@ HeptagonEffectV2::HeptagonEffectV2(const GpuContext& ctx,
// Create render pass using helper
ResourceBinding bindings[] = {{uniforms_buffer_.get(), WGPUBufferBindingType_Uniform}};
RenderPass pass = gpu_create_render_pass(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- main_shader_wgsl, bindings, 1);
+ heptagon_v2_shader_wgsl, bindings, 1);
pipeline_ = pass.pipeline;
bind_group_ = pass.bind_group;
}
diff --git a/src/effects/passthrough_effect_v2.cc b/src/effects/passthrough_effect_v2.cc
index d98315f..5203f97 100644
--- a/src/effects/passthrough_effect_v2.cc
+++ b/src/effects/passthrough_effect_v2.cc
@@ -9,9 +9,11 @@ PassthroughEffectV2::PassthroughEffectV2(const GpuContext& ctx,
const std::vector<std::string>& outputs)
: EffectV2(ctx, inputs, outputs), pipeline_(nullptr), bind_group_(nullptr),
sampler_(nullptr) {
+ // Init uniform buffer
+ uniforms_buffer_.init(ctx_.device);
// Create pipeline
pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- passthrough_shader_wgsl);
+ passthrough_v2_shader_wgsl);
// Create sampler
WGPUSamplerDescriptor sampler_desc = {};
@@ -21,6 +23,7 @@ PassthroughEffectV2::PassthroughEffectV2(const GpuContext& ctx,
sampler_desc.magFilter = WGPUFilterMode_Linear;
sampler_desc.minFilter = WGPUFilterMode_Linear;
sampler_desc.mipmapFilter = WGPUMipmapFilterMode_Nearest;
+ sampler_desc.maxAnisotropy = 1;
sampler_ = wgpuDeviceCreateSampler(ctx_.device, &sampler_desc);
}
@@ -31,36 +34,21 @@ void PassthroughEffectV2::render(WGPUCommandEncoder encoder,
WGPUTextureView input_view = nodes.get_view(input_nodes_[0]);
WGPUTextureView output_view = nodes.get_view(output_nodes_[0]);
- // Update bind group (recreate each frame for simplicity)
- WGPUBindGroupEntry entries[3] = {};
+ // Update uniforms
+ uniforms_buffer_.update(ctx_.queue, params);
- entries[0].binding = PP_BINDING_SAMPLER;
- entries[0].sampler = sampler_;
-
- entries[1].binding = PP_BINDING_TEXTURE;
- entries[1].textureView = input_view;
-
- // Uniforms (binding 2) - use empty buffer for now
- entries[2].binding = PP_BINDING_UNIFORMS;
- entries[2].buffer = nullptr;
- entries[2].size = 0;
-
- WGPUBindGroupDescriptor bg_desc = {};
- bg_desc.layout = wgpuRenderPipelineGetBindGroupLayout(pipeline_, 0);
- bg_desc.entryCount = 2; // Only sampler and texture, no uniforms
- bg_desc.entries = entries;
-
- if (bind_group_) {
- wgpuBindGroupRelease(bind_group_);
- }
- bind_group_ = wgpuDeviceCreateBindGroup(ctx_.device, &bg_desc);
+ // Update bind group using helper (handles dummy buffers)
+ pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view,
+ uniforms_buffer_.get(), {nullptr, 0});
// Render pass
- WGPURenderPassColorAttachment color_attachment = {};
- color_attachment.view = output_view;
- color_attachment.loadOp = WGPULoadOp_Clear;
- color_attachment.storeOp = WGPUStoreOp_Store;
- color_attachment.clearValue = {0.0, 0.0, 0.0, 1.0};
+ WGPURenderPassColorAttachment color_attachment = {
+ .view = output_view,
+ .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
+ .loadOp = WGPULoadOp_Clear,
+ .storeOp = WGPUStoreOp_Store,
+ .clearValue = {0.0, 0.0, 0.0, 1.0}
+ };
WGPURenderPassDescriptor pass_desc = {};
pass_desc.colorAttachmentCount = 1;
diff --git a/src/effects/passthrough_effect_v2.h b/src/effects/passthrough_effect_v2.h
index 813361e..a272b87 100644
--- a/src/effects/passthrough_effect_v2.h
+++ b/src/effects/passthrough_effect_v2.h
@@ -3,6 +3,7 @@
#pragma once
#include "gpu/effect_v2.h"
+#include "gpu/uniform_helper.h"
class PassthroughEffectV2 : public EffectV2 {
public:
@@ -16,4 +17,5 @@ class PassthroughEffectV2 : public EffectV2 {
WGPURenderPipeline pipeline_;
WGPUBindGroup bind_group_;
WGPUSampler sampler_;
+ UniformBuffer<UniformsSequenceParams> uniforms_buffer_;
};