From 671f27e5bc3950cc75884a5b8b0e6b6221011cb5 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 28 Jan 2016 12:05:59 -0800 Subject: [PATCH 01/12] Move DrawStencil to use ShapePlumber --- .../render-utils/src/RenderDeferredTask.cpp | 33 ++++++++----------- .../render-utils/src/RenderDeferredTask.h | 4 +-- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index d76d0a77de..9ae76bfe02 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -256,25 +256,19 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon } } -gpu::PipelinePointer DrawStencilDeferred::_opaquePipeline; -const gpu::PipelinePointer& DrawStencilDeferred::getOpaquePipeline() { - if (!_opaquePipeline) { - const gpu::int8 STENCIL_OPAQUE = 1; - auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); - auto ps = gpu::Shader::createPixel(std::string(drawOpaqueStencil_frag)); - auto program = gpu::Shader::createProgram(vs, ps); - +DrawStencilDeferred::DrawStencilDeferred() : _shapePlumber{ std::make_shared() } { + const gpu::int8 STENCIL_OPAQUE = 1; + auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); + auto ps = gpu::Shader::createPixel(std::string(drawOpaqueStencil_frag)); + auto program = gpu::Shader::createProgram(vs, ps); + gpu::Shader::makeProgram((*program)); - gpu::Shader::makeProgram((*program)); + auto state = std::make_shared(); + 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(); - 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; + _shapePlumber->addPipeline(ShapeKey::Filter::Builder(), program, state); } 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.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.setResourceTexture(0, nullptr); - }); args->_batch = nullptr; } diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index 8d773a9b21..2ebb2e4e12 100755 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -68,14 +68,14 @@ protected: class DrawStencilDeferred { public: - static const gpu::PipelinePointer& getOpaquePipeline(); + DrawStencilDeferred(); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); using JobModel = render::Job::Model; protected: - static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable + render::ShapePlumberPointer _shapePlumber; }; class DrawBackgroundDeferred { From df894d364a032fcc31837838e802621c96a7dbb6 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 28 Jan 2016 12:25:31 -0800 Subject: [PATCH 02/12] Move DrawOverlay3D to use ShapePlumber --- .../render-utils/src/RenderDeferredTask.cpp | 39 ++++++++++--------- .../render-utils/src/RenderDeferredTask.h | 5 +-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 9ae76bfe02..15a37998ca 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -128,7 +128,7 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) { addJob("DrawStatus", opaques, DrawStatus(statusIconMap)); } - addJob("DrawOverlay3D", shapePlumber); + addJob("DrawOverlay3D"); addJob("HitEffect"); @@ -180,22 +180,26 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont }); } -// TODO: Move this to the shapePlumber -gpu::PipelinePointer DrawOverlay3D::_opaquePipeline; -const gpu::PipelinePointer& DrawOverlay3D::getOpaquePipeline() { - if (!_opaquePipeline) { - 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 state = std::make_shared(); - state->setDepthTest(false); - // additive blending - state->setBlendFunction(true, gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::ONE); +DrawOverlay3D::DrawOverlay3D() : _shapePlumber{ std::make_shared() } { + 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); - _opaquePipeline = gpu::Pipeline::create(program, state); - } - return _opaquePipeline; + auto opaqueState = std::make_shared(); + opaqueState->setDepthTest(false); + opaqueState->setBlendFunction(true, + // Additive blending + gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::ONE); + + auto transparentState = std::make_shared(); + transparentState->setDepthTest(false); + transparentState->setBlendFunction(true, + // For transparency, keep the highlight intensity + gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, + gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); + + _shapePlumber->addPipeline(ShapeKey::Filter::Builder().withOpaque(), program, opaqueState); + _shapePlumber->addPipeline(ShapeKey::Filter::Builder().withTranslucent(), program, transparentState); } void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { @@ -246,9 +250,8 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon batch.setViewTransform(viewMat); batch.setViewportTransform(args->_viewport); batch.setStateScissorRect(args->_viewport); - - batch.setPipeline(getOpaquePipeline()); batch.setResourceTexture(0, args->_whiteTexture); + renderShapes(sceneContext, renderContext, _shapePlumber, inItems, _maxDrawn); }); args->_batch = nullptr; diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index 2ebb2e4e12..894a91cdc3 100755 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -106,15 +106,12 @@ public: using Config = DrawOverlay3DConfig; using JobModel = render::Job::Model; - DrawOverlay3D(render::ShapePlumberPointer shapePlumber) : _shapePlumber{ shapePlumber } {} + DrawOverlay3D(); void configure(const Config& config) { _maxDrawn = config.maxDrawn; } void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); - static const gpu::PipelinePointer& getOpaquePipeline(); - protected: - static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable render::ShapePlumberPointer _shapePlumber; int _maxDrawn; // initialized by Config }; From 5d49eacf83c3e4e850acffd38c6a8292293f786d Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 28 Jan 2016 15:51:56 -0800 Subject: [PATCH 03/12] Move pipeline init to separate file --- .../render-utils/src/RenderDeferredTask.cpp | 228 +---------------- .../render-utils/src/RenderPipelines.cpp | 234 ++++++++++++++++++ 2 files changed, 240 insertions(+), 222 deletions(-) create mode 100644 libraries/render-utils/src/RenderPipelines.cpp diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 15a37998ca..8a47280526 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -4,7 +4,7 @@ // render-utils/src/ // // Created by Sam Gateau on 5/29/15. -// Copyright 20154 High Fidelity, Inc. +// Copyright 2016 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -15,7 +15,6 @@ #include #include #include -#include #include "DebugDeferredBuffer.h" #include "DeferredLightingEffect.h" @@ -31,34 +30,11 @@ #include "RenderDeferredTask.h" -#include "model_vert.h" -#include "model_shadow_vert.h" -#include "model_normal_map_vert.h" -#include "model_lightmap_vert.h" -#include "model_lightmap_normal_map_vert.h" -#include "skin_model_vert.h" -#include "skin_model_shadow_vert.h" -#include "skin_model_normal_map_vert.h" - -#include "model_frag.h" -#include "model_shadow_frag.h" -#include "model_normal_map_frag.h" -#include "model_normal_specular_map_frag.h" -#include "model_specular_map_frag.h" -#include "model_lightmap_frag.h" -#include "model_lightmap_normal_map_frag.h" -#include "model_lightmap_normal_specular_map_frag.h" -#include "model_lightmap_specular_map_frag.h" -#include "model_translucent_frag.h" - -#include "overlay3D_vert.h" -#include "overlay3D_frag.h" - -#include "drawOpaqueStencil_frag.h" - using namespace render; -void initDeferredPipelines(render::ShapePlumber& plumber); +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) { DependencyManager::get()->prepare(renderContext->args); @@ -181,25 +157,7 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont } DrawOverlay3D::DrawOverlay3D() : _shapePlumber{ std::make_shared() } { - 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(); - opaqueState->setDepthTest(false); - opaqueState->setBlendFunction(true, - // Additive blending - gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::ONE); - - auto transparentState = std::make_shared(); - transparentState->setDepthTest(false); - transparentState->setBlendFunction(true, - // For transparency, keep the highlight intensity - gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, - gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); - - _shapePlumber->addPipeline(ShapeKey::Filter::Builder().withOpaque(), program, opaqueState); - _shapePlumber->addPipeline(ShapeKey::Filter::Builder().withTranslucent(), program, transparentState); + initOverlay3DPipelines(*_shapePlumber); } void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { @@ -260,18 +218,7 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon } DrawStencilDeferred::DrawStencilDeferred() : _shapePlumber{ std::make_shared() } { - const gpu::int8 STENCIL_OPAQUE = 1; - auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); - auto ps = gpu::Shader::createPixel(std::string(drawOpaqueStencil_frag)); - auto program = gpu::Shader::createProgram(vs, ps); - gpu::Shader::makeProgram((*program)); - - auto state = std::make_shared(); - 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); - - _shapePlumber->addPipeline(ShapeKey::Filter::Builder(), program, state); + initStencilPipelines(*_shapePlumber); } void DrawStencilDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { @@ -411,166 +358,3 @@ void Blit::run(const SceneContextPointer& sceneContext, const RenderContextPoint } }); } - -void pipelineBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) { - if (pipeline.locations->normalFittingMapUnit > -1) { - batch.setResourceTexture(pipeline.locations->normalFittingMapUnit, - DependencyManager::get()->getNormalFittingTexture()); - } -} - -void initDeferredPipelines(render::ShapePlumber& plumber) { - using Key = render::ShapeKey; - using ShaderPointer = gpu::ShaderPointer; - - auto addPipeline = [&plumber](const Key& key, const ShaderPointer& vertexShader, const ShaderPointer& pixelShader) { - auto state = std::make_shared(); - - // Cull backface - state->setCullMode(gpu::State::CULL_BACK); - - // Z test depends on transparency - state->setDepthTest(true, !key.isTranslucent(), gpu::LESS_EQUAL); - - // Blend if transparent - state->setBlendFunction(key.isTranslucent(), - // For transparency, keep the highlight intensity - gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, - gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); - - ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader); - plumber.addPipeline(key, program, state, &pipelineBatchSetter); - - // Add a wireframe version - if (!key.isWireFrame()) { - auto wireFrameKey = Key::Builder(key).withWireframe(); - auto wireFrameState = std::make_shared(state->getValues()); - - wireFrameState->setFillMode(gpu::State::FILL_LINE); - - plumber.addPipeline(wireFrameKey, program, wireFrameState, &pipelineBatchSetter); - } - }; - - // Vertex shaders - auto modelVertex = gpu::Shader::createVertex(std::string(model_vert)); - auto modelNormalMapVertex = gpu::Shader::createVertex(std::string(model_normal_map_vert)); - auto modelLightmapVertex = gpu::Shader::createVertex(std::string(model_lightmap_vert)); - auto modelLightmapNormalMapVertex = gpu::Shader::createVertex(std::string(model_lightmap_normal_map_vert)); - auto modelShadowVertex = gpu::Shader::createVertex(std::string(model_shadow_vert)); - auto skinModelVertex = gpu::Shader::createVertex(std::string(skin_model_vert)); - auto skinModelNormalMapVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_vert)); - auto skinModelShadowVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert)); - - // Pixel shaders - auto modelPixel = gpu::Shader::createPixel(std::string(model_frag)); - auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(model_normal_map_frag)); - auto modelSpecularMapPixel = gpu::Shader::createPixel(std::string(model_specular_map_frag)); - auto modelNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_frag)); - auto modelTranslucentPixel = gpu::Shader::createPixel(std::string(model_translucent_frag)); - auto modelShadowPixel = gpu::Shader::createPixel(std::string(model_shadow_frag)); - auto modelLightmapPixel = gpu::Shader::createPixel(std::string(model_lightmap_frag)); - auto modelLightmapNormalMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_frag)); - auto modelLightmapSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_frag)); - auto modelLightmapNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_frag)); - - // Fill the pipelineLib - addPipeline( - Key::Builder(), - modelVertex, modelPixel); - - addPipeline( - Key::Builder().withTangents(), - modelNormalMapVertex, modelNormalMapPixel); - - addPipeline( - Key::Builder().withSpecular(), - modelVertex, modelSpecularMapPixel); - - addPipeline( - Key::Builder().withTangents().withSpecular(), - modelNormalMapVertex, modelNormalSpecularMapPixel); - - - addPipeline( - Key::Builder().withTranslucent(), - modelVertex, modelTranslucentPixel); - // FIXME Ignore lightmap for translucents meshpart - addPipeline( - Key::Builder().withTranslucent().withLightmap(), - modelVertex, modelTranslucentPixel); - - addPipeline( - Key::Builder().withTangents().withTranslucent(), - modelNormalMapVertex, modelTranslucentPixel); - - addPipeline( - Key::Builder().withSpecular().withTranslucent(), - modelVertex, modelTranslucentPixel); - - addPipeline( - Key::Builder().withTangents().withSpecular().withTranslucent(), - modelNormalMapVertex, modelTranslucentPixel); - - - addPipeline( - Key::Builder().withLightmap(), - modelLightmapVertex, modelLightmapPixel); - - addPipeline( - Key::Builder().withLightmap().withTangents(), - modelLightmapNormalMapVertex, modelLightmapNormalMapPixel); - - addPipeline( - Key::Builder().withLightmap().withSpecular(), - modelLightmapVertex, modelLightmapSpecularMapPixel); - - addPipeline( - Key::Builder().withLightmap().withTangents().withSpecular(), - modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel); - - - addPipeline( - Key::Builder().withSkinned(), - skinModelVertex, modelPixel); - - addPipeline( - Key::Builder().withSkinned().withTangents(), - skinModelNormalMapVertex, modelNormalMapPixel); - - addPipeline( - Key::Builder().withSkinned().withSpecular(), - skinModelVertex, modelSpecularMapPixel); - - addPipeline( - Key::Builder().withSkinned().withTangents().withSpecular(), - skinModelNormalMapVertex, modelNormalSpecularMapPixel); - - - addPipeline( - Key::Builder().withSkinned().withTranslucent(), - skinModelVertex, modelTranslucentPixel); - - addPipeline( - Key::Builder().withSkinned().withTangents().withTranslucent(), - skinModelNormalMapVertex, modelTranslucentPixel); - - addPipeline( - Key::Builder().withSkinned().withSpecular().withTranslucent(), - skinModelVertex, modelTranslucentPixel); - - addPipeline( - Key::Builder().withSkinned().withTangents().withSpecular().withTranslucent(), - skinModelNormalMapVertex, modelTranslucentPixel); - - - addPipeline( - Key::Builder().withDepthOnly(), - modelShadowVertex, modelShadowPixel); - - - addPipeline( - Key::Builder().withSkinned().withDepthOnly(), - skinModelShadowVertex, modelShadowPixel); -} - diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp new file mode 100644 index 0000000000..a7e9081d9a --- /dev/null +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -0,0 +1,234 @@ + +// +// RenderPipelines.cpp +// render-utils/src/ +// +// Created by Zach Pomerantz on 1/28/2016. +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include + +#include "TextureCache.h" +#include "render/DrawTask.h" + +#include "model_vert.h" +#include "model_shadow_vert.h" +#include "model_normal_map_vert.h" +#include "model_lightmap_vert.h" +#include "model_lightmap_normal_map_vert.h" +#include "skin_model_vert.h" +#include "skin_model_shadow_vert.h" +#include "skin_model_normal_map_vert.h" + +#include "model_frag.h" +#include "model_shadow_frag.h" +#include "model_normal_map_frag.h" +#include "model_normal_specular_map_frag.h" +#include "model_specular_map_frag.h" +#include "model_lightmap_frag.h" +#include "model_lightmap_normal_map_frag.h" +#include "model_lightmap_normal_specular_map_frag.h" +#include "model_lightmap_specular_map_frag.h" +#include "model_translucent_frag.h" + +#include "overlay3D_vert.h" +#include "overlay3D_frag.h" + +#include "drawOpaqueStencil_frag.h" + +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(); + opaqueState->setDepthTest(false); + opaqueState->setBlendFunction(false); + + plumber.addPipeline(ShapeKey::Filter::Builder().withOpaque(), program, opaqueState); +} + +void initStencilPipelines(ShapePlumber& plumber) { + const gpu::int8 STENCIL_OPAQUE = 1; + auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS(); + auto ps = gpu::Shader::createPixel(std::string(drawOpaqueStencil_frag)); + auto program = gpu::Shader::createProgram(vs, ps); + gpu::Shader::makeProgram((*program)); + + auto state = std::make_shared(); + 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); + + plumber.addPipeline(ShapeKey::Filter::Builder(), program, state); +} + +void pipelineBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) { + if (pipeline.locations->normalFittingMapUnit > -1) { + batch.setResourceTexture(pipeline.locations->normalFittingMapUnit, + DependencyManager::get()->getNormalFittingTexture()); + } +} + +void initDeferredPipelines(render::ShapePlumber& plumber) { + using Key = render::ShapeKey; + using ShaderPointer = gpu::ShaderPointer; + + auto addPipeline = [&plumber](const Key& key, const ShaderPointer& vertexShader, const ShaderPointer& pixelShader) { + auto state = std::make_shared(); + + // Cull backface + state->setCullMode(gpu::State::CULL_BACK); + + // Z test depends on transparency + state->setDepthTest(true, !key.isTranslucent(), gpu::LESS_EQUAL); + + // Blend if transparent + state->setBlendFunction(key.isTranslucent(), + // For transparency, keep the highlight intensity + gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, + gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); + + ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader); + plumber.addPipeline(key, program, state, &pipelineBatchSetter); + + // Add a wireframe version + if (!key.isWireFrame()) { + auto wireFrameKey = Key::Builder(key).withWireframe(); + auto wireFrameState = std::make_shared(state->getValues()); + + wireFrameState->setFillMode(gpu::State::FILL_LINE); + + plumber.addPipeline(wireFrameKey, program, wireFrameState, &pipelineBatchSetter); + } + }; + + // Vertex shaders + auto modelVertex = gpu::Shader::createVertex(std::string(model_vert)); + auto modelNormalMapVertex = gpu::Shader::createVertex(std::string(model_normal_map_vert)); + auto modelLightmapVertex = gpu::Shader::createVertex(std::string(model_lightmap_vert)); + auto modelLightmapNormalMapVertex = gpu::Shader::createVertex(std::string(model_lightmap_normal_map_vert)); + auto modelShadowVertex = gpu::Shader::createVertex(std::string(model_shadow_vert)); + auto skinModelVertex = gpu::Shader::createVertex(std::string(skin_model_vert)); + auto skinModelNormalMapVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_vert)); + auto skinModelShadowVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert)); + + // Pixel shaders + auto modelPixel = gpu::Shader::createPixel(std::string(model_frag)); + auto modelNormalMapPixel = gpu::Shader::createPixel(std::string(model_normal_map_frag)); + auto modelSpecularMapPixel = gpu::Shader::createPixel(std::string(model_specular_map_frag)); + auto modelNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_frag)); + auto modelTranslucentPixel = gpu::Shader::createPixel(std::string(model_translucent_frag)); + auto modelShadowPixel = gpu::Shader::createPixel(std::string(model_shadow_frag)); + auto modelLightmapPixel = gpu::Shader::createPixel(std::string(model_lightmap_frag)); + auto modelLightmapNormalMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_frag)); + auto modelLightmapSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_frag)); + auto modelLightmapNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_frag)); + + // Fill the pipelineLib + addPipeline( + Key::Builder(), + modelVertex, modelPixel); + + addPipeline( + Key::Builder().withTangents(), + modelNormalMapVertex, modelNormalMapPixel); + + addPipeline( + Key::Builder().withSpecular(), + modelVertex, modelSpecularMapPixel); + + addPipeline( + Key::Builder().withTangents().withSpecular(), + modelNormalMapVertex, modelNormalSpecularMapPixel); + + + addPipeline( + Key::Builder().withTranslucent(), + modelVertex, modelTranslucentPixel); + // FIXME Ignore lightmap for translucents meshpart + addPipeline( + Key::Builder().withTranslucent().withLightmap(), + modelVertex, modelTranslucentPixel); + + addPipeline( + Key::Builder().withTangents().withTranslucent(), + modelNormalMapVertex, modelTranslucentPixel); + + addPipeline( + Key::Builder().withSpecular().withTranslucent(), + modelVertex, modelTranslucentPixel); + + addPipeline( + Key::Builder().withTangents().withSpecular().withTranslucent(), + modelNormalMapVertex, modelTranslucentPixel); + + + addPipeline( + Key::Builder().withLightmap(), + modelLightmapVertex, modelLightmapPixel); + + addPipeline( + Key::Builder().withLightmap().withTangents(), + modelLightmapNormalMapVertex, modelLightmapNormalMapPixel); + + addPipeline( + Key::Builder().withLightmap().withSpecular(), + modelLightmapVertex, modelLightmapSpecularMapPixel); + + addPipeline( + Key::Builder().withLightmap().withTangents().withSpecular(), + modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel); + + + addPipeline( + Key::Builder().withSkinned(), + skinModelVertex, modelPixel); + + addPipeline( + Key::Builder().withSkinned().withTangents(), + skinModelNormalMapVertex, modelNormalMapPixel); + + addPipeline( + Key::Builder().withSkinned().withSpecular(), + skinModelVertex, modelSpecularMapPixel); + + addPipeline( + Key::Builder().withSkinned().withTangents().withSpecular(), + skinModelNormalMapVertex, modelNormalSpecularMapPixel); + + + addPipeline( + Key::Builder().withSkinned().withTranslucent(), + skinModelVertex, modelTranslucentPixel); + + addPipeline( + Key::Builder().withSkinned().withTangents().withTranslucent(), + skinModelNormalMapVertex, modelTranslucentPixel); + + addPipeline( + Key::Builder().withSkinned().withSpecular().withTranslucent(), + skinModelVertex, modelTranslucentPixel); + + addPipeline( + Key::Builder().withSkinned().withTangents().withSpecular().withTranslucent(), + skinModelNormalMapVertex, modelTranslucentPixel); + + + addPipeline( + Key::Builder().withDepthOnly(), + modelShadowVertex, modelShadowPixel); + + + addPipeline( + Key::Builder().withSkinned().withDepthOnly(), + skinModelShadowVertex, modelShadowPixel); +} + From 095f0b93490633524f2ea2a68f802371cb5b61ac Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 1 Feb 2016 16:46:11 -0800 Subject: [PATCH 04/12] rename canAdjustLocks to isAllowedEditor for multi-purpose --- assignment-client/src/audio/AudioMixer.cpp | 2 +- domain-server/src/DomainGatekeeper.cpp | 14 +++++++------- domain-server/src/DomainServer.cpp | 2 +- .../entities/src/EntityScriptingInterface.cpp | 4 ++-- libraries/entities/src/EntityTree.cpp | 4 ++-- libraries/networking/src/LimitedNodeList.cpp | 15 +++++++-------- libraries/networking/src/LimitedNodeList.h | 10 +++++----- libraries/networking/src/Node.cpp | 8 ++++---- libraries/networking/src/Node.h | 8 ++++---- libraries/networking/src/NodeList.cpp | 12 ++++++------ 10 files changed, 39 insertions(+), 40 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index d85e1d137b..8967436e2d 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -551,7 +551,7 @@ void AudioMixer::handleNodeAudioPacket(QSharedPointer message, void AudioMixer::handleMuteEnvironmentPacket(QSharedPointer message, SharedNodePointer sendingNode) { auto nodeList = DependencyManager::get(); - if (sendingNode->getCanAdjustLocks()) { + if (sendingNode->isAllowedEditor()) { auto newPacket = NLPacket::create(PacketType::MuteEnvironment, message->getSize()); // Copy payload newPacket->write(message->getRawMessage(), message->getSize()); diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index fb67744d6e..3e4ee7b758 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -155,7 +155,7 @@ SharedNodePointer DomainGatekeeper::processAssignmentConnectRequest(const NodeCo _pendingAssignedNodes.erase(it); // always allow assignment clients to create and destroy entities - newNode->setCanAdjustLocks(true); + newNode->setIsAllowedEditor(true); newNode->setCanRez(true); return newNode; @@ -219,13 +219,13 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect } } - // if this user is in the editors list (or if the editors list is empty) set the user's node's canAdjustLocks to true + // if this user is in the editors list (or if the editors list is empty) set the user's node's isAllowedEditor to true const QVariant* allowedEditorsVariant = valueForKeyPath(_server->_settingsManager.getSettingsMap(), ALLOWED_EDITORS_SETTINGS_KEYPATH); QStringList allowedEditors = allowedEditorsVariant ? allowedEditorsVariant->toStringList() : QStringList(); // if the allowed editors list is empty then everyone can adjust locks - bool canAdjustLocks = allowedEditors.empty(); + bool isAllowedEditor = allowedEditors.empty(); if (allowedEditors.contains(username, Qt::CaseInsensitive)) { // we have a non-empty allowed editors list - check if this user is verified to be in it @@ -238,10 +238,10 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect << "will be given edit rights to avoid a thrasing of public key requests and connect requests."; } - canAdjustLocks = true; + isAllowedEditor = true; } else { // already verified this user and they are in the allowed editors list - canAdjustLocks = true; + isAllowedEditor = true; } } @@ -256,14 +256,14 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect bool canRez = true; if (onlyEditorsAreRezzers) { - canRez = canAdjustLocks; + canRez = isAllowedEditor; } // add the new node SharedNodePointer newNode = addVerifiedNodeFromConnectRequest(nodeConnection); // set the edit rights for this user - newNode->setCanAdjustLocks(canAdjustLocks); + newNode->setIsAllowedEditor(isAllowedEditor); newNode->setCanRez(canRez); // grab the linked data for our new node so we can set the username diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index db3c2df408..64b4f123f5 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -744,7 +744,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif extendedHeaderStream << limitedNodeList->getSessionUUID(); extendedHeaderStream << node->getUUID(); - extendedHeaderStream << (quint8) node->getCanAdjustLocks(); + extendedHeaderStream << (quint8) node->isAllowedEditor(); extendedHeaderStream << (quint8) node->getCanRez(); auto domainListPackets = NLPacketList::create(PacketType::DomainList, extendedHeader); diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 8fd7be912e..be9010cba5 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -29,7 +29,7 @@ EntityScriptingInterface::EntityScriptingInterface() : _entityTree(NULL) { auto nodeList = DependencyManager::get(); - connect(nodeList.data(), &NodeList::canAdjustLocksChanged, this, &EntityScriptingInterface::canAdjustLocksChanged); + connect(nodeList.data(), &NodeList::isAllowedEditorChanged, this, &EntityScriptingInterface::canAdjustLocksChanged); connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptingInterface::canRezChanged); } @@ -40,7 +40,7 @@ void EntityScriptingInterface::queueEntityMessage(PacketType packetType, bool EntityScriptingInterface::canAdjustLocks() { auto nodeList = DependencyManager::get(); - return nodeList->getThisNodeCanAdjustLocks(); + return nodeList->isAllowedEditor(); } bool EntityScriptingInterface::canRez() { diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 34dd809510..3c638fd1a2 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -124,10 +124,10 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI QUuid senderID; if (senderNode.isNull()) { auto nodeList = DependencyManager::get(); - allowLockChange = nodeList->getThisNodeCanAdjustLocks(); + allowLockChange = nodeList->isAllowedEditor(); senderID = nodeList->getSessionUUID(); } else { - allowLockChange = senderNode->getCanAdjustLocks(); + allowLockChange = senderNode->isAllowedEditor(); senderID = senderNode->getUUID(); } diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 3ea3175390..67237ee269 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -52,7 +52,6 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short _numCollectedPackets(0), _numCollectedBytes(0), _packetStatTimer(), - _thisNodeCanAdjustLocks(false), _thisNodeCanRez(true) { static bool firstCall = true; @@ -131,10 +130,10 @@ void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) { } } -void LimitedNodeList::setThisNodeCanAdjustLocks(bool canAdjustLocks) { - if (_thisNodeCanAdjustLocks != canAdjustLocks) { - _thisNodeCanAdjustLocks = canAdjustLocks; - emit canAdjustLocksChanged(canAdjustLocks); +void LimitedNodeList::setIsAllowedEditor(bool isAllowedEditor) { + if (_isAllowedEditor != isAllowedEditor) { + _isAllowedEditor = isAllowedEditor; + emit isAllowedEditorChanged(isAllowedEditor); } } @@ -515,7 +514,7 @@ void LimitedNodeList::handleNodeKill(const SharedNodePointer& node) { SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, - bool canAdjustLocks, bool canRez, + bool isAllowedEditor, bool canRez, const QUuid& connectionSecret) { NodeHash::const_iterator it = _nodeHash.find(uuid); @@ -524,14 +523,14 @@ SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t matchingNode->setPublicSocket(publicSocket); matchingNode->setLocalSocket(localSocket); - matchingNode->setCanAdjustLocks(canAdjustLocks); + matchingNode->setIsAllowedEditor(isAllowedEditor); matchingNode->setCanRez(canRez); matchingNode->setConnectionSecret(connectionSecret); return matchingNode; } else { // we didn't have this node, so add them - Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket, canAdjustLocks, canRez, connectionSecret, this); + Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket, isAllowedEditor, canRez, connectionSecret, this); if (nodeType == NodeType::AudioMixer) { LimitedNodeList::flagTimeForConnectionStep(LimitedNodeList::AddedAudioMixer); diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index c9785d240b..fcad23da8f 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -104,8 +104,8 @@ public: const QUuid& getSessionUUID() const { return _sessionUUID; } void setSessionUUID(const QUuid& sessionUUID); - bool getThisNodeCanAdjustLocks() const { return _thisNodeCanAdjustLocks; } - void setThisNodeCanAdjustLocks(bool canAdjustLocks); + bool isAllowedEditor() const { return _isAllowedEditor; } + void setIsAllowedEditor(bool isAllowedEditor); bool getThisNodeCanRez() const { return _thisNodeCanRez; } void setThisNodeCanRez(bool canRez); @@ -137,7 +137,7 @@ public: SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, - bool canAdjustLocks = false, bool canRez = false, + bool isAllowedEditor = false, bool canRez = false, const QUuid& connectionSecret = QUuid()); bool hasCompletedInitialSTUN() const { return _hasCompletedInitialSTUN; } @@ -244,7 +244,7 @@ signals: void localSockAddrChanged(const HifiSockAddr& localSockAddr); void publicSockAddrChanged(const HifiSockAddr& publicSockAddr); - void canAdjustLocksChanged(bool canAdjustLocks); + void isAllowedEditorChanged(bool isAllowedEditor); void canRezChanged(bool canRez); protected: @@ -289,7 +289,7 @@ protected: int _numCollectedBytes; QElapsedTimer _packetStatTimer; - bool _thisNodeCanAdjustLocks; + bool _isAllowedEditor { false }; bool _thisNodeCanRez; QPointer _initialSTUNTimer; diff --git a/libraries/networking/src/Node.cpp b/libraries/networking/src/Node.cpp index b28d0a6cb1..7e9bf60ea4 100644 --- a/libraries/networking/src/Node.cpp +++ b/libraries/networking/src/Node.cpp @@ -47,7 +47,7 @@ const QString& NodeType::getNodeTypeName(NodeType_t nodeType) { } Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, - const HifiSockAddr& localSocket, bool canAdjustLocks, bool canRez, const QUuid& connectionSecret, + const HifiSockAddr& localSocket, bool isAllowedEditor, bool canRez, const QUuid& connectionSecret, QObject* parent) : NetworkPeer(uuid, publicSocket, localSocket, parent), _type(type), @@ -57,7 +57,7 @@ Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, _clockSkewUsec(0), _mutex(), _clockSkewMovingPercentile(30, 0.8f), // moving 80th percentile of 30 samples - _canAdjustLocks(canAdjustLocks), + _isAllowedEditor(isAllowedEditor), _canRez(canRez) { // Update socket's object name @@ -84,7 +84,7 @@ QDataStream& operator<<(QDataStream& out, const Node& node) { out << node._uuid; out << node._publicSocket; out << node._localSocket; - out << node._canAdjustLocks; + out << node._isAllowedEditor; out << node._canRez; return out; @@ -95,7 +95,7 @@ QDataStream& operator>>(QDataStream& in, Node& node) { in >> node._uuid; in >> node._publicSocket; in >> node._localSocket; - in >> node._canAdjustLocks; + in >> node._isAllowedEditor; in >> node._canRez; return in; diff --git a/libraries/networking/src/Node.h b/libraries/networking/src/Node.h index 865e885add..ca05e5b84d 100644 --- a/libraries/networking/src/Node.h +++ b/libraries/networking/src/Node.h @@ -33,7 +33,7 @@ class Node : public NetworkPeer { public: Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, - bool canAdjustLocks, bool canRez, const QUuid& connectionSecret = QUuid(), + bool isAllowedEditor, bool canRez, const QUuid& connectionSecret = QUuid(), QObject* parent = 0); bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; } @@ -58,8 +58,8 @@ public: void updateClockSkewUsec(int clockSkewSample); QMutex& getMutex() { return _mutex; } - void setCanAdjustLocks(bool canAdjustLocks) { _canAdjustLocks = canAdjustLocks; } - bool getCanAdjustLocks() { return _canAdjustLocks; } + void setIsAllowedEditor(bool isAllowedEditor) { _isAllowedEditor = isAllowedEditor; } + bool isAllowedEditor() { return _isAllowedEditor; } void setCanRez(bool canRez) { _canRez = canRez; } bool getCanRez() { return _canRez; } @@ -81,7 +81,7 @@ private: int _clockSkewUsec; QMutex _mutex; MovingPercentile _clockSkewMovingPercentile; - bool _canAdjustLocks; + bool _isAllowedEditor; bool _canRez; }; diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 16277caace..677a1ad1e6 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -512,9 +512,9 @@ void NodeList::processDomainServerList(QSharedPointer message) packetStream >> newUUID; setSessionUUID(newUUID); - quint8 thisNodeCanAdjustLocks; - packetStream >> thisNodeCanAdjustLocks; - setThisNodeCanAdjustLocks((bool) thisNodeCanAdjustLocks); + quint8 isAllowedEditor; + packetStream >> isAllowedEditor; + setIsAllowedEditor((bool) isAllowedEditor); quint8 thisNodeCanRez; packetStream >> thisNodeCanRez; @@ -546,10 +546,10 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) { qint8 nodeType; QUuid nodeUUID, connectionUUID; HifiSockAddr nodePublicSocket, nodeLocalSocket; - bool canAdjustLocks; + bool isAllowedEditor; bool canRez; - packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> canAdjustLocks >> canRez; + packetStream >> nodeType >> nodeUUID >> nodePublicSocket >> nodeLocalSocket >> isAllowedEditor >> canRez; // if the public socket address is 0 then it's reachable at the same IP // as the domain server @@ -560,7 +560,7 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) { packetStream >> connectionUUID; SharedNodePointer node = addOrUpdateNode(nodeUUID, nodeType, nodePublicSocket, - nodeLocalSocket, canAdjustLocks, canRez, + nodeLocalSocket, isAllowedEditor, canRez, connectionUUID); } From b038e4b7e7b10e82b23a4b9f0b29a08ad174ed42 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Mon, 1 Feb 2016 16:48:00 -0800 Subject: [PATCH 05/12] calibrate using either the 1 or 2 button on each hand --- plugins/hifiSixense/src/SixenseManager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/hifiSixense/src/SixenseManager.cpp b/plugins/hifiSixense/src/SixenseManager.cpp index 3377aac14c..b23982f948 100644 --- a/plugins/hifiSixense/src/SixenseManager.cpp +++ b/plugins/hifiSixense/src/SixenseManager.cpp @@ -282,8 +282,8 @@ void SixenseManager::InputDevice::setDebugDrawCalibrated(bool flag) { // the calibration sequence is: // (1) reach arm straight out to the sides (xAxis is to the left) -// (2) press BUTTON_FWD on both hands and hold for one second -// (3) release both BUTTON_FWDs +// (2) press either BUTTON_1 or BUTTON_2 on both hands and hold for one second +// (3) release both buttons // // The code will: // (4) assume that the orb is on a flat surface (yAxis is UP) @@ -294,7 +294,8 @@ static const float MAXIMUM_NOISE_LEVEL = 0.05f; // meters static const quint64 LOCK_DURATION = USECS_PER_SECOND / 4; // time for lock to be acquired static bool calibrationRequested(SixenseControllerData* controllers) { - return (controllers[0].buttons == BUTTON_FWD && controllers[1].buttons == BUTTON_FWD); + return (((controllers[0].buttons == BUTTON_1) || (controllers[0].buttons == BUTTON_2)) && + ((controllers[1].buttons == BUTTON_1) || (controllers[1].buttons == BUTTON_2))); } void SixenseManager::InputDevice::updateCalibration(SixenseControllerData* controllers) { From 0b6cfbe50aef5461ac6b60b478ef812468947da7 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Mon, 1 Feb 2016 17:48:31 -0800 Subject: [PATCH 06/12] Only connect render config if dirty signal present --- libraries/render/src/render/Task.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/render/src/render/Task.h b/libraries/render/src/render/Task.h index 148117eed6..93f3681c1c 100644 --- a/libraries/render/src/render/Task.h +++ b/libraries/render/src/render/Task.h @@ -257,7 +257,13 @@ public: QConfigPointer config = _jobs.back().getConfiguration(); config->setParent(_config.get()); config->setObjectName(name.c_str()); - QObject::connect(config.get(), SIGNAL(dirty()), _config.get(), SLOT(refresh())); + + // Connect dirty->refresh if defined + static const char* DIRTY_SIGNAL = "dirty()"; + if (config->metaObject()->indexOfSignal(DIRTY_SIGNAL) != -1) { + QObject::connect(config.get(), SIGNAL(dirty()), _config.get(), SLOT(refresh())); + } + return _jobs.back().getOutput(); } template const Varying addJob(std::string name, A&&... args) { From dad36b73fc3edaea1ea271403be8b44583dbdc63 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 2 Feb 2016 09:57:52 -0800 Subject: [PATCH 07/12] Disable gridTool in edit.js --- examples/edit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/edit.js b/examples/edit.js index 286542a91f..29f16a5633 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -336,7 +336,7 @@ var toolBar = (function() { isActive = active; if (!isActive) { entityListTool.setVisible(false); - gridTool.setVisible(false); + // gridTool.setVisible(false); grid.setEnabled(false); propertiesTool.setVisible(false); selectionManager.clearSelections(); @@ -344,7 +344,7 @@ var toolBar = (function() { } else { hasShownPropertiesTool = false; entityListTool.setVisible(true); - gridTool.setVisible(true); + // gridTool.setVisible(true); grid.setEnabled(true); propertiesTool.setVisible(true); Window.setFocus(); From 57d92bcfa6faaa11beafdae07ff914a6b53014b1 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 2 Feb 2016 10:13:24 -0800 Subject: [PATCH 08/12] Stop creation of GridTool altogether in edit.js --- examples/edit.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/edit.js b/examples/edit.js index 29f16a5633..cc5921efd1 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -39,10 +39,10 @@ var lightOverlayManager = new LightOverlayManager(); var cameraManager = new CameraManager(); var grid = Grid(); -gridTool = GridTool({ - horizontalGrid: grid -}); -gridTool.setVisible(false); +// gridTool = GridTool({ +// horizontalGrid: grid +// }); +// gridTool.setVisible(false); var entityListTool = EntityListTool(); From 79dc2d5d5502f5aeaa98a0f55e6d0a6b012a7544 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 2 Feb 2016 11:40:15 -0800 Subject: [PATCH 09/12] add some debug for mute environment crash --- assignment-client/src/audio/AudioMixer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 8967436e2d..54032e993f 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -552,6 +552,8 @@ void AudioMixer::handleMuteEnvironmentPacket(QSharedPointer mes auto nodeList = DependencyManager::get(); if (sendingNode->isAllowedEditor()) { + qDebug() << "Received a mute environment packet of" << message->getSize() << "bytes"; + auto newPacket = NLPacket::create(PacketType::MuteEnvironment, message->getSize()); // Copy payload newPacket->write(message->getRawMessage(), message->getSize()); From 5adf9adb0e8321e21e50cba65764f7e5fd0d8a78 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Tue, 2 Feb 2016 12:00:17 -0800 Subject: [PATCH 10/12] Make mirror rectaqngle move with mirror controls --- interface/src/Application.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ab5edec527..883b082d0e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1362,6 +1362,9 @@ void Application::paintGL() { renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; renderArgs._blitFramebuffer = DependencyManager::get()->getSelfieFramebuffer(); + auto inputs = AvatarInputs::getInstance(); + _mirrorViewRect.moveTo(inputs->x(), inputs->y()); + renderRearViewMirror(&renderArgs, _mirrorViewRect); renderArgs._blitFramebuffer.reset(); From 2c26b32341fa53453aa6bacf4aed4557c53e960f Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Tue, 2 Feb 2016 12:00:58 -0800 Subject: [PATCH 11/12] Make QML based tool-windows close properly --- libraries/ui/src/QmlWindowClass.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/libraries/ui/src/QmlWindowClass.cpp b/libraries/ui/src/QmlWindowClass.cpp index 3874b85a12..0e834fa379 100644 --- a/libraries/ui/src/QmlWindowClass.cpp +++ b/libraries/ui/src/QmlWindowClass.cpp @@ -220,18 +220,7 @@ QmlWindowClass::QmlWindowClass(QObject* qmlWindow) } QmlWindowClass::~QmlWindowClass() { - if (_qmlWindow) { - if (_toolWindow) { - auto offscreenUi = DependencyManager::get(); - auto toolWindow = offscreenUi->getToolWindow(); - auto invokeResult = QMetaObject::invokeMethod(toolWindow, "removeTabForUrl", Qt::QueuedConnection, - Q_ARG(QVariant, _source)); - Q_ASSERT(invokeResult); - } else { - _qmlWindow->deleteLater(); - } - _qmlWindow = nullptr; - } + close(); } void QmlWindowClass::registerObject(const QString& name, QObject* object) { @@ -331,14 +320,18 @@ void QmlWindowClass::setTitle(const QString& title) { } void QmlWindowClass::close() { - DependencyManager::get()->executeOnUiThread([this] { - if (_qmlWindow) { - _qmlWindow->setProperty("destroyOnInvisible", true); - _qmlWindow->setProperty("visible", false); + if (_qmlWindow) { + if (_toolWindow) { + auto offscreenUi = DependencyManager::get(); + auto toolWindow = offscreenUi->getToolWindow(); + auto invokeResult = QMetaObject::invokeMethod(toolWindow, "removeTabForUrl", Qt::QueuedConnection, + Q_ARG(QVariant, _source)); + Q_ASSERT(invokeResult); + } else { _qmlWindow->deleteLater(); - _qmlWindow = nullptr; } - }); + _qmlWindow = nullptr; + } } void QmlWindowClass::hasClosed() { From aa10af2851f25284dd1ed4c8ee0ceed4f517add1 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Tue, 2 Feb 2016 17:10:21 -0800 Subject: [PATCH 12/12] Revert "Move DrawStencil to use ShapePlumber" This reverts commit 671f27e5bc3950cc75884a5b8b0e6b6221011cb5. --- .../render-utils/src/RenderDeferredTask.cpp | 15 ++++++---- .../render-utils/src/RenderDeferredTask.h | 9 +++--- .../render-utils/src/RenderPipelines.cpp | 28 +++++++++---------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 8a47280526..e21b8ce799 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -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() } { - 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; } diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index 894a91cdc3..0be2e0e808 100755 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -68,14 +68,13 @@ protected: class DrawStencilDeferred { public: - DrawStencilDeferred(); - - void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); - using JobModel = render::Job::Model; + 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 { diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp index a7e9081d9a..d2e880aea3 100644 --- a/libraries/render-utils/src/RenderPipelines.cpp +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -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(); - 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(); + opaqueState->setDepthTest(false); + opaqueState->setBlendFunction(false); + + plumber.addPipeline(ShapeKey::Filter::Builder().withOpaque(), program, opaqueState); } void pipelineBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) {