add Forward Draw for opaques (no pipelines)

This commit is contained in:
Zach Pomerantz 2017-01-03 15:18:22 -05:00
parent f8e8065e93
commit 89917b41fd
2 changed files with 39 additions and 0 deletions

View file

@ -30,6 +30,9 @@
using namespace render;
RenderForwardTask::RenderForwardTask(RenderFetchCullSortTask::Output items) {
// Prepare the ShapePipelines
ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
// 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>("PrepareFramebuffer");
addJob<Draw>("DrawOpaques", opaques, shapePlumber);
addJob<DrawBackground>("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;

View file

@ -35,6 +35,19 @@ private:
gpu::FramebufferPointer _framebuffer;
};
class Draw {
public:
using Inputs = render::ItemBounds;
using JobModel = render::Job::ModelI<Draw, Inputs>;
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;