Showing the changes to libraries/render-utils/src/RenderForwardTask.cpp (1 of 81 files). Show all
Unified · Split
| @@ -34,6 +34,8 @@ · 33 unmodified lines | ||
| 34 | 34 | #include "RenderCommonTask.h" |
| 35 | 35 | #include "RenderHUDLayerTask.h" |
| 36 | 36 | |
| 37 | +#include "RenderViewTask.h" | |
| 38 | + | |
| 37 | 39 | namespace ru { |
| 38 | 40 | using render_utils::slot::texture::Texture; |
| 39 | 41 | using render_utils::slot::buffer::Buffer; |
| @@ -66,13 +68,16 @@ void RenderForwardTask::configure(const Config& config) { · 26 unmodified lines | ||
| 66 | 68 | preparePrimaryBufferConfig->setResolutionScale(config.resolutionScale); |
| 67 | 69 | } |
| 68 | 70 | |
| 69 | −void RenderForwardTask::build(JobModel& task, const render::Varying& input, render::Varying& output) { | |
| 71 | +void RenderForwardTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, size_t depth) { | |
| 70 | 72 | task.addJob<SetRenderMethod>("SetRenderMethodTask", render::Args::FORWARD); |
| 71 | 73 | |
| 72 | 74 | // Prepare the ShapePipelines |
| 73 | 75 | auto fadeEffect = DependencyManager::get<FadeEffect>(); |
| 74 | − ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>(); | |
| 75 | − initForwardPipelines(*shapePlumber); | |
| 76 | + static ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>(); | |
| 77 | + static std::once_flag once; | |
| 78 | + std::call_once(once, [] { | |
| 79 | + initForwardPipelines(*shapePlumber); | |
| 80 | + }); | |
| 76 | 81 | |
| 77 | 82 | // Unpack inputs |
| 78 | 83 | const auto& inputs = input.get<Input>(); |
| @@ -86,6 +91,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend · 7 unmodified lines | ||
| 86 | 91 | const auto& opaques = items[RenderFetchCullSortTask::OPAQUE_SHAPE]; |
| 87 | 92 | const auto& transparents = items[RenderFetchCullSortTask::TRANSPARENT_SHAPE]; |
| 88 | 93 | const auto& metas = items[RenderFetchCullSortTask::META]; |
| 94 | + const auto& mirrors = items[RenderFetchCullSortTask::MIRROR]; | |
| 89 | 95 | const auto& inFrontOpaque = items[RenderFetchCullSortTask::LAYER_FRONT_OPAQUE_SHAPE]; |
| 90 | 96 | const auto& inFrontTransparent = items[RenderFetchCullSortTask::LAYER_FRONT_TRANSPARENT_SHAPE]; |
| 91 | 97 | const auto& hudOpaque = items[RenderFetchCullSortTask::LAYER_HUD_OPAQUE_SHAPE]; |
| @@ -107,7 +113,6 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend · 15 unmodified lines | ||
| 107 | 113 | // First job, alter faded |
| 108 | 114 | fadeEffect->build(task, opaques); |
| 109 | 115 | |
| 110 | − | |
| 111 | 116 | // GPU jobs: Start preparing the main framebuffer |
| 112 | 117 | const auto scaledPrimaryFramebuffer = task.addJob<PreparePrimaryFramebufferMSAA>("PreparePrimaryBufferForward"); |
| 113 | 118 | |
| @@ -125,6 +130,16 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend · 11 unmodified lines | ||
| 125 | 130 | const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel, hazeFrame).asVarying(); |
| 126 | 131 | task.addJob<DrawForward>("DrawOpaques", opaqueInputs, shapePlumber, true); |
| 127 | 132 | |
| 133 | + const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f)); | |
| 134 | +#ifndef Q_OS_ANDROID | |
| 135 | + if (depth < RenderMirrorTask::MAX_MIRROR_DEPTH) { | |
| 136 | + const auto mirrorInputs = RenderMirrorTask::Inputs(mirrors, scaledPrimaryFramebuffer, nullJitter).asVarying(); | |
| 137 | + for (size_t i = 0; i < RenderMirrorTask::MAX_MIRRORS_PER_LEVEL; i++) { | |
| 138 | + task.addJob<RenderMirrorTask>("RenderMirrorTask" + std::to_string(i) + "Depth" + std::to_string(depth), mirrorInputs, i, cullFunctor, depth); | |
| 139 | + } | |
| 140 | + } | |
| 141 | +#endif | |
| 142 | + | |
| 128 | 143 | // Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job |
| 129 | 144 | const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame, hazeFrame).asVarying(); |
| 130 | 145 | task.addJob<DrawBackgroundStage>("DrawBackgroundForward", backgroundInputs); |
| @@ -134,7 +149,6 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend · 3 unmodified lines | ||
| 134 | 149 | task.addJob<DrawForward>("DrawTransparents", transparentInputs, shapePlumber, false); |
| 135 | 150 | |
| 136 | 151 | // Layered |
| 137 | − const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f)); | |
| 138 | 152 | const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, hazeFrame, nullJitter).asVarying(); |
| 139 | 153 | const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, hazeFrame, nullJitter).asVarying(); |
| 140 | 154 | task.addJob<DrawLayered3D>("DrawInFrontOpaque", inFrontOpaquesInputs, true); |
| @@ -159,7 +173,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend · 18 unmodified lines | ||
| 159 | 173 | const auto destFramebuffer = static_cast<gpu::FramebufferPointer>(nullptr); |
| 160 | 174 | |
| 161 | 175 | const auto toneMappingInputs = ToneMapAndResample::Input(resolvedFramebuffer, destFramebuffer).asVarying(); |
| 162 | − const auto toneMappedBuffer = task.addJob<ToneMapAndResample>("ToneMapping", toneMappingInputs); | |
| 176 | + const auto toneMappedBuffer = task.addJob<ToneMapAndResample>("ToneMapping", toneMappingInputs, depth); | |
| 163 | 177 | // HUD Layer |
| 164 | 178 | const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(toneMappedBuffer, lightingModel, hudOpaque, hudTransparent, hazeFrame).asVarying(); |
| 165 | 179 | task.addJob<RenderHUDLayerTask>("RenderHUDLayer", renderHUDLayerInputs); |