From 1fd4c5c1a45199581e89e63a1b1ffb89cdbdfd65 Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 29 Jan 2018 12:20:51 -0800 Subject: [PATCH] Integrating the tag flags to the render item key and adding configration of the render pipelien with the Tag information --- interface/src/SecondaryCamera.cpp | 2 +- libraries/render-utils/src/RenderShadowTask.cpp | 6 ++---- libraries/render-utils/src/RenderShadowTask.h | 4 +++- libraries/render-utils/src/RenderViewTask.cpp | 2 +- libraries/render/src/render/CullTask.cpp | 6 ++++-- libraries/render/src/render/CullTask.h | 4 ++-- libraries/render/src/render/RenderFetchCullSortTask.cpp | 4 +++- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index 748f1595db..6b8e370689 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -20,7 +20,7 @@ using RenderArgsPointer = std::shared_ptr; void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) { - task.addJob("RenderShadowTask", cullFunctor); + task.addJob("RenderShadowTask", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1); const auto items = task.addJob("FetchCullSort", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1); assert(items.canCast()); if (!isDeferred) { diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index 20af1278ac..19a3f4ed73 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -216,7 +216,7 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende task.addJob("ShadowSetup"); for (auto i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) { - const auto setupOutput = task.addJob("ShadowCascadeSetup", i); + const auto setupOutput = task.addJob("ShadowCascadeSetup", i, tagBits, tagMask); const auto shadowFilter = setupOutput.getN(1); // CPU jobs: @@ -259,14 +259,12 @@ void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderCon // Cache old render args RenderArgs* args = renderContext->args; - // const auto& filterMask = inputs; - output.edit0() = args->_renderMode; output.edit2() = args->_sizeScale; const auto globalShadow = lightStage->getCurrentKeyShadow(); if (globalShadow && _cascadeIndexgetCascadeCount()) { - output.edit1() = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered(); + output.edit1() = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(_tagBits, _tagMask); globalShadow->setKeylightCascadeFrustum(_cascadeIndex, args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR); diff --git a/libraries/render-utils/src/RenderShadowTask.h b/libraries/render-utils/src/RenderShadowTask.h index 2bc325cc81..33e0ad4daa 100644 --- a/libraries/render-utils/src/RenderShadowTask.h +++ b/libraries/render-utils/src/RenderShadowTask.h @@ -67,12 +67,14 @@ public: using Outputs = render::VaryingSet3; using JobModel = render::Job::ModelO; - RenderShadowCascadeSetup(unsigned int cascadeIndex) : _cascadeIndex{ cascadeIndex } {} + RenderShadowCascadeSetup(unsigned int cascadeIndex, uint8_t tagBits = 0x00, uint8_t tagMask = 0x00) : _cascadeIndex{ cascadeIndex }, _tagBits(tagBits), _tagMask(tagMask) {} void run(const render::RenderContextPointer& renderContext, Outputs& output); private: unsigned int _cascadeIndex; + uint8_t _tagBits{ 0x00 }; + uint8_t _tagMask{ 0x00 }; }; class RenderShadowCascadeTeardown { diff --git a/libraries/render-utils/src/RenderViewTask.cpp b/libraries/render-utils/src/RenderViewTask.cpp index 42d3044b1b..19924b4ddc 100644 --- a/libraries/render-utils/src/RenderViewTask.cpp +++ b/libraries/render-utils/src/RenderViewTask.cpp @@ -28,7 +28,7 @@ void RenderViewTask::build(JobModel& task, const render::Varying& input, render: const auto threshold = 1e-3f; return relativeBoundRadius > threshold; return true; - }); + }, tagBits, tagMask); const auto items = task.addJob("FetchCullSort", cullFunctor, tagBits, tagMask); assert(items.canCast()); diff --git a/libraries/render/src/render/CullTask.cpp b/libraries/render/src/render/CullTask.cpp index 70331cdb47..8d99c3e8f2 100644 --- a/libraries/render/src/render/CullTask.cpp +++ b/libraries/render/src/render/CullTask.cpp @@ -61,7 +61,7 @@ void render::cullItems(const RenderContextPointer& renderContext, const CullFunc details._rendered += (int)outItems.size(); } -void FetchNonspatialItems::run(const RenderContextPointer& renderContext, ItemBounds& outItems) { +void FetchNonspatialItems::run(const RenderContextPointer& renderContext, const ItemFilter& filter, ItemBounds& outItems) { assert(renderContext->args); assert(renderContext->args->hasViewFrustum()); auto& scene = renderContext->_scene; @@ -72,7 +72,9 @@ void FetchNonspatialItems::run(const RenderContextPointer& renderContext, ItemBo outItems.reserve(items.size()); for (auto& id : items) { auto& item = scene->getItem(id); - outItems.emplace_back(ItemBound(id, item.getBound())); + if (filter.test(item.getKey())) { + outItems.emplace_back(ItemBound(id, item.getBound())); + } } } diff --git a/libraries/render/src/render/CullTask.h b/libraries/render/src/render/CullTask.h index 486c4f4cdf..4461537109 100644 --- a/libraries/render/src/render/CullTask.h +++ b/libraries/render/src/render/CullTask.h @@ -24,8 +24,8 @@ namespace render { class FetchNonspatialItems { public: - using JobModel = Job::ModelO; - void run(const RenderContextPointer& renderContext, ItemBounds& outItems); + using JobModel = Job::ModelIO; + void run(const RenderContextPointer& renderContext, const ItemFilter& filter, ItemBounds& outItems); }; class FetchSpatialTreeConfig : public Job::Config { diff --git a/libraries/render/src/render/RenderFetchCullSortTask.cpp b/libraries/render/src/render/RenderFetchCullSortTask.cpp index bb6bd462f6..7f60d5bb52 100644 --- a/libraries/render/src/render/RenderFetchCullSortTask.cpp +++ b/libraries/render/src/render/RenderFetchCullSortTask.cpp @@ -29,7 +29,9 @@ void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varyin const auto culledSpatialSelection = task.addJob("CullSceneSelection", cullInputs, cullFunctor, RenderDetails::ITEM); // Overlays are not culled - const auto nonspatialSelection = task.addJob("FetchOverlaySelection"); + const ItemFilter overlayfilter = ItemFilter::Builder().withVisible().withTagBits(tagBits, tagMask); + const auto nonspatialFilter = render::Varying(overlayfilter); + const auto nonspatialSelection = task.addJob("FetchOverlaySelection", nonspatialFilter); // Multi filter visible items into different buckets const int NUM_SPATIAL_FILTERS = 4;