History

add Forward Draw for opaques (no pipelines)

Zach Pomerantz committed 9 years ago

Commit 89917b41 parent f8e80652 files · +39 −0Browse files

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

Unified · Split

libraries/render-utils/src/RenderForwardTask.cpp+26−0
@@ -30,6 +30,9 @@ · 29 unmodified lines
3030 using namespace render;
3131
3232 RenderForwardTask::RenderForwardTask(RenderFetchCullSortTask::Output items) {
33+ // Prepare the ShapePipelines
34+ ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
35+
3336 // Extract opaques / transparents / lights / overlays
3437 const auto opaques = items[0];
3538 const auto transparents = items[1];
@@ -40,6 +43,7 @@ RenderForwardTask::RenderForwardTask(RenderFetchCullSortTask::Output items) { · 4 unmodified lines
4043
4144 const auto framebuffer = addJob<PrepareFramebuffer>("PrepareFramebuffer");
4245
46+ addJob<Draw>("DrawOpaques", opaques, shapePlumber);
4347 addJob<DrawBackground>("DrawBackground", background);
4448
4549 // bounds do not draw on stencil buffer, so they must come last
@@ -90,6 +94,28 @@ void PrepareFramebuffer::run(const SceneContextPointer& sceneContext, const Rend · 44 unmodified lines
9094 framebuffer = _framebuffer;
9195 }
9296
97+void Draw::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext,
98+ const Inputs& items) {
99+ RenderArgs* args = renderContext->args;
100+
101+ gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
102+ args->_batch = &batch;
103+
104+ // Setup projection
105+ glm::mat4 projMat;
106+ Transform viewMat;
107+ args->getViewFrustum().evalProjectionMatrix(projMat);
108+ args->getViewFrustum().evalViewTransform(viewMat);
109+ batch.setProjectionTransform(projMat);
110+ batch.setViewTransform(viewMat);
111+ batch.setModelTransform(Transform());
112+
113+ // Render items
114+ renderStateSortShapes(sceneContext, renderContext, _shapePlumber, items, -1);
115+ });
116+ args->_batch = nullptr;
117+}
118+
93119 void DrawBackground::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext,
94120 const Inputs& background) {
95121 RenderArgs* args = renderContext->args;