diff options
Diffstat (limited to 'src/effects/heptagon_effect.cc')
| -rw-r--r-- | src/effects/heptagon_effect.cc | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/effects/heptagon_effect.cc b/src/effects/heptagon_effect.cc index 20761dc..fd83229 100644 --- a/src/effects/heptagon_effect.cc +++ b/src/effects/heptagon_effect.cc @@ -1,15 +1,16 @@ // Heptagon effect implementation #include "effects/heptagon_effect.h" -#include "util/fatal_error.h" +#include "effects/shaders.h" #include "gpu/gpu.h" #include "gpu/post_process_helper.h" -#include "effects/shaders.h" +#include "util/fatal_error.h" Heptagon::Heptagon(const GpuContext& ctx, - const std::vector<std::string>& inputs, - const std::vector<std::string>& outputs) - : Effect(ctx, inputs, outputs), pipeline_(nullptr), bind_group_(nullptr), sampler_(nullptr) { + const std::vector<std::string>& inputs, + const std::vector<std::string>& outputs) + : Effect(ctx, inputs, outputs), pipeline_(nullptr), bind_group_(nullptr), + sampler_(nullptr) { // Headless mode: skip GPU resource creation (compiled out in STRIP_ALL) HEADLESS_RETURN_IF_NULL(ctx_.device); @@ -17,8 +18,8 @@ Heptagon::Heptagon(const GpuContext& ctx, uniforms_buffer_.init(ctx_.device); // Create pipeline (standard post-process, no depth) - pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm, - heptagon_shader_wgsl); + pipeline_ = create_post_process_pipeline( + ctx_.device, WGPUTextureFormat_RGBA8Unorm, heptagon_shader_wgsl); // Create dummy sampler (scene effects don't use texture input) WGPUSamplerDescriptor sampler_desc = {}; @@ -42,16 +43,21 @@ Heptagon::Heptagon(const GpuContext& ctx, } Heptagon::~Heptagon() { - if (bind_group_) wgpuBindGroupRelease(bind_group_); - if (pipeline_) wgpuRenderPipelineRelease(pipeline_); - if (sampler_) wgpuSamplerRelease(sampler_); - if (dummy_texture_view_) wgpuTextureViewRelease(dummy_texture_view_); - if (dummy_texture_) wgpuTextureRelease(dummy_texture_); + if (bind_group_) + wgpuBindGroupRelease(bind_group_); + if (pipeline_) + wgpuRenderPipelineRelease(pipeline_); + if (sampler_) + wgpuSamplerRelease(sampler_); + if (dummy_texture_view_) + wgpuTextureViewRelease(dummy_texture_view_); + if (dummy_texture_) + wgpuTextureRelease(dummy_texture_); } void Heptagon::render(WGPUCommandEncoder encoder, - const UniformsSequenceParams& params, - NodeRegistry& nodes) { + const UniformsSequenceParams& params, + NodeRegistry& nodes) { // Get output view (scene effects typically write to output, ignore input) WGPUTextureView output_view = nodes.get_view(output_nodes_[0]); @@ -59,8 +65,9 @@ void Heptagon::render(WGPUCommandEncoder encoder, uniforms_buffer_.update(ctx_.queue, params); // Create bind group (use dummy texture for scene effect) - pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, dummy_texture_view_, - uniforms_buffer_.get(), {nullptr, 0}); + pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, + dummy_texture_view_, uniforms_buffer_.get(), + {nullptr, 0}); // Render pass WGPURenderPassColorAttachment color_attachment = {}; @@ -74,10 +81,11 @@ void Heptagon::render(WGPUCommandEncoder encoder, pass_desc.colorAttachmentCount = 1; pass_desc.colorAttachments = &color_attachment; - WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc); + WGPURenderPassEncoder pass = + wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc); wgpuRenderPassEncoderSetPipeline(pass, pipeline_); wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr); - wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); // Fullscreen triangle + wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); // Fullscreen triangle wgpuRenderPassEncoderEnd(pass); wgpuRenderPassEncoderRelease(pass); } |
