History

Merging with upstream

samcake committed 8 years ago

Commit e0110ff2 parents ec93433 a5e671e746 files · +25281 −14034Browse files

Showing the changes to libraries/render-utils/src/RenderDeferredTask.cpp (1 of 746 files). Show all

Unified · Split

libraries/render-utils/src/RenderDeferredTask.cpp+85−26
@@ -36,15 +36,17 @@ · 35 unmodified lines
36#include "TextureCache.h"36#include "TextureCache.h"
37#include "ZoneRenderer.h"37#include "ZoneRenderer.h"
38#include "FadeEffect.h"38#include "FadeEffect.h"
39#include "RenderUtilsLogging.h"
39 40
40#include "AmbientOcclusionEffect.h"41#include "AmbientOcclusionEffect.h"
41#include "AntialiasingEffect.h"42#include "AntialiasingEffect.h"
42#include "ToneMappingEffect.h"43#include "ToneMappingEffect.h"
43#include "SubsurfaceScattering.h"44#include "SubsurfaceScattering.h"
44#include "OutlineEffect.h"45#include "DrawHaze.h"
45 46#include "BloomEffect.h"
46#include <gpu/StandardShaderLib.h>47#include "HighlightEffect.h"
47 48
49#include <sstream>
48 50
49using namespace render;51using namespace render;
50extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false);52extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false);
@@ -58,6 +60,18 @@ void RenderDeferredTask::configure(const Config& config) · 7 unmodified lines
58{60{
59}61}
60 62
63const render::Varying RenderDeferredTask::addSelectItemJobs(JobModel& task, const char* selectionName,
64 const render::Varying& metas,
65 const render::Varying& opaques,
66 const render::Varying& transparents) {
67 const auto selectMetaInput = SelectItems::Inputs(metas, Varying(), std::string()).asVarying();
68 const auto selectedMetas = task.addJob<SelectItems>("MetaSelection", selectMetaInput, selectionName);
69 const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas, std::string()).asVarying();
70 const auto selectedMetasAndOpaques = task.addJob<SelectItems>("OpaqueSelection", selectMetaAndOpaqueInput, selectionName);
71 const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques, std::string()).asVarying();
72 return task.addJob<SelectItems>("TransparentSelection", selectItemInput, selectionName);
73}
74
61void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {75void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
62 const auto& items = input.get<Input>();76 const auto& items = input.get<Input>();
63 auto fadeEffect = DependencyManager::get<FadeEffect>();77 auto fadeEffect = DependencyManager::get<FadeEffect>();
@@ -98,15 +112,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 34 unmodified lines
98 // draw a stencil mask in hidden regions of the framebuffer.112 // draw a stencil mask in hidden regions of the framebuffer.
99 task.addJob<PrepareStencil>("PrepareStencil", primaryFramebuffer);113 task.addJob<PrepareStencil>("PrepareStencil", primaryFramebuffer);
100 114
101 // Select items that need to be outlined
102 const auto selectionName = "contextOverlayHighlightList";
103 const auto selectMetaInput = SelectItems::Inputs(metas, Varying()).asVarying();
104 const auto selectedMetas = task.addJob<SelectItems>("PassTestMetaSelection", selectMetaInput, selectionName);
105 const auto selectMetaAndOpaqueInput = SelectItems::Inputs(opaques, selectedMetas).asVarying();
106 const auto selectedMetasAndOpaques = task.addJob<SelectItems>("PassTestOpaqueSelection", selectMetaAndOpaqueInput, selectionName);
107 const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques).asVarying();
108 const auto selectedItems = task.addJob<SelectItems>("PassTestTransparentSelection", selectItemInput, selectionName);
109
110 // Render opaque objects in DeferredBuffer115 // Render opaque objects in DeferredBuffer
111 const auto opaqueInputs = DrawStateSortDeferred::Inputs(opaques, lightingModel).asVarying();116 const auto opaqueInputs = DrawStateSortDeferred::Inputs(opaques, lightingModel).asVarying();
112 task.addJob<DrawStateSortDeferred>("DrawOpaqueDeferred", opaqueInputs, shapePlumber);117 task.addJob<DrawStateSortDeferred>("DrawOpaqueDeferred", opaqueInputs, shapePlumber);
@@ -153,11 +158,13 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 40 unmodified lines
153 // Create the cluster grid of lights, cpu job for now158 // Create the cluster grid of lights, cpu job for now
154 const auto lightClusteringPassInputs = LightClusteringPass::Inputs(deferredFrameTransform, lightingModel, linearDepthTarget).asVarying();159 const auto lightClusteringPassInputs = LightClusteringPass::Inputs(deferredFrameTransform, lightingModel, linearDepthTarget).asVarying();
155 const auto lightClusters = task.addJob<LightClusteringPass>("LightClustering", lightClusteringPassInputs);160 const auto lightClusters = task.addJob<LightClusteringPass>("LightClustering", lightClusteringPassInputs);
156 161
157 162 // Add haze model
163 const auto hazeModel = task.addJob<FetchHazeStage>("HazeModel");
164
158 // DeferredBuffer is complete, now let's shade it into the LightingBuffer165 // DeferredBuffer is complete, now let's shade it into the LightingBuffer
159 const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel,166 const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel,
160 surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters).asVarying();167 surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters, hazeModel).asVarying();
161 168
162 task.addJob<RenderDeferred>("RenderDeferred", deferredLightingInputs);169 task.addJob<RenderDeferred>("RenderDeferred", deferredLightingInputs);
163 170
@@ -169,30 +176,50 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 5 unmodified lines
169 const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).asVarying();176 const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).asVarying();
170 task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber);177 task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber);
171 178
172 // LIght Cluster Grid Debuging job179 // Light Cluster Grid Debuging job
173 {180 {
174 const auto debugLightClustersInputs = DebugLightClusters::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, linearDepthTarget, lightClusters).asVarying();181 const auto debugLightClustersInputs = DebugLightClusters::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, linearDepthTarget, lightClusters).asVarying();
175 task.addJob<DebugLightClusters>("DebugLightClusters", debugLightClustersInputs);182 task.addJob<DebugLightClusters>("DebugLightClusters", debugLightClustersInputs);
176 }183 }
177 184
185 const auto drawHazeInputs = render::Varying(DrawHaze::Inputs(hazeModel, lightingFramebuffer, linearDepthTarget, deferredFrameTransform, lightingFramebuffer));
186 task.addJob<DrawHaze>("DrawHaze", drawHazeInputs);
187
178 const auto toneAndPostRangeTimer = task.addJob<BeginGPURangeTimer>("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing");188 const auto toneAndPostRangeTimer = task.addJob<BeginGPURangeTimer>("BeginToneAndPostRangeTimer", "PostToneOverlaysAntialiasing");
179 189
190 // Add bloom
191 const auto bloomInputs = Bloom::Inputs(deferredFrameTransform, lightingFramebuffer).asVarying();
192 task.addJob<Bloom>("Bloom", bloomInputs);
193
180 // Lighting Buffer ready for tone mapping194 // Lighting Buffer ready for tone mapping
181 const auto toneMappingInputs = ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer).asVarying();195 const auto toneMappingInputs = ToneMappingDeferred::Inputs(lightingFramebuffer, primaryFramebuffer).asVarying();
182 task.addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs);196 task.addJob<ToneMappingDeferred>("ToneMapping", toneMappingInputs);
183 197
184 const auto outlineRangeTimer = task.addJob<BeginGPURangeTimer>("BeginOutlineRangeTimer", "Outline");198 const auto outlineRangeTimer = task.addJob<BeginGPURangeTimer>("BeginHighlightRangeTimer", "Highlight");
185 const auto outlineInputs = DrawOutlineTask::Inputs(selectedItems, shapePlumber, deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying();199 // Select items that need to be outlined
186 task.addJob<DrawOutlineTask>("DrawOutline", outlineInputs);200 const auto selectionBaseName = "contextOverlayHighlightList";
187 task.addJob<EndGPURangeTimer>("EndOutlineRangeTimer", outlineRangeTimer);201 const auto selectedItems = addSelectItemJobs(task, selectionBaseName, metas, opaques, transparents);
202
203 const auto outlineInputs = DrawHighlightTask::Inputs(items.get0(), deferredFramebuffer, primaryFramebuffer, deferredFrameTransform).asVarying();
204 task.addJob<DrawHighlightTask>("DrawHighlight", outlineInputs);
188 205
189 { // DEbug the bounds of the rendered items, still look at the zbuffer206 task.addJob<EndGPURangeTimer>("HighlightRangeTimer", outlineRangeTimer);
207
208 { // Debug the bounds of the rendered items, still look at the zbuffer
190 task.addJob<DrawBounds>("DrawMetaBounds", metas);209 task.addJob<DrawBounds>("DrawMetaBounds", metas);
191 task.addJob<DrawBounds>("DrawOpaqueBounds", opaques);210 task.addJob<DrawBounds>("DrawOpaqueBounds", opaques);
192 task.addJob<DrawBounds>("DrawTransparentBounds", transparents);211 task.addJob<DrawBounds>("DrawTransparentBounds", transparents);
193 212
194 task.addJob<DrawBounds>("DrawLightBounds", lights);213 task.addJob<DrawBounds>("DrawLightBounds", lights);
195 task.addJob<DrawBounds>("DrawZones", zones);214 task.addJob<DrawBounds>("DrawZones", zones);
215 const auto frustums = task.addJob<ExtractFrustums>("ExtractFrustums");
216 const auto viewFrustum = frustums.getN<ExtractFrustums::Output>(ExtractFrustums::VIEW_FRUSTUM);
217 const auto shadowFrustum = frustums.getN<ExtractFrustums::Output>(ExtractFrustums::SHADOW_FRUSTUM);
218 task.addJob<DrawFrustum>("DrawViewFrustum", viewFrustum, glm::vec3(1.0f, 1.0f, 0.0f));
219 task.addJob<DrawFrustum>("DrawShadowFrustum", shadowFrustum, glm::vec3(0.0f, 0.0f, 1.0f));
220
221 // Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true
222 task.addJob<DrawBounds>("DrawSelectionBounds", selectedItems);
196 }223 }
197 224
198 // Layered Overlays225 // Layered Overlays
@@ -239,9 +266,6 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 40 unmodified lines
239 }266 }
240 267
241 task.addJob<DebugZoneLighting>("DrawZoneStack", deferredFrameTransform);268 task.addJob<DebugZoneLighting>("DrawZoneStack", deferredFrameTransform);
242
243 // Render.getConfig("RenderMainView.DrawSelectionBounds").enabled = true
244 task.addJob<DrawBounds>("DrawSelectionBounds", selectedItems);
245 }269 }
246 270
247 // AA job to be revisited271 // AA job to be revisited
@@ -443,10 +467,15 @@ void CompositeHUD::run(const RenderContextPointer& renderContext) { · 195 unmodified lines
443 assert(renderContext->args);467 assert(renderContext->args);
444 assert(renderContext->args->_context);468 assert(renderContext->args->_context);
445 469
470 // We do not want to render HUD elements in secondary camera
471 if (renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) {
472 return;
473 }
474
446 // Grab the HUD texture475 // Grab the HUD texture
447 gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {476 gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {
448 if (renderContext->args->_hudOperator) {477 if (renderContext->args->_hudOperator) {
449 renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture);478 renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture, renderContext->args->_renderMode == RenderArgs::RenderMode::MIRROR_RENDER_MODE);
450 }479 }
451 });480 });
452}481}
@@ -459,6 +488,7 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer · 6 unmodified lines
459 auto blitFbo = renderArgs->_blitFramebuffer;488 auto blitFbo = renderArgs->_blitFramebuffer;
460 489
461 if (!blitFbo) {490 if (!blitFbo) {
491 qCWarning(renderutils) << "Blit::run - no blit frame buffer.";
462 return;492 return;
463 }493 }
464 494
@@ -521,3 +551,32 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer · 56 unmodified lines
521 });551 });
522}552}
523 553
554void ExtractFrustums::run(const render::RenderContextPointer& renderContext, Output& output) {
555 assert(renderContext->args);
556 assert(renderContext->args->_context);
557
558 RenderArgs* args = renderContext->args;
559
560 // Return view frustum
561 auto& viewFrustum = output[VIEW_FRUSTUM].edit<ViewFrustumPointer>();
562 if (!viewFrustum) {
563 viewFrustum = std::make_shared<ViewFrustum>(args->getViewFrustum());
564 } else {
565 *viewFrustum = args->getViewFrustum();
566 }
567
568 // Return shadow frustum
569 auto& shadowFrustum = output[SHADOW_FRUSTUM].edit<ViewFrustumPointer>();
570 auto lightStage = args->_scene->getStage<LightStage>(LightStage::getName());
571 if (lightStage) {
572 auto globalShadow = lightStage->getCurrentKeyShadow();
573
574 if (globalShadow) {
575 shadowFrustum = globalShadow->getFrustum();
576 } else {
577 shadowFrustum.reset();
578 }
579 } else {
580 shadowFrustum.reset();
581 }
582}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t