Overte C++ Documentation
RenderForwardTask.h
1 //
2 // RenderForwardTask.h
3 // render-utils/src/
4 //
5 // Created by Zach Pomerantz on 12/13/2016.
6 // Copyright 2016 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_RenderForwardTask_h
13 #define hifi_RenderForwardTask_h
14 
15 #include <gpu/Pipeline.h>
16 #include <render/RenderFetchCullSortTask.h>
17 #include "AssembleLightingStageTask.h"
18 #include "LightingModel.h"
19 
20 class RenderForwardTaskConfig : public render::Task::Config {
21  Q_OBJECT
22  Q_PROPERTY(float resolutionScale MEMBER resolutionScale NOTIFY dirty)
23 public:
24  float resolutionScale{ 1.f };
25 
26 signals:
27  void dirty();
28 };
29 
30 class RenderForwardTask {
31 public:
32  using Input = render::VaryingSet3<RenderFetchCullSortTask::Output, LightingModelPointer, AssembleLightingStageTask::Output>;
33  using Config = RenderForwardTaskConfig;
34  using JobModel = render::Task::ModelI<RenderForwardTask, Input, Config>;
35 
36  RenderForwardTask() {}
37 
38  void configure(const Config& config);
39  void build(JobModel& task, const render::Varying& input, render::Varying& output);
40 };
41 
42 
43 class PreparePrimaryFramebufferMSAAConfig : public render::Job::Config {
44  Q_OBJECT
45  Q_PROPERTY(float resolutionScale WRITE setResolutionScale READ getResolutionScale NOTIFY dirty)
46  Q_PROPERTY(int numSamples WRITE setNumSamples READ getNumSamples NOTIFY dirty)
47 public:
48  float getResolutionScale() const { return resolutionScale; }
49  void setResolutionScale(float scale);
50 
51  int getNumSamples() const { return numSamples; }
52  void setNumSamples(int num);
53 
54 signals:
55  void dirty();
56 
57 protected:
58  float resolutionScale{ 1.0f };
59  int numSamples{ 4 };
60 };
61 
62 class PreparePrimaryFramebufferMSAA {
63 public:
64  using Output = gpu::FramebufferPointer;
65  using Config = PreparePrimaryFramebufferMSAAConfig;
66  using JobModel = render::Job::ModelO<PreparePrimaryFramebufferMSAA, Output, Config>;
67 
68  void configure(const Config& config);
69  void run(const render::RenderContextPointer& renderContext,
70  gpu::FramebufferPointer& framebuffer);
71 
72 private:
73  gpu::FramebufferPointer _framebuffer;
74  float _resolutionScale{ 1.0f };
75  int _numSamples;
76 
77  static gpu::FramebufferPointer createFramebuffer(const char* name, const glm::uvec2& frameSize, int numSamples);
78 };
79 
80 class PrepareForward {
81 public:
82  using Inputs = render::VaryingSet2 <gpu::FramebufferPointer, LightStage::FramePointer>;
83  using JobModel = render::Job::ModelI<PrepareForward, Inputs>;
84 
85  void run(const render::RenderContextPointer& renderContext,
86  const Inputs& inputs);
87 
88 private:
89 };
90 
91 class DrawForward{
92 public:
93  using Inputs = render::VaryingSet3<render::ItemBounds, LightingModelPointer, HazeStage::FramePointer>;
94  using JobModel = render::Job::ModelI<DrawForward, Inputs>;
95 
96  DrawForward(const render::ShapePlumberPointer& shapePlumber, bool opaquePass) : _shapePlumber(shapePlumber), _opaquePass(opaquePass) {}
97  void run(const render::RenderContextPointer& renderContext,
98  const Inputs& inputs);
99 
100 private:
101  render::ShapePlumberPointer _shapePlumber;
102  bool _opaquePass;
103 };
104 
105 #endif // hifi_RenderForwardTask_h