Overte C++ Documentation
ResampleTask.h
1 //
2 // ResampleTask.h
3 // render/src/render
4 //
5 // Various to upsample or downsample textures into framebuffers.
6 //
7 // Created by Olivier Prat on 10/09/17.
8 // Copyright 2017 High Fidelity, Inc.
9 //
10 // Distributed under the Apache License, Version 2.0.
11 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
12 //
13 
14 #ifndef hifi_render_ResampleTask_h
15 #define hifi_render_ResampleTask_h
16 
17 #include "Engine.h"
18 
19 namespace render {
20 
21  class HalfDownsample {
22  public:
23  using Config = JobConfig;
24  using JobModel = Job::ModelIO<HalfDownsample, gpu::FramebufferPointer, gpu::FramebufferPointer, Config>;
25 
26  HalfDownsample();
27 
28  void configure(const Config& config);
29  void run(const RenderContextPointer& renderContext, const gpu::FramebufferPointer& sourceFramebuffer, gpu::FramebufferPointer& resampledFrameBuffer);
30 
31  protected:
32 
33  static gpu::PipelinePointer _pipeline;
34 
35  gpu::FramebufferPointer _destinationFrameBuffer;
36 
37  gpu::FramebufferPointer getResampledFrameBuffer(const gpu::FramebufferPointer& sourceFramebuffer);
38  };
39 
40  class UpsampleConfig : public render::Job::Config {
41  Q_OBJECT
42  Q_PROPERTY(float factor MEMBER factor NOTIFY dirty)
43  public:
44 
45  float factor{ 1.0f };
46 
47  signals:
48  void dirty();
49  };
50 
51  class Upsample {
52  public:
53  using Config = UpsampleConfig;
54  using JobModel = Job::ModelIO<Upsample, gpu::FramebufferPointer, gpu::FramebufferPointer, Config>;
55 
56  Upsample(float factor = 2.0f) : _factor{ factor } {}
57 
58  void configure(const Config& config);
59  void run(const RenderContextPointer& renderContext, const gpu::FramebufferPointer& sourceFramebuffer, gpu::FramebufferPointer& resampledFrameBuffer);
60 
61  protected:
62 
63  static gpu::PipelinePointer _pipeline;
64 
65  gpu::FramebufferPointer _destinationFrameBuffer;
66  float _factor{ 2.0f };
67 
68  gpu::FramebufferPointer getResampledFrameBuffer(const gpu::FramebufferPointer& sourceFramebuffer);
69  };
70 
71  class UpsampleToBlitFramebuffer {
72  public:
73  using Input = gpu::FramebufferPointer;
74  using JobModel = Job::ModelIO<UpsampleToBlitFramebuffer, Input, gpu::FramebufferPointer>;
75 
76  UpsampleToBlitFramebuffer() {}
77 
78  void run(const RenderContextPointer& renderContext, const Input& input, gpu::FramebufferPointer& resampledFrameBuffer);
79 
80  protected:
81 
82  static gpu::PipelinePointer _pipeline;
83  static gpu::PipelinePointer _mirrorPipeline;
84  };
85 }
86 
87 #endif // hifi_render_ResampleTask_h