summaryrefslogtreecommitdiff
path: root/src/gpu/effects/cnn_v2_effect.h
blob: edf301e534030b576f20482568e3982c52f384a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// CNN v2 Effect - Parametric Static Features
// Multi-pass post-processing with 7D feature input

#pragma once
#include "gpu/effect.h"
#include <vector>

class CNNv2Effect : public PostProcessEffect {
public:
  explicit CNNv2Effect(const GpuContext& ctx);
  ~CNNv2Effect();

  void init(MainSequence* demo) override;
  void resize(int width, int height) override;
  void render(WGPURenderPassEncoder pass,
              const CommonPostProcessUniforms& uniforms) override;
  void update_bind_group(WGPUTextureView input_view) override;

private:
  void create_textures();
  void create_pipelines();
  void cleanup();

  // Static features compute
  WGPUComputePipeline static_pipeline_;
  WGPUBindGroup static_bind_group_;
  WGPUTexture static_features_tex_;
  WGPUTextureView static_features_view_;

  // CNN layers (opaque implementation)
  std::vector<WGPUComputePipeline> layer_pipelines_;
  std::vector<WGPUBindGroup> layer_bind_groups_;
  std::vector<WGPUTexture> layer_textures_;
  std::vector<WGPUTextureView> layer_views_;

  // Input mips
  WGPUTexture input_mip_tex_;
  WGPUTextureView input_mip_view_[3];

  bool initialized_;
};