History

Removing cruft and organizing the stencil config

samcake committed 9 years ago

Commit 9c1e99f1 parent ea6be9319 files · +74 −249Browse files

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

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+20−0
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424
2525 #include "TextureCache.h"
2626 #include "RenderUtilsLogging.h"
27+#include "StencilMaskPass.h"
2728
2829 #include "gpu/StandardShaderLib.h"
2930
@@ -1610,6 +1611,9 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const · 1580 unmodified lines
16101611 state->setBlendFunction(true,
16111612 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
16121613 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
1614+
1615+ PrepareStencil::testMask(*state);
1616+
16131617 gpu::Shader::BindingSet slotBindings;
16141618 slotBindings.insert(gpu::Shader::Binding(std::string("lineData"), LINE_DATA_SLOT));
16151619 gpu::Shader::makeProgram(*program, slotBindings);
@@ -1663,11 +1667,14 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) { · 47 unmodified lines
16631667
16641668 // enable decal blend
16651669 state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
1670+ PrepareStencil::testMask(*state);
16661671
16671672 _standardDrawPipeline = gpu::Pipeline::create(program, state);
16681673
16691674
16701675 auto stateNoBlend = std::make_shared<gpu::State>();
1676+ PrepareStencil::testMaskDrawShape(*state);
1677+
16711678 auto noBlendPS = gpu::StandardShaderLib::getDrawTextureOpaquePS();
16721679 auto programNoBlend = gpu::Shader::createProgram(vs, noBlendPS);
16731680 gpu::Shader::makeProgram((*programNoBlend));
@@ -1690,12 +1697,14 @@ void GeometryCache::useGridPipeline(gpu::Batch& batch, GridBuffer gridBuffer, bo · 16 unmodified lines
16901697
16911698 auto stateLayered = std::make_shared<gpu::State>();
16921699 stateLayered->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
1700+ PrepareStencil::testMask(*stateLayered);
16931701 _gridPipelineLayered = gpu::Pipeline::create(program, stateLayered);
16941702
16951703 auto state = std::make_shared<gpu::State>(stateLayered->getValues());
16961704 const float DEPTH_BIAS = 0.001f;
16971705 state->setDepthBias(DEPTH_BIAS);
16981706 state->setDepthTest(true, false, gpu::LESS_EQUAL);
1707+ PrepareStencil::testMaskDrawShape(*state);
16991708 _gridPipeline = gpu::Pipeline::create(program, state);
17001709 }
17011710
@@ -1773,6 +1782,11 @@ static void buildWebShader(const std::string& vertShaderText, const std::string& · 71 unmodified lines
17731782 state->setBlendFunction(blendEnable,
17741783 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
17751784 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
1785+ if (blendEnable) {
1786+ PrepareStencil::testMaskBlendShape(*state);
1787+ } else {
1788+ PrepareStencil::testMaskDrawShape(*state);
1789+ }
17761790
17771791 pipelinePointerOut = gpu::Pipeline::create(shaderPointerOut, state);
17781792 }
@@ -1858,6 +1872,12 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp · 79 unmodified lines
18581872 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
18591873 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
18601874
1875+ if (config.isTransparent()) {
1876+ PrepareStencil::testMask(*state);
1877+ } else {
1878+ PrepareStencil::testMaskDrawShape(*state);
1879+ }
1880+
18611881 gpu::ShaderPointer program = (config.isUnlit()) ? _unlitShader : _simpleShader;
18621882 gpu::PipelinePointer pipeline = gpu::Pipeline::create(program, state);
18631883 _simplePrograms.insert(config, pipeline);