Revert "Move DrawStencil to use ShapePlumber"

This reverts commit 671f27e5bc.
This commit is contained in:
Zach Pomerantz 2016-02-02 17:10:21 -08:00
parent 5d49eacf83
commit aa10af2851
3 changed files with 27 additions and 25 deletions

View file

@ -32,8 +32,8 @@
using namespace render;
extern void initStencilPipeline(gpu::PipelinePointer& pipeline);
extern void initOverlay3DPipelines(render::ShapePlumber& plumber);
extern void initStencilPipelines(render::ShapePlumber& plumber);
extern void initDeferredPipelines(render::ShapePlumber& plumber);
void PrepareDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
@ -217,8 +217,12 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon
}
}
DrawStencilDeferred::DrawStencilDeferred() : _shapePlumber{ std::make_shared<ShapePlumber>() } {
initStencilPipelines(*_shapePlumber);
gpu::PipelinePointer DrawStencilDeferred::_opaquePipeline;
const gpu::PipelinePointer& DrawStencilDeferred::getOpaquePipeline() {
if (!_opaquePipeline) {
initStencilPipeline(_opaquePipeline);
}
return _opaquePipeline;
}
void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
@ -238,12 +242,11 @@ void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const Ren
batch.setViewportTransform(args->_viewport);
batch.setStateScissorRect(args->_viewport);
// We only need to fetch this once
static const auto& pipeline = _shapePlumber->pickPipeline(args, ShapeKey());
batch.setPipeline(getOpaquePipeline());
batch.setPipeline(pipeline->pipeline);
batch.draw(gpu::TRIANGLE_STRIP, 4);
batch.setResourceTexture(0, nullptr);
});
args->_batch = nullptr;
}

View file

@ -68,14 +68,13 @@ protected:
class DrawStencilDeferred {
public:
DrawStencilDeferred();
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
using JobModel = render::Job::Model<DrawStencilDeferred>;
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
static const gpu::PipelinePointer& getOpaquePipeline();
protected:
render::ShapePlumberPointer _shapePlumber;
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
};
class DrawBackgroundDeferred {

View file

@ -43,19 +43,7 @@
using namespace render;
void initOverlay3DPipelines(ShapePlumber& plumber) {
auto vs = gpu::Shader::createVertex(std::string(overlay3D_vert));
auto ps = gpu::Shader::createPixel(std::string(overlay3D_frag));
auto program = gpu::Shader::createProgram(vs, ps);
auto opaqueState = std::make_shared<gpu::State>();
opaqueState->setDepthTest(false);
opaqueState->setBlendFunction(false);
plumber.addPipeline(ShapeKey::Filter::Builder().withOpaque(), program, opaqueState);
}
void initStencilPipelines(ShapePlumber& plumber) {
void initStencilPipeline(gpu::PipelinePointer& pipeline) {
const gpu::int8 STENCIL_OPAQUE = 1;
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
auto ps = gpu::Shader::createPixel(std::string(drawOpaqueStencil_frag));
@ -67,7 +55,19 @@ void initStencilPipelines(ShapePlumber& plumber) {
state->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_OPAQUE, 0xFF, gpu::ALWAYS, gpu::State::STENCIL_OP_REPLACE, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_REPLACE));
state->setColorWriteMask(0);
plumber.addPipeline(ShapeKey::Filter::Builder(), program, state);
pipeline = gpu::Pipeline::create(program, state);
}
void initOverlay3DPipelines(ShapePlumber& plumber) {
auto vs = gpu::Shader::createVertex(std::string(overlay3D_vert));
auto ps = gpu::Shader::createPixel(std::string(overlay3D_frag));
auto program = gpu::Shader::createProgram(vs, ps);
auto opaqueState = std::make_shared<gpu::State>();
opaqueState->setDepthTest(false);
opaqueState->setBlendFunction(false);
plumber.addPipeline(ShapeKey::Filter::Builder().withOpaque(), program, opaqueState);
}
void pipelineBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) {