diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 480a9ebb8b..981de190d3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3431,10 +3431,10 @@ namespace render { // Background rendering decision auto skyStage = DependencyManager::get()->getSkyStage(); - auto skybox = model::SkyboxPointer(); if (skyStage->getBackgroundMode() == model::SunSkyStage::NO_BACKGROUND) { + // this line intentionally left blank } else if (skyStage->getBackgroundMode() == model::SunSkyStage::SKY_DOME) { - if (/*!selfAvatarOnly &&*/ Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { + if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { PerformanceTimer perfTimer("stars"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::payloadRender() ... stars..."); @@ -3500,8 +3500,7 @@ namespace render { } } else if (skyStage->getBackgroundMode() == model::SunSkyStage::SKY_BOX) { PerformanceTimer perfTimer("skybox"); - - skybox = skyStage->getSkybox(); + auto skybox = skyStage->getSkybox(); if (skybox) { skybox->render(batch, *(qApp->getDisplayViewFrustum())); } @@ -3767,6 +3766,10 @@ void Application::clearDomainOctreeDetails() { // reset the model renderer getEntities()->clear(); + + auto skyStage = DependencyManager::get()->getSkyStage(); + skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); + } void Application::domainChanged(const QString& domainHostname) { diff --git a/libraries/audio/src/AudioEffectOptions.cpp b/libraries/audio/src/AudioEffectOptions.cpp index 758875e896..9d3ce9299b 100644 --- a/libraries/audio/src/AudioEffectOptions.cpp +++ b/libraries/audio/src/AudioEffectOptions.cpp @@ -55,7 +55,7 @@ static const float LATE_MIX_RIGHT_DEFAULT = 90.0f; static const float WET_DRY_MIX_DEFAULT = 50.0f; static void setOption(QScriptValue arguments, const QString name, float defaultValue, float& variable) { - variable = arguments.property(name).isNumber() ? arguments.property(name).toNumber() : defaultValue; + variable = arguments.property(name).isNumber() ? (float)arguments.property(name).toNumber() : defaultValue; } AudioEffectOptions::AudioEffectOptions(QScriptValue arguments) { diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index c89619448d..ba6294f8a8 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -226,9 +226,16 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI while (!toProcess.empty()) { EntityItemPointer childEntity = std::static_pointer_cast(toProcess.dequeue()); + if (!childEntity) { + continue; + } BoundingBoxRelatedProperties newChildBBRelProperties(childEntity); + EntityTreeElementPointer containingElement = childEntity->getElement(); + if (!containingElement) { + continue; + } UpdateEntityOperator theChildOperator(getThisPointer(), - childEntity->getElement(), + containingElement, childEntity, newChildBBRelProperties); recurseTreeWithOperator(&theChildOperator); foreach (SpatiallyNestablePointer childChild, childEntity->getChildren()) { diff --git a/libraries/gl/src/gl/GLEscrow.h b/libraries/gl/src/gl/GLEscrow.h index 511dec6a10..7e126835ab 100644 --- a/libraries/gl/src/gl/GLEscrow.h +++ b/libraries/gl/src/gl/GLEscrow.h @@ -48,35 +48,32 @@ template < > class GLEscrow { public: + static const uint64_t MAX_UNSIGNALED_TIME = USECS_PER_SECOND / 2; struct Item { - T _value; + const T _value; GLsync _sync; - uint64_t _created; + const uint64_t _created; Item(T value, GLsync sync) : _value(value), _sync(sync), _created(usecTimestampNow()) { } - uint64_t age() { + uint64_t age() const { return usecTimestampNow() - _created; } - bool signaled() { + bool signaled() const { auto result = glClientWaitSync(_sync, 0, 0); if (GL_TIMEOUT_EXPIRED != result && GL_WAIT_FAILED != result) { return true; } - if (age() > (USECS_PER_SECOND / 2)) { - qWarning() << "Long unsignaled sync"; - } return false; } }; - using Mutex = std::recursive_mutex; - using Lock = std::unique_lock; + using Mutex = std::mutex; using Recycler = std::function; // deque gives us random access, double ended push & pop and size, all in constant time using Deque = std::deque; @@ -86,9 +83,32 @@ public: _recycler = recycler; } - size_t depth() { + template + void withLock(F f) { + using Lock = std::unique_lock; Lock lock(_mutex); - return _submits.size(); + f(); + } + + template + bool tryLock(F f) { + using Lock = std::unique_lock; + bool result = false; + Lock lock(_mutex, std::try_to_lock_t()); + if (lock.owns_lock()) { + f(); + result = true; + } + return result; + } + + + size_t depth() { + size_t result{ 0 }; + withLock([&]{ + result = _submits.size(); + }); + return result; } // Submit a new resource from the producer context @@ -103,11 +123,9 @@ public: glFlush(); } - { - Lock lock(_mutex); + withLock([&]{ _submits.push_back(Item(t, writeSync)); - } - + }); return cleanTrash(); } @@ -119,13 +137,13 @@ public: // On the one hand using try_lock() reduces the chance of blocking the consumer thread, // but if the produce thread is going fast enough, it could effectively // starve the consumer out of ever actually getting resources. - if (_mutex.try_lock()) { + tryLock([&]{ + // May be called on any thread, but must be inside a locked section if (signaled(_submits, 0)) { result = _submits.at(0)._value; _submits.pop_front(); } - _mutex.unlock(); - } + }); return result; } @@ -153,37 +171,45 @@ public: glFlush(); } - Lock lock(_mutex); - _releases.push_back(Item(t, readSync)); + withLock([&]{ + _releases.push_back(Item(t, readSync)); + }); } private: size_t cleanTrash() { size_t wastedWork{ 0 }; List trash; - { + tryLock([&]{ + while (!_submits.empty()) { + const auto& item = _submits.front(); + if (!item._sync || item.age() < MAX_UNSIGNALED_TIME) { + break; + } + qWarning() << "Long unsignaled sync " << item._sync << " unsignaled for " << item.age(); + _trash.push_front(item); + _submits.pop_front(); + } + // We only ever need one ready item available in the list, so if the // second item is signaled (implying the first is as well, remove the first // item. Iterate until the SECOND item in the list is not in the ready state // The signaled function takes care of checking against the deque size while (signaled(_submits, 1)) { - pop(_submits); + _trash.push_front(_submits.front()); + _submits.pop_front(); ++wastedWork; } // Stuff in the release queue can be cleared out as soon as it's signaled while (signaled(_releases, 0)) { - pop(_releases); + _trash.push_front(_releases.front()); + _releases.pop_front(); } - { - // FIXME I don't think this lock should be necessary, only the submitting thread - // touches the trash - Lock lock(_mutex); - trash.swap(_trash); - } - } - + trash.swap(_trash); + }); + // FIXME maybe doing a timing on the deleters and warn if it's taking excessive time? // although we are out of the lock, so it shouldn't be blocking anything std::for_each(trash.begin(), trash.end(), [&](typename List::const_reference item) { @@ -197,14 +223,6 @@ private: return wastedWork; } - // May be called on any thread, but must be inside a locked section - void pop(Deque& deque) { - Lock lock(_mutex); - auto& item = deque.front(); - _trash.push_front(item); - deque.pop_front(); - } - // May be called on any thread, but must be inside a locked section bool signaled(Deque& deque, size_t i) { if (i >= deque.size()) { diff --git a/libraries/render/src/render/DrawTask.h b/libraries/render/src/render/DrawTask.h index 3f628c3a02..5dd61e347f 100755 --- a/libraries/render/src/render/DrawTask.h +++ b/libraries/render/src/render/DrawTask.h @@ -216,7 +216,7 @@ void renderItems(const SceneContextPointer& sceneContext, const RenderContextPoi class FetchItems { public: - typedef std::function ProbeNumItems; + typedef std::function ProbeNumItems; FetchItems(const ProbeNumItems& probe): _probeNumItems(probe) {} FetchItems(const ItemFilter& filter, const ProbeNumItems& probe): _filter(filter), _probeNumItems(probe) {}