mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:58:35 +02:00
Move DrawStencil to use ShapePlumber
This commit is contained in:
parent
753fc44c12
commit
671f27e5bc
2 changed files with 16 additions and 21 deletions
|
@ -256,25 +256,19 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer DrawStencilDeferred::_opaquePipeline;
|
DrawStencilDeferred::DrawStencilDeferred() : _shapePlumber{ std::make_shared<ShapePlumber>() } {
|
||||||
const gpu::PipelinePointer& DrawStencilDeferred::getOpaquePipeline() {
|
const gpu::int8 STENCIL_OPAQUE = 1;
|
||||||
if (!_opaquePipeline) {
|
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||||
const gpu::int8 STENCIL_OPAQUE = 1;
|
auto ps = gpu::Shader::createPixel(std::string(drawOpaqueStencil_frag));
|
||||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
auto program = gpu::Shader::createProgram(vs, ps);
|
||||||
auto ps = gpu::Shader::createPixel(std::string(drawOpaqueStencil_frag));
|
gpu::Shader::makeProgram((*program));
|
||||||
auto program = gpu::Shader::createProgram(vs, ps);
|
|
||||||
|
|
||||||
|
|
||||||
gpu::Shader::makeProgram((*program));
|
auto state = std::make_shared<gpu::State>();
|
||||||
|
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
||||||
|
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);
|
||||||
|
|
||||||
auto state = std::make_shared<gpu::State>();
|
_shapePlumber->addPipeline(ShapeKey::Filter::Builder(), program, state);
|
||||||
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
|
||||||
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);
|
|
||||||
|
|
||||||
_opaquePipeline = gpu::Pipeline::create(program, state);
|
|
||||||
}
|
|
||||||
return _opaquePipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
||||||
|
@ -294,11 +288,12 @@ void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const Ren
|
||||||
batch.setViewportTransform(args->_viewport);
|
batch.setViewportTransform(args->_viewport);
|
||||||
batch.setStateScissorRect(args->_viewport);
|
batch.setStateScissorRect(args->_viewport);
|
||||||
|
|
||||||
batch.setPipeline(getOpaquePipeline());
|
// We only need to fetch this once
|
||||||
|
static const auto& pipeline = _shapePlumber->pickPipeline(args, ShapeKey());
|
||||||
|
|
||||||
|
batch.setPipeline(pipeline->pipeline);
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
batch.setResourceTexture(0, nullptr);
|
batch.setResourceTexture(0, nullptr);
|
||||||
|
|
||||||
});
|
});
|
||||||
args->_batch = nullptr;
|
args->_batch = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,14 +68,14 @@ protected:
|
||||||
|
|
||||||
class DrawStencilDeferred {
|
class DrawStencilDeferred {
|
||||||
public:
|
public:
|
||||||
static const gpu::PipelinePointer& getOpaquePipeline();
|
DrawStencilDeferred();
|
||||||
|
|
||||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||||
|
|
||||||
using JobModel = render::Job::Model<DrawStencilDeferred>;
|
using JobModel = render::Job::Model<DrawStencilDeferred>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
|
render::ShapePlumberPointer _shapePlumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawBackgroundDeferred {
|
class DrawBackgroundDeferred {
|
||||||
|
|
Loading…
Reference in a new issue