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
30using namespace render;30using namespace render;
31 31
32RenderForwardTask::RenderForwardTask(RenderFetchCullSortTask::Output items) {32RenderForwardTask::RenderForwardTask(RenderFetchCullSortTask::Output items) {
33 // Prepare the ShapePipelines
34 ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
35
33 // Extract opaques / transparents / lights / overlays36 // Extract opaques / transparents / lights / overlays
34 const auto opaques = items[0];37 const auto opaques = items[0];
35 const auto transparents = items[1];38 const auto transparents = items[1];
@@ -40,6 +43,7 @@ RenderForwardTask::RenderForwardTask(RenderFetchCullSortTask::Output items) { · 4 unmodified lines
40 43
41 const auto framebuffer = addJob<PrepareFramebuffer>("PrepareFramebuffer");44 const auto framebuffer = addJob<PrepareFramebuffer>("PrepareFramebuffer");
42 45
46 addJob<Draw>("DrawOpaques", opaques, shapePlumber);
43 addJob<DrawBackground>("DrawBackground", background);47 addJob<DrawBackground>("DrawBackground", background);
44 48
45 // bounds do not draw on stencil buffer, so they must come last49 // 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
90 framebuffer = _framebuffer;94 framebuffer = _framebuffer;
91}95}
92 96
97void 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
93void DrawBackground::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext,119void DrawBackground::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext,
94 const Inputs& background) {120 const Inputs& background) {
95 RenderArgs* args = renderContext->args;121 RenderArgs* args = renderContext->args;