From 89917b41fd08d9936c133a8e71cdfd596249f0d0 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Tue, 3 Jan 2017 15:18:22 -0500 Subject: [PATCH] add Forward Draw for opaques (no pipelines) --- .../render-utils/src/RenderForwardTask.cpp | 26 +++++++++++++++++++ .../render-utils/src/RenderForwardTask.h | 13 ++++++++++ 2 files changed, 39 insertions(+) diff --git a/libraries/render-utils/src/RenderForwardTask.cpp b/libraries/render-utils/src/RenderForwardTask.cpp index 51dc2dcd47..ebc9ac5b94 100755 --- a/libraries/render-utils/src/RenderForwardTask.cpp +++ b/libraries/render-utils/src/RenderForwardTask.cpp @@ -30,6 +30,9 @@ using namespace render; RenderForwardTask::RenderForwardTask(RenderFetchCullSortTask::Output items) { + // Prepare the ShapePipelines + ShapePlumberPointer shapePlumber = std::make_shared(); + // Extract opaques / transparents / lights / overlays const auto opaques = items[0]; const auto transparents = items[1]; @@ -40,6 +43,7 @@ RenderForwardTask::RenderForwardTask(RenderFetchCullSortTask::Output items) { const auto framebuffer = addJob("PrepareFramebuffer"); + addJob("DrawOpaques", opaques, shapePlumber); addJob("DrawBackground", background); // bounds do not draw on stencil buffer, so they must come last @@ -90,6 +94,28 @@ void PrepareFramebuffer::run(const SceneContextPointer& sceneContext, const Rend framebuffer = _framebuffer; } +void Draw::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, + const Inputs& items) { + RenderArgs* args = renderContext->args; + + gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { + args->_batch = &batch; + + // Setup projection + glm::mat4 projMat; + Transform viewMat; + args->getViewFrustum().evalProjectionMatrix(projMat); + args->getViewFrustum().evalViewTransform(viewMat); + batch.setProjectionTransform(projMat); + batch.setViewTransform(viewMat); + batch.setModelTransform(Transform()); + + // Render items + renderStateSortShapes(sceneContext, renderContext, _shapePlumber, items, -1); + }); + args->_batch = nullptr; +} + void DrawBackground::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const Inputs& background) { RenderArgs* args = renderContext->args; diff --git a/libraries/render-utils/src/RenderForwardTask.h b/libraries/render-utils/src/RenderForwardTask.h index 21fe43af64..5f9386ceba 100755 --- a/libraries/render-utils/src/RenderForwardTask.h +++ b/libraries/render-utils/src/RenderForwardTask.h @@ -35,6 +35,19 @@ private: gpu::FramebufferPointer _framebuffer; }; +class Draw { +public: + using Inputs = render::ItemBounds; + using JobModel = render::Job::ModelI; + + Draw(const render::ShapePlumberPointer& shapePlumber) : _shapePlumber(shapePlumber) {} + void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, + const Inputs& items); + +private: + render::ShapePlumberPointer _shapePlumber; +}; + class DrawBackground { public: using Inputs = render::ItemBounds;