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
24 24
25#include "TextureCache.h"25#include "TextureCache.h"
26#include "RenderUtilsLogging.h"26#include "RenderUtilsLogging.h"
27#include "StencilMaskPass.h"
27 28
28#include "gpu/StandardShaderLib.h"29#include "gpu/StandardShaderLib.h"
29 30
@@ -1610,6 +1611,9 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const · 1580 unmodified lines
1610 state->setBlendFunction(true, 1611 state->setBlendFunction(true,
1611 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,1612 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
1612 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);1613 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
1614
1615 PrepareStencil::testMask(*state);
1616
1613 gpu::Shader::BindingSet slotBindings;1617 gpu::Shader::BindingSet slotBindings;
1614 slotBindings.insert(gpu::Shader::Binding(std::string("lineData"), LINE_DATA_SLOT));1618 slotBindings.insert(gpu::Shader::Binding(std::string("lineData"), LINE_DATA_SLOT));
1615 gpu::Shader::makeProgram(*program, slotBindings);1619 gpu::Shader::makeProgram(*program, slotBindings);
@@ -1663,11 +1667,14 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) { · 47 unmodified lines
1663 1667
1664 // enable decal blend1668 // enable decal blend
1665 state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);1669 state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
1670 PrepareStencil::testMask(*state);
1666 1671
1667 _standardDrawPipeline = gpu::Pipeline::create(program, state);1672 _standardDrawPipeline = gpu::Pipeline::create(program, state);
1668 1673
1669 1674
1670 auto stateNoBlend = std::make_shared<gpu::State>();1675 auto stateNoBlend = std::make_shared<gpu::State>();
1676 PrepareStencil::testMaskDrawShape(*state);
1677
1671 auto noBlendPS = gpu::StandardShaderLib::getDrawTextureOpaquePS();1678 auto noBlendPS = gpu::StandardShaderLib::getDrawTextureOpaquePS();
1672 auto programNoBlend = gpu::Shader::createProgram(vs, noBlendPS);1679 auto programNoBlend = gpu::Shader::createProgram(vs, noBlendPS);
1673 gpu::Shader::makeProgram((*programNoBlend));1680 gpu::Shader::makeProgram((*programNoBlend));
@@ -1690,12 +1697,14 @@ void GeometryCache::useGridPipeline(gpu::Batch& batch, GridBuffer gridBuffer, bo · 16 unmodified lines
1690 1697
1691 auto stateLayered = std::make_shared<gpu::State>();1698 auto stateLayered = std::make_shared<gpu::State>();
1692 stateLayered->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);1699 stateLayered->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
1700 PrepareStencil::testMask(*stateLayered);
1693 _gridPipelineLayered = gpu::Pipeline::create(program, stateLayered);1701 _gridPipelineLayered = gpu::Pipeline::create(program, stateLayered);
1694 1702
1695 auto state = std::make_shared<gpu::State>(stateLayered->getValues());1703 auto state = std::make_shared<gpu::State>(stateLayered->getValues());
1696 const float DEPTH_BIAS = 0.001f;1704 const float DEPTH_BIAS = 0.001f;
1697 state->setDepthBias(DEPTH_BIAS);1705 state->setDepthBias(DEPTH_BIAS);
1698 state->setDepthTest(true, false, gpu::LESS_EQUAL);1706 state->setDepthTest(true, false, gpu::LESS_EQUAL);
1707 PrepareStencil::testMaskDrawShape(*state);
1699 _gridPipeline = gpu::Pipeline::create(program, state);1708 _gridPipeline = gpu::Pipeline::create(program, state);
1700 }1709 }
1701 1710
@@ -1773,6 +1782,11 @@ static void buildWebShader(const std::string& vertShaderText, const std::string& · 71 unmodified lines
1773 state->setBlendFunction(blendEnable,1782 state->setBlendFunction(blendEnable,
1774 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,1783 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
1775 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);1784 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 }
1776 1790
1777 pipelinePointerOut = gpu::Pipeline::create(shaderPointerOut, state);1791 pipelinePointerOut = gpu::Pipeline::create(shaderPointerOut, state);
1778}1792}
@@ -1858,6 +1872,12 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp · 79 unmodified lines
1858 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,1872 gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
1859 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);1873 gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
1860 1874
1875 if (config.isTransparent()) {
1876 PrepareStencil::testMask(*state);
1877 } else {
1878 PrepareStencil::testMaskDrawShape(*state);
1879 }
1880
1861 gpu::ShaderPointer program = (config.isUnlit()) ? _unlitShader : _simpleShader;1881 gpu::ShaderPointer program = (config.isUnlit()) ? _unlitShader : _simpleShader;
1862 gpu::PipelinePointer pipeline = gpu::Pipeline::create(program, state);1882 gpu::PipelinePointer pipeline = gpu::Pipeline::create(program, state);
1863 _simplePrograms.insert(config, pipeline);1883 _simplePrograms.insert(config, pipeline);