From 0bc89d6b18474a1d6514ecc2b2b42105da81af41 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Thu, 28 Apr 2016 10:52:09 -0700 Subject: [PATCH] Avoid missing pipeline log flood --- libraries/render/src/render/DrawTask.cpp | 4 ++-- libraries/render/src/render/ShapePipeline.cpp | 6 +++++- libraries/render/src/render/ShapePipeline.h | 10 ++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libraries/render/src/render/DrawTask.cpp b/libraries/render/src/render/DrawTask.cpp index 58b3a50e54..6d43d169c3 100755 --- a/libraries/render/src/render/DrawTask.cpp +++ b/libraries/render/src/render/DrawTask.cpp @@ -46,7 +46,7 @@ void renderShape(RenderArgs* args, const ShapePlumberPointer& shapeContext, cons } else if (key.hasOwnPipeline()) { item.render(args); } else { - qDebug() << "Item could not be rendered: invalid key ?" << key; + qDebug() << "Item could not be rendered with invalid key" << key; } } @@ -96,7 +96,7 @@ void render::renderStateSortShapes(const SceneContextPointer& sceneContext, cons } else if (key.hasOwnPipeline()) { ownPipelineBucket.push_back(item); } else { - qDebug() << "Item could not be rendered: invalid key ?" << key; + qDebug() << "Item could not be rendered with invalid key" << key; } } } diff --git a/libraries/render/src/render/ShapePipeline.cpp b/libraries/render/src/render/ShapePipeline.cpp index b09d4b1356..a4ebdb30b6 100644 --- a/libraries/render/src/render/ShapePipeline.cpp +++ b/libraries/render/src/render/ShapePipeline.cpp @@ -93,7 +93,11 @@ const ShapePipelinePointer ShapePlumber::pickPipeline(RenderArgs* args, const Ke const auto& pipelineIterator = _pipelineMap.find(key); if (pipelineIterator == _pipelineMap.end()) { - qDebug() << "Couldn't find a pipeline from ShapeKey ?" << key; + // The first time we can't find a pipeline, we should log it + if (_missingKeys.find(key) == _missingKeys.end()) { + _missingKeys.insert(key); + qDebug() << "Couldn't find a pipeline for" << key; + } return PipelinePointer(nullptr); } diff --git a/libraries/render/src/render/ShapePipeline.h b/libraries/render/src/render/ShapePipeline.h index 22aa22d4c9..cf7d1c7c29 100644 --- a/libraries/render/src/render/ShapePipeline.h +++ b/libraries/render/src/render/ShapePipeline.h @@ -12,6 +12,8 @@ #ifndef hifi_render_ShapePipeline_h #define hifi_render_ShapePipeline_h +#include + #include #include @@ -147,7 +149,7 @@ public: bool hasOwnPipeline() const { return _flags[OWN_PIPELINE]; } bool isValid() const { return !_flags[INVALID]; } - // Hasher for use in unordered_maps + // Comparator for use in stl containers class Hash { public: size_t operator() (const ShapeKey& key) const { @@ -155,7 +157,7 @@ public: } }; - // Comparator for use in unordered_maps + // Comparator for use in stl containers class KeyEqual { public: bool operator()(const ShapeKey& lhs, const ShapeKey& rhs) const { return lhs._flags == rhs._flags; } @@ -264,7 +266,11 @@ public: protected: void addPipelineHelper(const Filter& filter, Key key, int bit, const PipelinePointer& pipeline); PipelineMap _pipelineMap; + +private: + mutable std::unordered_set _missingKeys; }; + using ShapePlumberPointer = std::shared_ptr; }