diff options
Diffstat (limited to 'src/effects/passthrough_effect_v2.cc')
| -rw-r--r-- | src/effects/passthrough_effect_v2.cc | 44 |
1 files changed, 16 insertions, 28 deletions
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; |
