From 79278f5add3e881af1e4d3811b7c85d6c84f741b Mon Sep 17 00:00:00 2001 From: LaShonda Hopper Date: Fri, 27 Apr 2018 17:23:27 -0400 Subject: [PATCH 01/29] [BugFix] EntityList UncaughtException in that.sendUpdate (details below). * Adds safety checks to properties.renderInfo to prevent invalid access when undefined. * Error trace prior to guards: [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] [defaultScripts.js] [UncaughtException signalHandlerException] Error: Result of expression 'properties.renderInfo' [undefined] is not an object. in .../build/interface/RelWithDebInfo/scripts/system/libraries/entityList.js:93 [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] [Backtrace] [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] () at .../build/interface/RelWithDebInfo/scripts/system/libraries/entityList.js:93 [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] (data = [object Object]) at .../build/interface/RelWithDebInfo/scripts/system/libraries/entityList.js:149 [04/27 13:16:19] [CRITICAL] [hifi.scriptengine] () at -1 Changes Committed: modified: scripts/system/libraries/entityList.js --- scripts/system/libraries/entityList.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index d53766ab4e..8cd8decbef 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -90,12 +90,17 @@ EntityListTool = function(opts) { url: url, locked: properties.locked, visible: properties.visible, - verticesCount: valueIfDefined(properties.renderInfo.verticesCount), - texturesCount: valueIfDefined(properties.renderInfo.texturesCount), - texturesSize: valueIfDefined(properties.renderInfo.texturesSize), - hasTransparent: valueIfDefined(properties.renderInfo.hasTransparent), + verticesCount: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.verticesCount) : ""), + texturesCount: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.texturesCount) : ""), + texturesSize: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.texturesSize) : ""), + hasTransparent: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.hasTransparent) : ""), isBaked: properties.type == "Model" ? url.toLowerCase().endsWith(".baked.fbx") : false, - drawCalls: valueIfDefined(properties.renderInfo.drawCalls), + drawCalls: (properties.renderInfo !== undefined ? + valueIfDefined(properties.renderInfo.drawCalls) : ""), hasScript: properties.script !== "" }); } From dcebbada28ad436646a17b2eecc0b9241cda6cef Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 19 Jun 2018 10:13:48 -0700 Subject: [PATCH 02/29] fix various crashes-upon-exits --- interface/src/Application.cpp | 22 +++++++++++-------- interface/src/Application_render.cpp | 5 ++++- interface/src/ui/ApplicationOverlay.cpp | 2 ++ libraries/networking/src/ResourceManager.cpp | 9 ++++++-- .../plugins/src/plugins/PluginManager.cpp | 5 ++--- libraries/plugins/src/plugins/PluginManager.h | 10 +++++++-- 6 files changed, 36 insertions(+), 17 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2033e8ee8e..54ecaf1201 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -814,6 +814,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { } // Tell the plugin manager about our statically linked plugins + DependencyManager::set(); auto pluginManager = PluginManager::getInstance(); pluginManager->setInputPluginProvider([] { return getInputPlugins(); }); pluginManager->setDisplayPluginProvider([] { return getDisplayPlugins(); }); @@ -1375,6 +1376,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo initializeRenderEngine(); qCDebug(interfaceapp, "Initialized Render Engine."); + // Overlays need to exist before we set the ContextOverlayInterface dependency + _overlays.init(); // do this before scripts load + DependencyManager::set(); + // Initialize the user interface and menu system // Needs to happen AFTER the render engine initialization to access its configuration initializeUi(); @@ -1511,10 +1516,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // allow you to move an entity around in your hand _entityEditSender.setPacketsPerSecond(3000); // super high!! - // Overlays need to exist before we set the ContextOverlayInterface dependency - _overlays.init(); // do this before scripts load - DependencyManager::set(); - // Make sure we don't time out during slow operations at startup updateHeartbeat(); @@ -2552,12 +2553,18 @@ Application::~Application() { _octreeProcessor.terminate(); _entityEditSender.terminate(); + if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { + steamClient->shutdown(); + } + DependencyManager::destroy(); + + DependencyManager::destroy(); // must be destroyed before the FramebufferCache + DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); - DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); @@ -2567,10 +2574,6 @@ Application::~Application() { // remove the NodeList from the DependencyManager DependencyManager::destroy(); - if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { - steamClient->shutdown(); - } - #if 0 ConnexionClient::getInstance().destroy(); #endif @@ -2890,6 +2893,7 @@ void Application::initializeUi() { auto compositorHelper = DependencyManager::get(); connect(compositorHelper.data(), &CompositorHelper::allowMouseCaptureChanged, this, [=] { if (isHMDMode()) { + auto compositorHelper = DependencyManager::get(); // don't capture outer smartpointer showCursor(compositorHelper->getAllowMouseCapture() ? Cursor::Manager::lookupIcon(_preferredCursor.get()) : Cursor::Icon::SYSTEM); diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp index 2daa49dcf7..6b4840e3e5 100644 --- a/interface/src/Application_render.cpp +++ b/interface/src/Application_render.cpp @@ -139,7 +139,10 @@ void Application::paintGL() { frame->frameIndex = _renderFrameCount; frame->framebuffer = finalFramebuffer; frame->framebufferRecycler = [](const gpu::FramebufferPointer& framebuffer) { - DependencyManager::get()->releaseFramebuffer(framebuffer); + auto frameBufferCache = DependencyManager::get(); + if (frameBufferCache) { + frameBufferCache->releaseFramebuffer(framebuffer); + } }; // deliver final scene rendering commands to the display plugin { diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index ea660fb0e2..7db6a49d1c 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -50,6 +50,8 @@ ApplicationOverlay::~ApplicationOverlay() { geometryCache->releaseID(_magnifierBorder); geometryCache->releaseID(_qmlGeometryId); } + + DependencyManager::destroy(); } // Renders the overlays either to a texture or to the screen diff --git a/libraries/networking/src/ResourceManager.cpp b/libraries/networking/src/ResourceManager.cpp index 6df15129a2..46cf43b97d 100644 --- a/libraries/networking/src/ResourceManager.cpp +++ b/libraries/networking/src/ResourceManager.cpp @@ -39,8 +39,13 @@ ResourceManager::ResourceManager(bool atpSupportEnabled) : _atpSupportEnabled(at } ResourceManager::~ResourceManager() { - _thread.terminate(); - _thread.wait(); + if (_thread.isRunning()) { + _thread.quit(); + static const auto MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME = 0.5 * MSECS_PER_SECOND; + if (!_thread.wait(MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME)) { + _thread.terminate(); + } + } } void ResourceManager::setUrlPrefixOverride(const QString& prefix, const QString& replacement) { diff --git a/libraries/plugins/src/plugins/PluginManager.cpp b/libraries/plugins/src/plugins/PluginManager.cpp index e9c084e132..40b6ed820a 100644 --- a/libraries/plugins/src/plugins/PluginManager.cpp +++ b/libraries/plugins/src/plugins/PluginManager.cpp @@ -40,9 +40,8 @@ void PluginManager::setInputPluginSettingsPersister(const InputPluginSettingsPer _inputSettingsPersister = persister; } -PluginManager* PluginManager::getInstance() { - static PluginManager _manager; - return &_manager; +PluginManagerPointer PluginManager::getInstance() { + return DependencyManager::get(); } QString getPluginNameFromMetaData(QJsonObject object) { diff --git a/libraries/plugins/src/plugins/PluginManager.h b/libraries/plugins/src/plugins/PluginManager.h index f16ad7d09f..226ccc8060 100644 --- a/libraries/plugins/src/plugins/PluginManager.h +++ b/libraries/plugins/src/plugins/PluginManager.h @@ -9,11 +9,17 @@ #include +#include + #include "Forward.h" -class PluginManager : public QObject { + +class PluginManager; +using PluginManagerPointer = QSharedPointer; + +class PluginManager : public QObject, public Dependency { public: - static PluginManager* getInstance(); + static PluginManagerPointer getInstance(); PluginManager(); const DisplayPluginList& getDisplayPlugins(); From 18219464f191b79d8a6d0254c8c41af000975ccf Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Wed, 27 Jun 2018 09:39:19 -0700 Subject: [PATCH 03/29] Fix shutdown crash on Mac in Application::onPresent --- interface/src/Application.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2033e8ee8e..c2600f9fca 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -269,9 +269,6 @@ public: } _renderContext->doneCurrent(); - // Deleting the object with automatically shutdown the thread - connect(qApp, &QCoreApplication::aboutToQuit, this, &QObject::deleteLater); - // Transfer to a new thread moveToNewNamedThread(this, "RenderThread", [this](QThread* renderThread) { hifi::qt::addBlockingForbiddenThread("Render", renderThread); @@ -2590,6 +2587,8 @@ Application::~Application() { // Can't log to file passed this point, FileLogger about to be deleted qInstallMessageHandler(LogHandler::verboseMessageHandler); + + _renderEventHandler->deleteLater(); } void Application::initializeGL() { From 4afb19e09106f4605a14e7634bca0a071a9cacb2 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Wed, 27 Jun 2018 09:49:51 -0700 Subject: [PATCH 04/29] Remove assert in ~Frame causing shutdown crash on Mac in dev build --- libraries/gpu/src/gpu/Frame.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/gpu/src/gpu/Frame.cpp b/libraries/gpu/src/gpu/Frame.cpp index d08a8ab56d..f1001d97d2 100644 --- a/libraries/gpu/src/gpu/Frame.cpp +++ b/libraries/gpu/src/gpu/Frame.cpp @@ -21,10 +21,7 @@ Frame::~Frame() { framebuffer.reset(); } - assert(bufferUpdates.empty()); - if (!bufferUpdates.empty()) { - qFatal("Buffer sync error... frame destroyed without buffer updates being applied"); - } + bufferUpdates.clear(); } void Frame::finish() { From 2cdda231698a3e31eeeeaed67c8822dd467856af Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 27 Jun 2018 13:05:39 -0700 Subject: [PATCH 05/29] more robustness for optional properties --- scripts/system/edit.js | 1 - .../particle_explorer/hifi-entity-ui.js | 48 +++------- .../particle_explorer/particleExplorerTool.js | 93 +++++++++++++------ 3 files changed, 80 insertions(+), 62 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index e9c7a49378..08e7a541d5 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -2373,7 +2373,6 @@ function selectParticleEntity(entityID) { particleExplorerTool.createWebView(); particleExplorerTool.setActiveParticleEntity(entityID); - particleExplorerTool.setActiveParticleProperties(properties); // Switch to particle explorer var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 36505a0b7f..62a0aadc86 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -61,12 +61,18 @@ function HifiEntityUI(parent) { this.parent = parent; var self = this; + this.sendPackage = {}; this.settingsUpdateLock = false; - this.webBridgeSync = _.debounce(function (id, val) { - if (self.EventBridge && !self.settingsUpdateLock) { - var sendPackage = {}; - sendPackage[id] = val; - self.submitChanges(sendPackage); + this.webBridgeSync = function(id, val) { + if (!this.settingsUpdateLock) { + this.sendPackage[id] = val; + this.webBridgeSyncDebounce(); + } + }; + this.webBridgeSyncDebounce = _.debounce(function () { + if (self.EventBridge) { + self.submitChanges(self.sendPackage); + self.sendPackage = {}; } }, DEBOUNCE_TIMEOUT); } @@ -159,7 +165,6 @@ HifiEntityUI.prototype = { var self = this; var fields = document.getElementsByTagName("input"); - self.settingsUpdateLock = true; if (!currentProperties.locked) { for (var i = 0; i < fields.length; i++) { fields[i].removeAttribute("disabled"); @@ -179,7 +184,7 @@ HifiEntityUI.prototype = { for (var e in keys) { if (keys.hasOwnProperty(e)) { var value = keys[e]; - + var property = currentProperties[value]; var field = self.builtRows[value]; if (field) { @@ -235,10 +240,6 @@ HifiEntityUI.prototype = { } } } - // Now unlocking settings Update lock for sending messages on callbacks. - setTimeout(function () { - self.settingsUpdateLock = false; - }, DEBOUNCE_TIMEOUT * 2.5); }, connect: function (EventBridge) { this.EventBridge = EventBridge; @@ -253,28 +254,9 @@ HifiEntityUI.prototype = { data = JSON.parse(data); if (data.messageType === 'particle_settings') { - // Update settings - var currentProperties = data.currentProperties; - // Update uninitialized variables - if (!currentProperties.alphaStart) { - currentProperties.alphaStart = currentProperties.alpha; - } - if (!currentProperties.alphaFinish) { - currentProperties.alphaFinish = currentProperties.alpha; - } - if (!currentProperties.radiusStart) { - currentProperties.radiusStart = currentProperties.particleRadius; - } - if (!currentProperties.radiusFinish) { - currentProperties.radiusFinish = currentProperties.particleRadius; - } - if (!currentProperties.colorStart || !currentProperties.colorStart.red) { - currentProperties.colorStart = currentProperties.color; - } - if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) { - currentProperties.colorFinish = currentProperties.color; - } - self.fillFields(currentProperties); + self.settingsUpdateLock = true; + self.fillFields(data.currentProperties); + self.settingsUpdateLock = false; // Do expected property match with structure; } else if (data.messageType === 'particle_close') { self.disableFields(); diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index a1f06fda35..0de86fbf2f 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -9,7 +9,8 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* global window, alert, ParticleExplorerTool, EventBridge, dat, listenForSettingsUpdates,createVec3Folder,createQuatFolder,writeVec3ToInterface,writeDataToInterface*/ +/* global window, alert, ParticleExplorerTool, EventBridge, dat, listenForSettingsUpdates, createVec3Folder, + createQuatFolder, writeVec3ToInterface, writeDataToInterface */ var PARTICLE_EXPLORER_HTML_URL = Script.resolvePath('particleExplorer.html'); @@ -17,7 +18,7 @@ var PARTICLE_EXPLORER_HTML_URL = Script.resolvePath('particleExplorer.html'); ParticleExplorerTool = function() { var that = {}; that.activeParticleEntity = 0; - that.activeParticleProperties = {}; + that.updatedActiveParticleProperties = {}; that.createWebView = function() { that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); @@ -30,7 +31,7 @@ ParticleExplorerTool = function() { return; } that.activeParticleEntity = 0; - that.activeParticleProperties = {}; + that.updatedActiveParticleProperties = {}; var messageData = { messageType: "particle_close" @@ -38,46 +39,86 @@ ParticleExplorerTool = function() { that.webView.emitScriptEvent(JSON.stringify(messageData)); }; - function sendActiveParticleProperties() { + function sendParticleProperties(properties) { that.webView.emitScriptEvent(JSON.stringify({ messageType: "particle_settings", - currentProperties: that.activeParticleProperties + currentProperties: properties })); } + function sendActiveParticleProperties() { + var properties = Entities.getEntityProperties(that.activeParticleEntity); + if (properties.emitOrientation) { + properties.emitOrientation = Quat.safeEulerAngles(properties.emitOrientation); + } + // Update uninitialized variables + if (isNaN(properties.alphaStart)) { + properties.alphaStart = properties.alpha; + } + if (isNaN(properties.alphaFinish)) { + properties.alphaFinish = properties.alpha; + } + if (isNaN(properties.radiusStart)) { + properties.radiusStart = properties.particleRadius; + } + if (isNaN(properties.radiusFinish)) { + properties.radiusFinish = properties.particleRadius; + } + if (isNaN(properties.colorStart) || isNaN(properties.colorStart.red)) { + properties.colorStart = properties.color; + } + if (isNaN(properties.colorFinish) || isNaN(properties.colorFinish.red)) { + properties.colorFinish = properties.color; + } + sendParticleProperties(properties); + } + + function sendUpdatedActiveParticleProperties() { + sendParticleProperties(that.updatedActiveParticleProperties); + that.updatedActiveParticleProperties = {}; + } + that.webEventReceived = function(message) { var data = JSON.parse(message); if (data.messageType === "settings_update") { - if (data.updatedSettings.emitOrientation) { - data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation); - } - Entities.editEntity(that.activeParticleEntity, data.updatedSettings); - - for (var key in data.updatedSettings) { - if (that.activeParticleProperties.hasOwnProperty(key)) { - that.activeParticleProperties[key] = data.updatedSettings[key]; - } - } + var updatedSettings = data.updatedSettings; var optionalProps = ["alphaStart", "alphaFinish", "radiusStart", "radiusFinish", "colorStart", "colorFinish"]; var fallbackProps = ["alpha", "particleRadius", "color"]; - var entityProps = Entities.getEntityProperties(that.activeParticleProperties, optionalProps); + for (var i = 0; i < optionalProps.length; i++) { + var fallbackProp = fallbackProps[Math.floor(i / 2)]; + var optionalValue = updatedSettings[optionalProps[i]]; + var fallbackValue = updatedSettings[fallbackProp]; + if (optionalValue && fallbackValue) { + delete updatedSettings[optionalProps[i]]; + } + } + + if (updatedSettings.emitOrientation) { + updatedSettings.emitOrientation = Quat.fromVec3Degrees(updatedSettings.emitOrientation); + } + + Entities.editEntity(that.activeParticleEntity, updatedSettings); + + var entityProps = Entities.getEntityProperties(that.activeParticleEntity, optionalProps); + var needsUpdate = false; for (var i = 0; i < optionalProps.length; i++) { - var fallback = fallbackProps[Math.floor(i / 2)]; - if (data.updatedSettings[fallback]) { - var prop = optionalProps[i]; - if (!that.activeParticleProperties[prop] || (fallback === "color" && !that.activeParticleProperties[prop].red)) { - that.activeParticleProperties[prop] = entityProps[fallback]; + var fallbackProp = fallbackProps[Math.floor(i / 2)]; + var fallbackValue = updatedSettings[fallbackProp]; + if (fallbackValue) { + var optionalProp = optionalProps[i]; + if (isNaN(entityProps[optionalProp]) || (fallbackProp === "color" && isNaN(entityProps[optionalProp].red))) { + that.updatedActiveParticleProperties[optionalProp] = fallbackValue; needsUpdate = true; } } } if (needsUpdate) { - sendActiveParticleProperties(); + sendUpdatedActiveParticleProperties(); } - + } else if (data.messageType === "page_loaded") { sendActiveParticleProperties(); } @@ -85,12 +126,8 @@ ParticleExplorerTool = function() { that.setActiveParticleEntity = function(id) { that.activeParticleEntity = id; - }; - - that.setActiveParticleProperties = function(properties) { - that.activeParticleProperties = properties; sendActiveParticleProperties(); }; - + return that; }; From 8228afb3782c2b11cfd3d7ee72c243e1c7ac86eb Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Wed, 27 Jun 2018 17:15:54 -0700 Subject: [PATCH 06/29] Resolving issue where VR input for movement stops emotes --- scripts/system/emote.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/system/emote.js b/scripts/system/emote.js index 1c741ba129..d484078b7b 100644 --- a/scripts/system/emote.js +++ b/scripts/system/emote.js @@ -84,7 +84,7 @@ function onWebEventReceived(event) { emoteName = event.data + randSit; // Sit1, Sit2, Sit3 } - if (ANIMATIONS[emoteName].resource.state =+= FINISHED) { + if (ANIMATIONS[emoteName].resource.state === FINISHED) { if (activeTimer !== false) { Script.clearTimeout(activeTimer); @@ -101,6 +101,7 @@ function onWebEventReceived(event) { // If user provides input during a sit, the avatar animation state should be restored Controller.keyPressEvent.connect(restoreAnimation); + Controller.enableMapping(eventMappingName); MyAvatar.overrideAnimation(ANIMATIONS[emoteName].url, FPS, false, 0, frameCount); } else { @@ -132,6 +133,7 @@ function restoreAnimation() { // Make sure the input is disconnected after animations are restored so it doesn't affect any emotes other than sit Controller.keyPressEvent.disconnect(restoreAnimation); + Controller.disableMapping(eventMappingName); } // Note peek() so as to not interfere with other mappings. @@ -151,7 +153,7 @@ eventMapping.from(Controller.Standard.RS).peek().to(restoreAnimation); eventMapping.from(Controller.Standard.RightGrip).peek().to(restoreAnimation); eventMapping.from(Controller.Standard.Back).peek().to(restoreAnimation); eventMapping.from(Controller.Standard.Start).peek().to(restoreAnimation); -Controller.enableMapping(eventMappingName); + button.clicked.connect(onClicked); tablet.screenChanged.connect(onScreenChanged); From e74d30ce22788b41fdb802543cd01d576a0620a8 Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 27 Jun 2018 17:43:41 -0700 Subject: [PATCH 07/29] fix color fallbacks --- scripts/system/particle_explorer/particleExplorerTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index 0de86fbf2f..b675d26ff6 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -108,7 +108,7 @@ ParticleExplorerTool = function() { var fallbackValue = updatedSettings[fallbackProp]; if (fallbackValue) { var optionalProp = optionalProps[i]; - if (isNaN(entityProps[optionalProp]) || (fallbackProp === "color" && isNaN(entityProps[optionalProp].red))) { + if ((fallbackProp !== "color" && isNaN(entityProps[optionalProp])) || (fallbackProp === "color" && isNaN(entityProps[optionalProp].red))) { that.updatedActiveParticleProperties[optionalProp] = fallbackValue; needsUpdate = true; } From 4f5a1bc340c5605bbe4dd02f51c14e03f419a6f5 Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 27 Jun 2018 19:02:55 -0700 Subject: [PATCH 08/29] zero out spread values for previous versions --- libraries/entities/src/EntityTree.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index a58f01a83b..87fcdc4f4d 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -2521,6 +2521,13 @@ bool EntityTree::readFromMap(QVariantMap& map) { } } + // Zero out the spread values that were fixed in version ParticleEntityFix so they behave the same as before + if (contentVersion < (int)EntityVersion::ParticleEntityFix) { + properties.setRadiusSpread(0.f); + properties.setAlphaSpread(0.f); + properties.setColorSpread({0, 0, 0}); + } + EntityItemPointer entity = addEntity(entityItemID, properties); if (!entity) { qCDebug(entities) << "adding Entity failed:" << entityItemID << properties.getType(); From a8e231c5afad7e4a3a2ffcdef9022de6e53299de Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 28 Jun 2018 11:33:38 -0700 Subject: [PATCH 09/29] floats .0f --- libraries/entities/src/EntityTree.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 87fcdc4f4d..0315ba7186 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -2523,8 +2523,8 @@ bool EntityTree::readFromMap(QVariantMap& map) { // Zero out the spread values that were fixed in version ParticleEntityFix so they behave the same as before if (contentVersion < (int)EntityVersion::ParticleEntityFix) { - properties.setRadiusSpread(0.f); - properties.setAlphaSpread(0.f); + properties.setRadiusSpread(0.0f); + properties.setAlphaSpread(0.0f); properties.setColorSpread({0, 0, 0}); } From d543cd07668dc543ebd4e6ec1b7bb48bd201f74f Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 29 Jun 2018 15:42:19 +0200 Subject: [PATCH 10/29] Fixing a bug if the last session display pluginis an invalid name, resolve to default --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a60d72073c..9c262c1980 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2719,7 +2719,7 @@ void Application::initializeDisplayPlugins() { setDisplayPlugin(defaultDisplayPlugin); // Now set the desired plugin if it's not the same as the default plugin - if (targetDisplayPlugin != defaultDisplayPlugin) { + if (!targetDisplayPlugin && (targetDisplayPlugin != defaultDisplayPlugin)) { setDisplayPlugin(targetDisplayPlugin); } From de831ffea970df0981067bd075f10f2e042362e3 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Fri, 29 Jun 2018 16:55:33 +0200 Subject: [PATCH 11/29] Switched shadow maps to sampler2DArrayShadow to try to fix on Mac --- .../src/gpu/gl/GLBackendPipeline.cpp | 5 ++-- .../gpu-gl-common/src/gpu/gl/GLTexture.cpp | 16 ++++++++++--- .../gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp | 14 +++++++++-- .../src/gpu/gl41/GL41BackendTexture.cpp | 9 +++++++- .../gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp | 14 ++++++++--- .../src/gpu/gl45/GL45BackendTexture.cpp | 7 +++++- libraries/gpu/src/gpu/Texture.cpp | 8 +++++++ libraries/gpu/src/gpu/Texture.h | 2 ++ libraries/gpu/src/gpu/Texture_ktx.cpp | 2 +- libraries/ktx/src/ktx/KTX.h | 1 + .../render-utils/src/DebugDeferredBuffer.cpp | 13 +++++++---- .../src/DeferredLightingEffect.cpp | 6 ++--- libraries/render-utils/src/LightStage.cpp | 23 +++++++++++++++++-- libraries/render-utils/src/LightStage.h | 3 ++- libraries/render-utils/src/Shadow.slh | 4 ++-- 15 files changed, 101 insertions(+), 26 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp index 91f1d8bb8c..b75f89f7ae 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp @@ -203,10 +203,11 @@ void GLBackend::releaseResourceTexture(uint32_t slot) { } void GLBackend::resetResourceStage() { - for (uint32_t i = 0; i < _resource._buffers.size(); i++) { + uint32_t i; + for (i = 0; i < _resource._buffers.size(); i++) { releaseResourceBuffer(i); } - for (uint32_t i = 0; i < _resource._textures.size(); i++) { + for (i = 0; i < _resource._textures.size(); i++) { releaseResourceTexture(i); } } diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLTexture.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLTexture.cpp index e11f8f01c7..e9494a1271 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLTexture.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLTexture.cpp @@ -59,7 +59,11 @@ const size_t GLVariableAllocationSupport::MAX_BUFFER_SIZE = MAX_TRANSFER_SIZE; GLenum GLTexture::getGLTextureType(const Texture& texture) { switch (texture.getType()) { case Texture::TEX_2D: - return GL_TEXTURE_2D; + if (!texture.isArray()) { + return GL_TEXTURE_2D; + } else { + return GL_TEXTURE_2D_ARRAY; + } break; case Texture::TEX_CUBE: @@ -77,6 +81,7 @@ GLenum GLTexture::getGLTextureType(const Texture& texture) { uint8_t GLTexture::getFaceCount(GLenum target) { switch (target) { case GL_TEXTURE_2D: + case GL_TEXTURE_2D_ARRAY: return TEXTURE_2D_NUM_FACES; case GL_TEXTURE_CUBE_MAP: return TEXTURE_CUBE_NUM_FACES; @@ -86,17 +91,22 @@ uint8_t GLTexture::getFaceCount(GLenum target) { } } const std::vector& GLTexture::getFaceTargets(GLenum target) { - static std::vector cubeFaceTargets { + static const std::vector cubeFaceTargets { GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z }; - static std::vector faceTargets { + static const std::vector faceTargets { GL_TEXTURE_2D }; + static const std::vector arrayFaceTargets{ + GL_TEXTURE_2D_ARRAY + }; switch (target) { case GL_TEXTURE_2D: return faceTargets; + case GL_TEXTURE_2D_ARRAY: + return arrayFaceTargets; case GL_TEXTURE_CUBE_MAP: return cubeFaceTargets; default: diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp index a5ef2d92e1..1d512103bd 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendOutput.cpp @@ -64,7 +64,12 @@ public: } if (gltexture) { - glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0); + } else { + glFramebufferTextureLayer(GL_FRAMEBUFFER, colorAttachments[unit], gltexture->_texture, 0, + b._subresource); + } _colorBuffers.push_back(colorAttachments[unit]); } else { glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, 0, 0); @@ -91,7 +96,12 @@ public: } if (gltexture) { - glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, gltexture->_texture, 0); + } else { + glFramebufferTextureLayer(GL_FRAMEBUFFER, attachement, gltexture->_texture, 0, + _gpuObject.getDepthStencilBufferSubresource()); + } } else { glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, 0, 0); } diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp index a255cc5878..ce9735b37e 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp @@ -215,12 +215,19 @@ GL41FixedAllocationTexture::~GL41FixedAllocationTexture() { void GL41FixedAllocationTexture::allocateStorage() const { const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat()); const auto numMips = _gpuObject.getNumMips(); + const auto numSlices = _gpuObject.getNumSlices(); // glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); for (GLint level = 0; level < numMips; level++) { Vec3u dimensions = _gpuObject.evalMipDimensions(level); for (GLenum target : getFaceTargets(_target)) { - glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format, texelFormat.type, nullptr); + if (!_gpuObject.isArray()) { + glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format, + texelFormat.type, nullptr); + } else { + glTexImage3D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, 0, + texelFormat.format, texelFormat.type, nullptr); + } } } diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp index ca53d6c624..86332558e3 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendOutput.cpp @@ -60,7 +60,11 @@ public: } if (gltexture) { - glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glNamedFramebufferTexture(_id, colorAttachments[unit], gltexture->_texture, 0); + } else { + glNamedFramebufferTextureLayer(_id, colorAttachments[unit], gltexture->_texture, 0, b._subresource); + } _colorBuffers.push_back(colorAttachments[unit]); } else { glNamedFramebufferTexture(_id, colorAttachments[unit], 0, 0); @@ -87,14 +91,18 @@ public: } if (gltexture) { - glNamedFramebufferTexture(_id, attachement, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glNamedFramebufferTexture(_id, attachement, gltexture->_texture, 0); + } else { + glNamedFramebufferTextureLayer(_id, attachement, gltexture->_texture, 0, + _gpuObject.getDepthStencilBufferSubresource()); + } } else { glNamedFramebufferTexture(_id, attachement, 0, 0); } _depthStamp = _gpuObject.getDepthStamp(); } - // Last but not least, define where we draw if (!_colorBuffers.empty()) { glNamedFramebufferDrawBuffers(_id, (GLsizei)_colorBuffers.size(), _colorBuffers.data()); diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index fda7ac22dd..a00159a7ce 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -374,8 +374,13 @@ void GL45FixedAllocationTexture::allocateStorage() const { const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat()); const auto dimensions = _gpuObject.getDimensions(); const auto mips = _gpuObject.getNumMips(); + const auto numSlices = _gpuObject.getNumSlices(); - glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); + if (!_gpuObject.isArray()) { + glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); + } else { + glTextureStorage3D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices); + } glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, 0); glTextureParameteri(_id, GL_TEXTURE_MAX_LEVEL, mips - 1); diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index a92243f808..34262b0cd9 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -184,6 +184,10 @@ TexturePointer Texture::createRenderBuffer(const Element& texelFormat, uint16 wi return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, 1, 0, numMips, sampler); } +TexturePointer Texture::createRenderBufferArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips, const Sampler& sampler) { + return create(TextureUsageType::RENDERBUFFER, TEX_2D, texelFormat, width, height, 1, 1, numSlices, numMips, sampler); +} + TexturePointer Texture::create1D(const Element& texelFormat, uint16 width, uint16 numMips, const Sampler& sampler) { return create(TextureUsageType::RESOURCE, TEX_1D, texelFormat, width, 1, 1, 1, 0, numMips, sampler); } @@ -192,6 +196,10 @@ TexturePointer Texture::create2D(const Element& texelFormat, uint16 width, uint1 return create(TextureUsageType::RESOURCE, TEX_2D, texelFormat, width, height, 1, 1, 0, numMips, sampler); } +TexturePointer Texture::create2DArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips, const Sampler& sampler) { + return create(TextureUsageType::STRICT_RESOURCE, TEX_2D, texelFormat, width, height, 1, 1, numSlices, numMips, sampler); +} + TexturePointer Texture::createStrict(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips, const Sampler& sampler) { return create(TextureUsageType::STRICT_RESOURCE, TEX_2D, texelFormat, width, height, 1, 1, 0, numMips, sampler); } diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 09b2bc9475..9ad5dc0816 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -374,9 +374,11 @@ public: static const uint16 SINGLE_MIP = 1; static TexturePointer create1D(const Element& texelFormat, uint16 width, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer create2D(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); + static TexturePointer create2DArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer create3D(const Element& texelFormat, uint16 width, uint16 height, uint16 depth, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer createCube(const Element& texelFormat, uint16 width, uint16 numMips = 1, const Sampler& sampler = Sampler()); static TexturePointer createRenderBuffer(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); + static TexturePointer createRenderBufferArray(const Element& texelFormat, uint16 width, uint16 height, uint16 numSlices, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer createStrict(const Element& texelFormat, uint16 width, uint16 height, uint16 numMips = SINGLE_MIP, const Sampler& sampler = Sampler()); static TexturePointer createExternal(const ExternalRecycler& recycler, const Sampler& sampler = Sampler()); diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 0d4abe78d3..1b7b552078 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -515,7 +515,7 @@ TexturePointer Texture::build(const ktx::KTXDescriptor& descriptor) { header.getPixelHeight(), header.getPixelDepth(), 1, // num Samples - header.getNumberOfSlices(), + header.isArray() ? header.getNumberOfSlices() : 0, header.getNumberOfLevels(), samplerDesc); texture->setUsage(gpuktxKeyValue._usage); diff --git a/libraries/ktx/src/ktx/KTX.h b/libraries/ktx/src/ktx/KTX.h index 54a8188a42..d755a482e3 100644 --- a/libraries/ktx/src/ktx/KTX.h +++ b/libraries/ktx/src/ktx/KTX.h @@ -163,6 +163,7 @@ namespace ktx { uint32_t getPixelDepth() const { return (pixelDepth ? pixelDepth : 1); } uint32_t getNumberOfSlices() const { return (numberOfArrayElements ? numberOfArrayElements : 1); } uint32_t getNumberOfLevels() const { return (numberOfMipmapLevels ? numberOfMipmapLevels : 1); } + bool isArray() const { return numberOfArrayElements > 0; } bool isCompressed() const { return glFormat == COMPRESSED_FORMAT; } uint32_t evalMaxDimension() const; diff --git a/libraries/render-utils/src/DebugDeferredBuffer.cpp b/libraries/render-utils/src/DebugDeferredBuffer.cpp index c17044be6d..7728c1406c 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.cpp +++ b/libraries/render-utils/src/DebugDeferredBuffer.cpp @@ -140,11 +140,12 @@ static const std::string DEFAULT_LIGHTING_SHADER { }; static const std::string DEFAULT_SHADOW_SHADER{ - "uniform sampler2DShadow shadowMap;" + "uniform sampler2DArrayShadow shadowMaps;" + "uniform int shadowCascadeIndex;" "vec4 getFragmentColor() {" " for (int i = 255; i >= 0; --i) {" " float depth = i / 255.0;" - " if (texture(shadowMap, vec3(uv, depth)) > 0.5) {" + " if (texture(shadowMaps, vec4(uv, shadowCascadeIndex, depth)) > 0.5) {" " return vec4(vec3(depth), 1.0);" " }" " }" @@ -403,7 +404,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str slotBindings.insert(gpu::Shader::Binding("depthMap", Depth)); slotBindings.insert(gpu::Shader::Binding("obscuranceMap", AmbientOcclusion)); slotBindings.insert(gpu::Shader::Binding("lightingMap", Lighting)); - slotBindings.insert(gpu::Shader::Binding("shadowMap", Shadow)); + slotBindings.insert(gpu::Shader::Binding("shadowMaps", Shadow)); slotBindings.insert(gpu::Shader::Binding("linearDepthMap", LinearDepth)); slotBindings.insert(gpu::Shader::Binding("halfLinearDepthMap", HalfLinearDepth)); slotBindings.insert(gpu::Shader::Binding("halfNormalMap", HalfNormal)); @@ -490,7 +491,11 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I const auto& globalShadow = lightAndShadow.second; if (globalShadow) { const auto cascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)globalShadow->getCascadeCount() - 1); - batch.setResourceTexture(Shadow, globalShadow->getCascade(cascadeIndex).map); + const auto cascadeIndexLocation = pipeline->getProgram()->getUniforms().findLocation("shadowCascadeIndex"); + batch.setResourceTexture(Shadow, globalShadow->map); + if (cascadeIndexLocation >= 0) { + batch._glUniform1i(cascadeIndexLocation, cascadeIndex); + } batch.setUniformBuffer(ShadowTransform, globalShadow->getBuffer()); batch.setUniformBuffer(DeferredFrameTransform, frameTransform->getFrameTransformBuffer()); } diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 9223e0fa03..452e5b5ccd 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -68,7 +68,7 @@ enum DeferredShader_MapSlot { SCATTERING_SPECULAR_UNIT = 9, SKYBOX_MAP_UNIT = render::ShapePipeline::Slot::LIGHT_AMBIENT_MAP, // unit = 10 SHADOW_MAP_UNIT = 11, - nextAvailableUnit = SHADOW_MAP_UNIT + SHADOW_CASCADE_MAX_COUNT + nextAvailableUnit = SHADOW_MAP_UNIT }; enum DeferredShader_BufferSlot { DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT = 0, @@ -534,9 +534,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, // Bind the shadow buffers if (globalShadow) { - for (unsigned int i = 0; i < globalShadow->getCascadeCount(); i++) { - batch.setResourceTexture(SHADOW_MAP_UNIT+i, globalShadow->getCascade(i).map); - } + batch.setResourceTexture(SHADOW_MAP_UNIT, globalShadow->map); } auto program = deferredLightingEffect->_directionalSkyboxLight; diff --git a/libraries/render-utils/src/LightStage.cpp b/libraries/render-utils/src/LightStage.cpp index ceac4ae3c8..369c62c197 100644 --- a/libraries/render-utils/src/LightStage.cpp +++ b/libraries/render-utils/src/LightStage.cpp @@ -74,8 +74,6 @@ LightStage::Shadow::Cascade::Cascade() : _frustum{ std::make_shared() }, _minDistance{ 0.0f }, _maxDistance{ 20.0f } { - framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::createShadowmap(MAP_SIZE)); - map = framebuffer->getDepthStencilBuffer(); } const glm::mat4& LightStage::Shadow::Cascade::getView() const { @@ -127,8 +125,29 @@ LightStage::Shadow::Shadow(graphics::LightPointer light, float maxDistance, unsi Schema schema; schema.cascadeCount = cascadeCount; _schemaBuffer = std::make_shared(sizeof(Schema), (const gpu::Byte*) &schema); + + // Create shadow cascade texture array + auto depthFormat = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH); // Depth32 texel format + map = gpu::TexturePointer(gpu::Texture::createRenderBufferArray(depthFormat, MAP_SIZE, MAP_SIZE, cascadeCount)); + gpu::Sampler::Desc samplerDesc; + samplerDesc._borderColor = glm::vec4(1.0f); + samplerDesc._wrapModeU = gpu::Sampler::WRAP_BORDER; + samplerDesc._wrapModeV = gpu::Sampler::WRAP_BORDER; + samplerDesc._filter = gpu::Sampler::FILTER_MIN_MAG_LINEAR; + samplerDesc._comparisonFunc = gpu::LESS; + + map->setSampler(gpu::Sampler(samplerDesc)); + _cascades.resize(cascadeCount); + for (uint cascadeIndex=0; cascadeIndex < cascadeCount; cascadeIndex++) { + auto& cascade = _cascades[cascadeIndex]; + std::string name = "Shadowmap Cascade "; + name += '0' + cascadeIndex; + cascade.framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create(name)); + cascade.framebuffer->setDepthBuffer(map, depthFormat, cascadeIndex); + } + setMaxDistance(maxDistance); } diff --git a/libraries/render-utils/src/LightStage.h b/libraries/render-utils/src/LightStage.h index 9812426fa6..b8a49d81bb 100644 --- a/libraries/render-utils/src/LightStage.h +++ b/libraries/render-utils/src/LightStage.h @@ -53,7 +53,6 @@ public: Cascade(); gpu::FramebufferPointer framebuffer; - gpu::TexturePointer map; const std::shared_ptr& getFrustum() const { return _frustum; } @@ -93,6 +92,8 @@ public: const graphics::LightPointer& getLight() const { return _light; } + gpu::TexturePointer map; + protected: #include "Shadows_shared.slh" diff --git a/libraries/render-utils/src/Shadow.slh b/libraries/render-utils/src/Shadow.slh index 36eb35c757..235ea519ab 100644 --- a/libraries/render-utils/src/Shadow.slh +++ b/libraries/render-utils/src/Shadow.slh @@ -17,11 +17,11 @@ #define SHADOW_SCREEN_SPACE_DITHER 1 // the shadow texture -uniform sampler2DShadow shadowMaps[SHADOW_CASCADE_MAX_COUNT]; +uniform sampler2DArrayShadow shadowMaps; // Sample the shadowMap with PCF (built-in) float fetchShadow(int cascadeIndex, vec3 shadowTexcoord) { - return texture(shadowMaps[cascadeIndex], shadowTexcoord); + return texture(shadowMaps, vec4(shadowTexcoord.xy, cascadeIndex, shadowTexcoord.z)); } vec2 PCFkernel[4] = vec2[4]( From 9dc03f50133a104b3f7c553737e54f1098dca372 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 29 Jun 2018 10:39:16 -0700 Subject: [PATCH 12/29] Destroy GeometryCache explicitly in Application destructor --- interface/src/Application.cpp | 1 + interface/src/ui/ApplicationOverlay.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4b32783607..63fff2af5b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2565,6 +2565,7 @@ Application::~Application() { DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); + DependencyManager::destroy(); DependencyManager::get()->cleanup(); diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 7db6a49d1c..ea660fb0e2 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -50,8 +50,6 @@ ApplicationOverlay::~ApplicationOverlay() { geometryCache->releaseID(_magnifierBorder); geometryCache->releaseID(_qmlGeometryId); } - - DependencyManager::destroy(); } // Renders the overlays either to a texture or to the screen From e4377a6c95b6cd99fb56116f0768d23e7c901b3a Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Fri, 29 Jun 2018 10:55:01 -0700 Subject: [PATCH 13/29] Prevent type conversion in ~ResourceManager constant --- libraries/networking/src/ResourceManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/ResourceManager.cpp b/libraries/networking/src/ResourceManager.cpp index 46cf43b97d..553f0d0a61 100644 --- a/libraries/networking/src/ResourceManager.cpp +++ b/libraries/networking/src/ResourceManager.cpp @@ -41,7 +41,7 @@ ResourceManager::ResourceManager(bool atpSupportEnabled) : _atpSupportEnabled(at ResourceManager::~ResourceManager() { if (_thread.isRunning()) { _thread.quit(); - static const auto MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME = 0.5 * MSECS_PER_SECOND; + static const auto MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME = MSECS_PER_SECOND / 2; if (!_thread.wait(MAX_RESOURCE_MANAGER_THREAD_QUITTING_TIME)) { _thread.terminate(); } From 9e3626cca31432e596586b737ea3d949e4e678a7 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Jun 2018 14:42:33 -0700 Subject: [PATCH 14/29] returning false if there is no entity to connect to --- libraries/entities/src/EntityScriptingInterface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 378ce541d7..09d9823728 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -1269,6 +1269,8 @@ bool EntityScriptingInterface::appendPoint(QUuid entityID, const glm::vec3& poin EntityItemPointer entity = static_cast(_entityTree->findEntityByEntityItemID(entityID)); if (!entity) { qCDebug(entities) << "EntityScriptingInterface::setPoints no entity with ID" << entityID; + // There is no entity + return false; } EntityTypes::EntityType entityType = entity->getType(); From 9b59dc5809f551edb6e321122304f25acc405180 Mon Sep 17 00:00:00 2001 From: r3tk0n Date: Fri, 29 Jun 2018 15:22:57 -0700 Subject: [PATCH 15/29] Changed SpinnerSliderPreference.qml to general-case UI element as originally intended, updated PreferencesDialog.cpp's Avatar Scale slider to hard-coded bounds [0.25, 4.0]. --- .../dialogs/preferences/SpinnerSliderPreference.qml | 8 ++++---- interface/src/ui/PreferencesDialog.cpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml b/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml index 731acc7e5b..126e62fc30 100644 --- a/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml +++ b/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml @@ -56,8 +56,8 @@ Preference { id: slider value: preference.value width: 100 - minimumValue: MyAvatar.getDomainMinScale() - maximumValue: MyAvatar.getDomainMaxScale() + minimumValue: preference.min + maximumValue: preference.max stepSize: preference.step onValueChanged: { spinner.realValue = value @@ -74,8 +74,8 @@ Preference { id: spinner decimals: preference.decimals realValue: preference.value - minimumValue: MyAvatar.getDomainMinScale() - maximumValue: MyAvatar.getDomainMaxScale() + minimumValue: preference.min + maximumValue: preference.max width: 100 onValueChanged: { slider.value = realValue; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 3d3c432e92..983dbe44ec 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -233,6 +233,8 @@ void setupPreferences() { auto getter = [=]()->float { return myAvatar->getTargetScale(); }; auto setter = [=](float value) { myAvatar->setTargetScale(value); }; auto preference = new SpinnerSliderPreference(AVATAR_TUNING, "Avatar Scale", getter, setter); + preference->setMin(0.25); + preference->setMax(4); preference->setStep(0.05f); preference->setDecimals(2); preferences->addPreference(preference); @@ -286,6 +288,7 @@ void setupPreferences() { preferences->addPreference(new CheckPreference(MOVEMENT, "Flying & jumping", getter, setter)); } { + auto getter = [=]()->int { return myAvatar->getSnapTurn() ? 0 : 1; }; auto setter = [=](int value) { myAvatar->setSnapTurn(value == 0); }; auto preference = new RadioButtonsPreference(MOVEMENT, "Snap turn / Smooth turn", getter, setter); @@ -309,17 +312,21 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getPitchSpeed(); }; auto setter = [=](float value) { myAvatar->setPitchSpeed(value); }; - auto preference = new SpinnerPreference(AVATAR_CAMERA, "Pitch speed (degrees/second)", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Pitch speed (degrees/second)", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); + preference->setStep(1); + preference->setDecimals(1); preferences->addPreference(preference); } { auto getter = [=]()->float { return myAvatar->getYawSpeed(); }; auto setter = [=](float value) { myAvatar->setYawSpeed(value); }; - auto preference = new SpinnerPreference(AVATAR_CAMERA, "Yaw speed (degrees/second)", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Yaw speed (degrees/second)", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); + preference->setStep(1); + preference->setDecimals(1); preferences->addPreference(preference); } From fd4a8fdd833fea9e31a2ec39b28496a2290c7c32 Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 29 Jun 2018 15:33:55 -0700 Subject: [PATCH 16/29] fix color NaN check --- scripts/system/particle_explorer/particleExplorerTool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index b675d26ff6..80256a12e3 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -64,10 +64,10 @@ ParticleExplorerTool = function() { if (isNaN(properties.radiusFinish)) { properties.radiusFinish = properties.particleRadius; } - if (isNaN(properties.colorStart) || isNaN(properties.colorStart.red)) { + if (isNaN(properties.colorStart.red)) { properties.colorStart = properties.color; } - if (isNaN(properties.colorFinish) || isNaN(properties.colorFinish.red)) { + if (isNaN(properties.colorFinish.red)) { properties.colorFinish = properties.color; } sendParticleProperties(properties); From dce9cb0404f058a9431f06eae94c4d9da3a02df6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 28 Jun 2018 19:17:22 -0700 Subject: [PATCH 17/29] fix case where TCP Vegas would not re-send lost ACK --- libraries/networking/src/udt/Connection.cpp | 41 ++++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/libraries/networking/src/udt/Connection.cpp b/libraries/networking/src/udt/Connection.cpp index c1fe6ccd85..0bc86a28ad 100644 --- a/libraries/networking/src/udt/Connection.cpp +++ b/libraries/networking/src/udt/Connection.cpp @@ -239,7 +239,7 @@ void Connection::sync() { sendACK(); } - if (_lossList.getLength() > 0) { + if (_congestionControl->shouldNAK() && _lossList.getLength() > 0) { // check if we need to re-transmit a loss list // we do this if it has been longer than the current nakInterval since we last sent auto now = p_high_resolution_clock::now(); @@ -271,10 +271,13 @@ void Connection::sendACK(bool wasCausedBySyncTimeout) { SequenceNumber nextACKNumber = nextACK(); Q_ASSERT_X(nextACKNumber >= _lastSentACK, "Connection::sendACK", "Sending lower ACK, something is wrong"); - - if (nextACKNumber == _lastSentACK) { - // We already sent this ACK, but check if we should re-send it. - if (nextACKNumber < _lastReceivedAcknowledgedACK) { + + // if our congestion control doesn't want to send an ACK for every packet received + // check if we already sent this ACK + if (_congestionControl->_ackInterval > 1 && nextACKNumber == _lastSentACK) { + + // if we use ACK2s, check if the receiving side already confirmed receipt of this ACK + if (_congestionControl->shouldACK2() && nextACKNumber < _lastReceivedAcknowledgedACK) { // we already got an ACK2 for this ACK we would be sending, don't bother return; } @@ -287,11 +290,11 @@ void Connection::sendACK(bool wasCausedBySyncTimeout) { } } // we have received new packets since the last sent ACK + // or our congestion control dictates that we always send ACKs // update the last sent ACK _lastSentACK = nextACKNumber; - _ackPacket->reset(); // We need to reset it every time. // pack in the ACK sub-sequence number @@ -448,20 +451,22 @@ bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, in // mark our last receive time as now (to push the potential expiry farther) _lastReceiveTime = p_high_resolution_clock::now(); - - // check if this is a packet pair we should estimate bandwidth from, or just a regular packet - if (((uint32_t) sequenceNumber & 0xF) == 0) { - _receiveWindow.onProbePair1Arrival(); - } else if (((uint32_t) sequenceNumber & 0xF) == 1) { - // only use this packet for bandwidth estimation if we didn't just receive a control packet in its place - if (!_receivedControlProbeTail) { - _receiveWindow.onProbePair2Arrival(); - } else { - // reset our control probe tail marker so the next probe that comes with data can be used - _receivedControlProbeTail = false; + + if (_congestionControl->shouldProbe()) { + // check if this is a packet pair we should estimate bandwidth from, or just a regular packet + if (((uint32_t) sequenceNumber & 0xF) == 0) { + _receiveWindow.onProbePair1Arrival(); + } else if (((uint32_t) sequenceNumber & 0xF) == 1) { + // only use this packet for bandwidth estimation if we didn't just receive a control packet in its place + if (!_receivedControlProbeTail) { + _receiveWindow.onProbePair2Arrival(); + } else { + // reset our control probe tail marker so the next probe that comes with data can be used + _receivedControlProbeTail = false; + } } - } + _receiveWindow.onPacketArrival(); // If this is not the next sequence number, report loss From 5158a9c4fd35b1d0c374b6a7d13109f2baec842a Mon Sep 17 00:00:00 2001 From: r3tk0n <39922250+r3tk0n@users.noreply.github.com> Date: Fri, 29 Jun 2018 16:11:18 -0700 Subject: [PATCH 18/29] Update Mouse Sensitivity Settings Text Changed text for clarity to new users. --- interface/src/ui/PreferencesDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 983dbe44ec..eb65001561 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -312,7 +312,7 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getPitchSpeed(); }; auto setter = [=](float value) { myAvatar->setPitchSpeed(value); }; - auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Pitch speed (degrees/second)", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Y axis:", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); @@ -322,7 +322,7 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getYawSpeed(); }; auto setter = [=](float value) { myAvatar->setYawSpeed(value); }; - auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Yaw speed (degrees/second)", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "X axis: ", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); From 4feba7e66e058d1fe0de2e05d7e1e95b78b03485 Mon Sep 17 00:00:00 2001 From: r3tk0n <39922250+r3tk0n@users.noreply.github.com> Date: Fri, 29 Jun 2018 16:12:31 -0700 Subject: [PATCH 19/29] Correction of string literals Last update to string literals, miscommunication. --- interface/src/ui/PreferencesDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index eb65001561..deedc74619 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -312,7 +312,7 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getPitchSpeed(); }; auto setter = [=](float value) { myAvatar->setPitchSpeed(value); }; - auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Y axis:", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "Y input:", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); @@ -322,7 +322,7 @@ void setupPreferences() { { auto getter = [=]()->float { return myAvatar->getYawSpeed(); }; auto setter = [=](float value) { myAvatar->setYawSpeed(value); }; - auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "X axis: ", getter, setter); + auto preference = new SpinnerSliderPreference(AVATAR_CAMERA, "X input:", getter, setter); preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); From 2c32dc1cf52e817c33cd05ac9712fad5d9ab275d Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Jun 2018 16:13:02 -0700 Subject: [PATCH 20/29] adding enter key event for logging in in pw textfield --- .../resources/qml/LoginDialog/+android/LinkAccountBody.qml | 2 ++ interface/resources/qml/LoginDialog/LinkAccountBody.qml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml index 38e65af4ca..bf7807c85d 100644 --- a/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml @@ -135,6 +135,8 @@ Item { placeholderText: qsTr("Password") echoMode: TextInput.Password + + Keys.onReturnPressed: linkAccountBody.login() } } diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 6cbd1c4837..814778a4b1 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -177,6 +177,8 @@ Item { root.text = ""; root.isPassword = true; } + + Keys.onReturnPressed: linkAccountBody.login() } CheckBox { From 39f491d9d02e9e88d515c694d788599921d5f551 Mon Sep 17 00:00:00 2001 From: r3tk0n <39922250+r3tk0n@users.noreply.github.com> Date: Fri, 29 Jun 2018 16:17:15 -0700 Subject: [PATCH 21/29] Update PreferencesDialog.cpp Removing errant newline --- interface/src/ui/PreferencesDialog.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index deedc74619..af11d9c4c8 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -288,7 +288,6 @@ void setupPreferences() { preferences->addPreference(new CheckPreference(MOVEMENT, "Flying & jumping", getter, setter)); } { - auto getter = [=]()->int { return myAvatar->getSnapTurn() ? 0 : 1; }; auto setter = [=](int value) { myAvatar->setSnapTurn(value == 0); }; auto preference = new RadioButtonsPreference(MOVEMENT, "Snap turn / Smooth turn", getter, setter); From 99a64f31d794e67ee9636acaf75a7637f28d4186 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 29 Jun 2018 16:21:03 -0700 Subject: [PATCH 22/29] Adding Enter/Return for sign up dialog in pw field --- interface/resources/qml/LoginDialog/SignUpBody.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index 5eb99e0ece..bb30696e4c 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -164,6 +164,8 @@ Item { root.text = ""; root.isPassword = focus } + + Keys.onReturnPressed: signupBody.signup() } Row { From ba53e7add8feb39ab4922938eed0ff3f71972527 Mon Sep 17 00:00:00 2001 From: Clement Date: Fri, 29 Jun 2018 15:51:40 -0700 Subject: [PATCH 23/29] Fix ACs startup crash --- assignment-client/src/Agent.cpp | 3 +++ assignment-client/src/audio/AudioMixer.cpp | 7 ++++++- assignment-client/src/audio/AudioMixer.h | 3 +++ assignment-client/src/scripts/EntityScriptServer.cpp | 3 +++ libraries/plugins/src/plugins/PluginManager.cpp | 3 --- libraries/plugins/src/plugins/PluginManager.h | 5 ++++- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 42924a8487..73444d1198 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -64,6 +64,7 @@ Agent::Agent(ReceivedMessage& message) : DependencyManager::get()->setPacketSender(&_entityEditSender); DependencyManager::set(); + DependencyManager::set(); DependencyManager::registerInheritance(); @@ -833,6 +834,8 @@ void Agent::aboutToFinish() { DependencyManager::get()->cleanup(); + DependencyManager::destroy(); + // cleanup the AudioInjectorManager (and any still running injectors) DependencyManager::destroy(); diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 34eb138697..d56b22466e 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -65,7 +65,8 @@ AudioMixer::AudioMixer(ReceivedMessage& message) : // hash the available codecs (on the mixer) _availableCodecs.clear(); // Make sure struct is clean - auto codecPlugins = PluginManager::getInstance()->getCodecPlugins(); + auto pluginManager = DependencyManager::set(); + auto codecPlugins = pluginManager->getCodecPlugins(); std::for_each(codecPlugins.cbegin(), codecPlugins.cend(), [&](const CodecPluginPointer& codec) { _availableCodecs[codec->getName()] = codec; @@ -106,6 +107,10 @@ AudioMixer::AudioMixer(ReceivedMessage& message) : connect(nodeList.data(), &NodeList::nodeKilled, this, &AudioMixer::handleNodeKilled); } +void AudioMixer::aboutToFinish() { + DependencyManager::destroy(); +} + void AudioMixer::queueAudioPacket(QSharedPointer message, SharedNodePointer node) { if (message->getType() == PacketType::SilentAudioFrame) { _numSilentPackets++; diff --git a/assignment-client/src/audio/AudioMixer.h b/assignment-client/src/audio/AudioMixer.h index 8c47893aa3..f9eb18da6d 100644 --- a/assignment-client/src/audio/AudioMixer.h +++ b/assignment-client/src/audio/AudioMixer.h @@ -58,6 +58,9 @@ public: to.getPublicSocket() != from.getPublicSocket() && to.getLocalSocket() != from.getLocalSocket(); } + + virtual void aboutToFinish() override; + public slots: void run() override; void sendStatsPacket() override; diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index eea8e8b470..607ab28b20 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -58,6 +58,7 @@ EntityScriptServer::EntityScriptServer(ReceivedMessage& message) : ThreadedAssig DependencyManager::get()->setPacketSender(&_entityEditSender); DependencyManager::set(); + DependencyManager::set(); DependencyManager::registerInheritance(); @@ -572,6 +573,8 @@ void EntityScriptServer::aboutToFinish() { DependencyManager::get()->cleanup(); + DependencyManager::destroy(); + // cleanup the AudioInjectorManager (and any still running injectors) DependencyManager::destroy(); DependencyManager::destroy(); diff --git a/libraries/plugins/src/plugins/PluginManager.cpp b/libraries/plugins/src/plugins/PluginManager.cpp index 40b6ed820a..94ce16cf00 100644 --- a/libraries/plugins/src/plugins/PluginManager.cpp +++ b/libraries/plugins/src/plugins/PluginManager.cpp @@ -135,9 +135,6 @@ const LoaderList& getLoadedPlugins() { return loadedPlugins; } -PluginManager::PluginManager() { -} - const CodecPluginList& PluginManager::getCodecPlugins() { static CodecPluginList codecPlugins; static std::once_flag once; diff --git a/libraries/plugins/src/plugins/PluginManager.h b/libraries/plugins/src/plugins/PluginManager.h index 226ccc8060..65a4012aed 100644 --- a/libraries/plugins/src/plugins/PluginManager.h +++ b/libraries/plugins/src/plugins/PluginManager.h @@ -18,9 +18,10 @@ class PluginManager; using PluginManagerPointer = QSharedPointer; class PluginManager : public QObject, public Dependency { + SINGLETON_DEPENDENCY + public: static PluginManagerPointer getInstance(); - PluginManager(); const DisplayPluginList& getDisplayPlugins(); const InputPluginList& getInputPlugins(); @@ -45,6 +46,8 @@ public: void setInputPluginSettingsPersister(const InputPluginSettingsPersister& persister); private: + PluginManager() = default; + DisplayPluginProvider _displayPluginProvider { []()->DisplayPluginList { return {}; } }; InputPluginProvider _inputPluginProvider { []()->InputPluginList { return {}; } }; CodecPluginProvider _codecPluginProvider { []()->CodecPluginList { return {}; } }; From c1856a5e3637652c7aa87fd8e402e2200bedc243 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Jul 2018 10:46:53 +0200 Subject: [PATCH 24/29] Make shadows work with one cascade --- .../gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp | 4 ++-- .../gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp | 4 ++-- libraries/gpu/src/gpu/Framebuffer.cpp | 2 +- libraries/render-utils/src/RenderShadowTask.cpp | 16 ++++++++++------ libraries/render-utils/src/Shadow.slh | 14 ++++++++++++++ libraries/render-utils/src/Shadows_shared.slh | 2 +- libraries/render/src/render/CullTask.cpp | 5 ++++- 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp index a255cc5878..4be82f0158 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp @@ -182,7 +182,7 @@ void GL41Texture::syncSampler() const { glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, fm.magFilter); if (sampler.doComparison()) { - glTexParameteri(_target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(_target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glTexParameteri(_target, GL_TEXTURE_COMPARE_FUNC, COMPARISON_TO_GL[sampler.getComparisonFunction()]); } else { glTexParameteri(_target, GL_TEXTURE_COMPARE_MODE, GL_NONE); @@ -197,7 +197,7 @@ void GL41Texture::syncSampler() const { glTexParameterf(_target, GL_TEXTURE_MIN_LOD, (float)sampler.getMinMip()); glTexParameterf(_target, GL_TEXTURE_MAX_LOD, (sampler.getMaxMip() == Sampler::MAX_MIP_LEVEL ? 1000.f : sampler.getMaxMip())); - glTexParameterf(_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, sampler.getMaxAnisotropy()); + glTexParameterf(_target, GL_TEXTURE_MAX_ANISOTROPY, sampler.getMaxAnisotropy()); } using GL41FixedAllocationTexture = GL41Backend::GL41FixedAllocationTexture; diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index fda7ac22dd..7cc639da5e 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -152,7 +152,7 @@ public: glSamplerParameteri(result, GL_TEXTURE_MIN_FILTER, fm.minFilter); glSamplerParameteri(result, GL_TEXTURE_MAG_FILTER, fm.magFilter); if (sampler.doComparison()) { - glSamplerParameteri(result, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE_ARB); + glSamplerParameteri(result, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glSamplerParameteri(result, GL_TEXTURE_COMPARE_FUNC, COMPARISON_TO_GL[sampler.getComparisonFunction()]); } else { glSamplerParameteri(result, GL_TEXTURE_COMPARE_MODE, GL_NONE); @@ -341,7 +341,7 @@ void GL45Texture::syncSampler() const { glTextureParameteri(_id, GL_TEXTURE_MAG_FILTER, fm.magFilter); if (sampler.doComparison()) { - glTextureParameteri(_id, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE_ARB); + glTextureParameteri(_id, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glTextureParameteri(_id, GL_TEXTURE_COMPARE_FUNC, COMPARISON_TO_GL[sampler.getComparisonFunction()]); } else { glTextureParameteri(_id, GL_TEXTURE_COMPARE_MODE, GL_NONE); diff --git a/libraries/gpu/src/gpu/Framebuffer.cpp b/libraries/gpu/src/gpu/Framebuffer.cpp index 8bb9be4a76..7e7db1345c 100755 --- a/libraries/gpu/src/gpu/Framebuffer.cpp +++ b/libraries/gpu/src/gpu/Framebuffer.cpp @@ -61,7 +61,7 @@ Framebuffer* Framebuffer::createShadowmap(uint16 width) { samplerDesc._borderColor = glm::vec4(1.0f); samplerDesc._wrapModeU = Sampler::WRAP_BORDER; samplerDesc._wrapModeV = Sampler::WRAP_BORDER; - samplerDesc._filter = Sampler::FILTER_MIN_MAG_LINEAR; + samplerDesc._filter = Sampler::FILTER_MIN_MAG_POINT; samplerDesc._comparisonFunc = LESS; depthTexture->setSampler(Sampler(samplerDesc)); diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index fbb4bba263..91eb777199 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -227,7 +227,7 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende } const auto setupOutput = task.addJob("ShadowSetup"); - const auto queryResolution = setupOutput.getN(2); + const auto queryResolution = setupOutput.getN(1); // Fetch and cull the items from the scene static const auto shadowCasterReceiverFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered().withTagBits(tagBits, tagMask); @@ -248,10 +248,12 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende const auto sortedShapes = task.addJob("DepthSortShadow", sortedPipelines, true); render::Varying cascadeFrustums[SHADOW_CASCADE_MAX_COUNT] = { - ViewFrustumPointer(), - ViewFrustumPointer(), + ViewFrustumPointer() +#if SHADOW_CASCADE_MAX_COUNT>1 + ,ViewFrustumPointer(), ViewFrustumPointer(), ViewFrustumPointer() +#endif }; for (auto i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) { @@ -293,13 +295,15 @@ RenderShadowSetup::RenderShadowSetup() : void RenderShadowSetup::configure(const Config& configuration) { setConstantBias(0, configuration.constantBias0); - setConstantBias(1, configuration.constantBias1); - setConstantBias(2, configuration.constantBias2); - setConstantBias(3, configuration.constantBias3); setSlopeBias(0, configuration.slopeBias0); +#if SHADOW_CASCADE_MAX_COUNT>1 + setConstantBias(1, configuration.constantBias1); setSlopeBias(1, configuration.slopeBias1); + setConstantBias(2, configuration.constantBias2); setSlopeBias(2, configuration.slopeBias2); + setConstantBias(3, configuration.constantBias3); setSlopeBias(3, configuration.slopeBias3); +#endif } void RenderShadowSetup::setConstantBias(int cascadeIndex, float value) { diff --git a/libraries/render-utils/src/Shadow.slh b/libraries/render-utils/src/Shadow.slh index 36eb35c757..4a63e24082 100644 --- a/libraries/render-utils/src/Shadow.slh +++ b/libraries/render-utils/src/Shadow.slh @@ -17,11 +17,19 @@ #define SHADOW_SCREEN_SPACE_DITHER 1 // the shadow texture +#if SHADOW_CASCADE_MAX_COUNT>1 uniform sampler2DShadow shadowMaps[SHADOW_CASCADE_MAX_COUNT]; +#else +uniform sampler2DShadow shadowMaps; +#endif // Sample the shadowMap with PCF (built-in) float fetchShadow(int cascadeIndex, vec3 shadowTexcoord) { +#if SHADOW_CASCADE_MAX_COUNT>1 return texture(shadowMaps[cascadeIndex], shadowTexcoord); +#else + return texture(shadowMaps, shadowTexcoord); +#endif } vec2 PCFkernel[4] = vec2[4]( @@ -89,6 +97,7 @@ float evalShadowCascadeAttenuation(int cascadeIndex, ShadowSampleOffsets offsets float evalShadowAttenuation(vec3 worldLightDir, vec4 worldPosition, float viewDepth, vec3 worldNormal) { ShadowSampleOffsets offsets = evalShadowFilterOffsets(worldPosition); +#if 0 vec4 cascadeShadowCoords[2]; cascadeShadowCoords[0] = vec4(0); cascadeShadowCoords[1] = vec4(0); @@ -105,6 +114,11 @@ float evalShadowAttenuation(vec3 worldLightDir, vec4 worldPosition, float viewDe float attenuation = mix(cascadeAttenuations.x, cascadeAttenuations.y, cascadeMix); // Falloff to max distance return mix(1.0, attenuation, evalShadowFalloff(viewDepth)); +#else +vec4 shadowTexcoord = evalShadowTexcoord(0, worldPosition); +float attenuation = fetchShadow(0, shadowTexcoord.xyz); +return attenuation; +#endif } <@endif@> diff --git a/libraries/render-utils/src/Shadows_shared.slh b/libraries/render-utils/src/Shadows_shared.slh index bc8063e018..7dea11cd8b 100644 --- a/libraries/render-utils/src/Shadows_shared.slh +++ b/libraries/render-utils/src/Shadows_shared.slh @@ -5,7 +5,7 @@ # define MAT4 mat4 #endif -#define SHADOW_CASCADE_MAX_COUNT 4 +#define SHADOW_CASCADE_MAX_COUNT 1 struct ShadowTransform { MAT4 reprojection; diff --git a/libraries/render/src/render/CullTask.cpp b/libraries/render/src/render/CullTask.cpp index 3f55e6dedc..8cfe7683ce 100644 --- a/libraries/render/src/render/CullTask.cpp +++ b/libraries/render/src/render/CullTask.cpp @@ -370,10 +370,13 @@ void CullShapeBounds::run(const RenderContextPointer& renderContext, const Input const auto& inShapes = inputs.get0(); const auto& cullFilter = inputs.get1(); const auto& boundsFilter = inputs.get2(); - const auto& antiFrustum = inputs.get3(); + ViewFrustumPointer antiFrustum; auto& outShapes = outputs.edit0(); auto& outBounds = outputs.edit1(); + if (!inputs[3].isNull()) { + antiFrustum = inputs.get3(); + } outShapes.clear(); outBounds = AABox(); From 1f90e86b87dd2fa9ce9ce117e1622ea5657b3c41 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Jul 2018 11:08:14 +0200 Subject: [PATCH 25/29] fix shader shadow bug on mac --- libraries/render-utils/src/Shadows_shared.slh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/Shadows_shared.slh b/libraries/render-utils/src/Shadows_shared.slh index 7dea11cd8b..bc8063e018 100644 --- a/libraries/render-utils/src/Shadows_shared.slh +++ b/libraries/render-utils/src/Shadows_shared.slh @@ -5,7 +5,7 @@ # define MAT4 mat4 #endif -#define SHADOW_CASCADE_MAX_COUNT 1 +#define SHADOW_CASCADE_MAX_COUNT 4 struct ShadowTransform { MAT4 reprojection; From 419e8e6eb9118b133ab546228d26465cbaa020b1 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Mon, 2 Jul 2018 11:32:33 +0200 Subject: [PATCH 26/29] Forgot to put back linear filtering on single shadow map --- libraries/gpu/src/gpu/Framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/gpu/src/gpu/Framebuffer.cpp b/libraries/gpu/src/gpu/Framebuffer.cpp index 7e7db1345c..8bb9be4a76 100755 --- a/libraries/gpu/src/gpu/Framebuffer.cpp +++ b/libraries/gpu/src/gpu/Framebuffer.cpp @@ -61,7 +61,7 @@ Framebuffer* Framebuffer::createShadowmap(uint16 width) { samplerDesc._borderColor = glm::vec4(1.0f); samplerDesc._wrapModeU = Sampler::WRAP_BORDER; samplerDesc._wrapModeV = Sampler::WRAP_BORDER; - samplerDesc._filter = Sampler::FILTER_MIN_MAG_POINT; + samplerDesc._filter = Sampler::FILTER_MIN_MAG_LINEAR; samplerDesc._comparisonFunc = LESS; depthTexture->setSampler(Sampler(samplerDesc)); From 1a5c382d88bdce3721c05211f0e799707eefaf1c Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Mon, 2 Jul 2018 12:41:24 +0200 Subject: [PATCH 27/29] Fixed on Android --- .../gpu-gles/src/gpu/gles/GLESBackendOutput.cpp | 14 ++++++++++++-- .../gpu-gles/src/gpu/gles/GLESBackendTexture.cpp | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackendOutput.cpp b/libraries/gpu-gles/src/gpu/gles/GLESBackendOutput.cpp index 0bf1548a4b..9c3a83ce13 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackendOutput.cpp +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackendOutput.cpp @@ -64,7 +64,12 @@ public: } if (gltexture) { - glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0); + } else { + glFramebufferTextureLayer(GL_FRAMEBUFFER, colorAttachments[unit], gltexture->_texture, 0, + b._subresource); + } _colorBuffers.push_back(colorAttachments[unit]); } else { glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, 0, 0); @@ -91,7 +96,12 @@ public: } if (gltexture) { - glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, gltexture->_texture, 0); + if (gltexture->_target == GL_TEXTURE_2D) { + glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, gltexture->_texture, 0); + } else { + glFramebufferTextureLayer(GL_FRAMEBUFFER, attachement, gltexture->_texture, 0, + _gpuObject.getDepthStencilBufferSubresource()); + } } else { glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, 0, 0); } diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp index bbc02c2af6..2e7faa1454 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp @@ -274,10 +274,20 @@ void GLESFixedAllocationTexture::allocateStorage() const { Vec3u dimensions = _gpuObject.evalMipDimensions(level); for (GLenum target : getFaceTargets(_target)) { if (texelFormat.isCompressed()) { - glCompressedTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, - getCompressedImageSize(dimensions.x, dimensions.y, texelFormat.internalFormat), nullptr); + auto size = getCompressedImageSize(dimensions.x, dimensions.y, texelFormat.internalFormat); + if (!_gpuObject.isArray()) { + glCompressedTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, size, nullptr); + } else { + glCompressedTexImage3D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, 0, size * numSlices, nullptr); + } } else { - glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format, texelFormat.type, nullptr); + if (!_gpuObject.isArray()) { + glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format, + texelFormat.type, nullptr); + } else { + glTexImage3D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, 0, + texelFormat.format, texelFormat.type, nullptr); + } } } } From 51fe60ec45dbb37303d7db86f4252d789e4f5bd0 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Mon, 2 Jul 2018 14:59:09 +0200 Subject: [PATCH 28/29] Fixed android compilation error and removed _glUniformi call --- .../src/gpu/gles/GLESBackendTexture.cpp | 1 + .../render-utils/src/DebugDeferredBuffer.cpp | 22 ++++++------- .../render-utils/src/DebugDeferredBuffer.h | 31 +++++++++++++------ .../src/debug_deferred_buffer.slf | 7 +++++ .../src/debug_deferred_buffer_shared.slh | 17 ++++++++++ 5 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 libraries/render-utils/src/debug_deferred_buffer_shared.slh diff --git a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp index 2e7faa1454..911dfb8bb8 100644 --- a/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp +++ b/libraries/gpu-gles/src/gpu/gles/GLESBackendTexture.cpp @@ -268,6 +268,7 @@ GLsizei getCompressedImageSize(int width, int height, GLenum internalFormat) { void GLESFixedAllocationTexture::allocateStorage() const { const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat()); const auto numMips = _gpuObject.getNumMips(); + const auto numSlices = _gpuObject.getNumSlices(); // glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); for (GLint level = 0; level < numMips; level++) { diff --git a/libraries/render-utils/src/DebugDeferredBuffer.cpp b/libraries/render-utils/src/DebugDeferredBuffer.cpp index 7728c1406c..8575df399e 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.cpp +++ b/libraries/render-utils/src/DebugDeferredBuffer.cpp @@ -60,7 +60,8 @@ enum TextureSlot { enum ParamSlot { CameraCorrection = 0, DeferredFrameTransform, - ShadowTransform + ShadowTransform, + DebugParametersBuffer }; static const std::string DEFAULT_ALBEDO_SHADER { @@ -139,13 +140,11 @@ static const std::string DEFAULT_LIGHTING_SHADER { " }" }; -static const std::string DEFAULT_SHADOW_SHADER{ - "uniform sampler2DArrayShadow shadowMaps;" - "uniform int shadowCascadeIndex;" +static const std::string DEFAULT_SHADOW_DEPTH_SHADER{ "vec4 getFragmentColor() {" " for (int i = 255; i >= 0; --i) {" " float depth = i / 255.0;" - " if (texture(shadowMaps, vec4(uv, shadowCascadeIndex, depth)) > 0.5) {" + " if (texture(shadowMaps, vec4(uv, parameters._shadowCascadeIndex, depth)) > 0.5) {" " return vec4(vec3(depth), 1.0);" " }" " }" @@ -324,7 +323,7 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string cust case ShadowCascade1Mode: case ShadowCascade2Mode: case ShadowCascade3Mode: - return DEFAULT_SHADOW_SHADER; + return DEFAULT_SHADOW_DEPTH_SHADER; case ShadowCascadeIndicesMode: return DEFAULT_SHADOW_CASCADE_SHADER; case LinearDepthMode: @@ -397,6 +396,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str slotBindings.insert(gpu::Shader::Binding("cameraCorrectionBuffer", CameraCorrection)); slotBindings.insert(gpu::Shader::Binding("deferredFrameTransformBuffer", DeferredFrameTransform)); slotBindings.insert(gpu::Shader::Binding("shadowTransformBuffer", ShadowTransform)); + slotBindings.insert(gpu::Shader::Binding("parametersBuffer", DebugParametersBuffer)); slotBindings.insert(gpu::Shader::Binding("albedoMap", Albedo)); slotBindings.insert(gpu::Shader::Binding("normalMap", Normal)); @@ -433,8 +433,11 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str } void DebugDeferredBuffer::configure(const Config& config) { + auto& parameters = _parameters.edit(); + _mode = (Mode)config.mode; _size = config.size; + parameters._shadowCascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)SHADOW_CASCADE_MAX_COUNT - 1); } void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const Inputs& inputs) { @@ -484,18 +487,15 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I batch.setResourceTexture(Velocity, velocityFramebuffer->getVelocityTexture()); } + batch.setUniformBuffer(DebugParametersBuffer, _parameters); + auto lightStage = renderContext->_scene->getStage(); assert(lightStage); assert(lightStage->getNumLights() > 0); auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow(); const auto& globalShadow = lightAndShadow.second; if (globalShadow) { - const auto cascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)globalShadow->getCascadeCount() - 1); - const auto cascadeIndexLocation = pipeline->getProgram()->getUniforms().findLocation("shadowCascadeIndex"); batch.setResourceTexture(Shadow, globalShadow->map); - if (cascadeIndexLocation >= 0) { - batch._glUniform1i(cascadeIndexLocation, cascadeIndex); - } batch.setUniformBuffer(ShadowTransform, globalShadow->getBuffer()); batch.setUniformBuffer(DeferredFrameTransform, frameTransform->getFrameTransformBuffer()); } diff --git a/libraries/render-utils/src/DebugDeferredBuffer.h b/libraries/render-utils/src/DebugDeferredBuffer.h index 5384a77b76..9daa8fd530 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.h +++ b/libraries/render-utils/src/DebugDeferredBuffer.h @@ -30,7 +30,7 @@ public: DebugDeferredBufferConfig() : render::Job::Config(false) {} void setMode(int newMode); - + int mode{ 0 }; glm::vec4 size{ 0.0f, -1.0f, 1.0f, 1.0f }; signals: @@ -39,20 +39,26 @@ signals: class DebugDeferredBuffer { public: - using Inputs = render::VaryingSet6; + using Inputs = render::VaryingSet6; using Config = DebugDeferredBufferConfig; using JobModel = render::Job::ModelI; - + DebugDeferredBuffer(); ~DebugDeferredBuffer(); void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, const Inputs& inputs); - + protected: friend class DebugDeferredBufferConfig; - enum Mode : uint8_t { + enum Mode : uint8_t + { // Use Mode suffix to avoid collisions Off = 0, DepthMode, @@ -83,7 +89,7 @@ protected: AmbientOcclusionMode, AmbientOcclusionBlurredMode, VelocityMode, - CustomMode, // Needs to stay last + CustomMode, // Needs to stay last NumModes, }; @@ -92,20 +98,25 @@ private: Mode _mode{ Off }; glm::vec4 _size; +#include "debug_deferred_buffer_shared.slh" + + using ParametersBuffer = gpu::StructBuffer; + struct CustomPipeline { gpu::PipelinePointer pipeline; mutable QFileInfo info; }; using StandardPipelines = std::array; using CustomPipelines = std::unordered_map; - + bool pipelineNeedsUpdate(Mode mode, std::string customFile = std::string()) const; const gpu::PipelinePointer& getPipeline(Mode mode, std::string customFile = std::string()); std::string getShaderSourceCode(Mode mode, std::string customFile = std::string()); - + + ParametersBuffer _parameters; StandardPipelines _pipelines; CustomPipelines _customPipelines; - int _geometryId { 0 }; + int _geometryId{ 0 }; }; -#endif // hifi_DebugDeferredBuffer_h \ No newline at end of file +#endif // hifi_DebugDeferredBuffer_h \ No newline at end of file diff --git a/libraries/render-utils/src/debug_deferred_buffer.slf b/libraries/render-utils/src/debug_deferred_buffer.slf index fded04ca87..5f974acfeb 100644 --- a/libraries/render-utils/src/debug_deferred_buffer.slf +++ b/libraries/render-utils/src/debug_deferred_buffer.slf @@ -23,11 +23,18 @@ uniform sampler2D occlusionMap; uniform sampler2D occlusionBlurredMap; uniform sampler2D scatteringMap; uniform sampler2D velocityMap; +uniform sampler2DArrayShadow shadowMaps; <@include ShadowCore.slh@> <$declareDeferredCurvature()$> +<@include debug_deferred_buffer_shared.slh@> + +layout(std140) uniform parametersBuffer { + DebugParameters parameters; +}; + float curvatureAO(float k) { return 1.0f - (0.0022f * k * k) + (0.0776f * k) + 0.7369f; } diff --git a/libraries/render-utils/src/debug_deferred_buffer_shared.slh b/libraries/render-utils/src/debug_deferred_buffer_shared.slh new file mode 100644 index 0000000000..2d11a66d61 --- /dev/null +++ b/libraries/render-utils/src/debug_deferred_buffer_shared.slh @@ -0,0 +1,17 @@ +// glsl / C++ compatible source as interface for FadeEffect +#ifdef __cplusplus +# define INT32 glm::int32 +#else +# define INT32 int +#endif + +struct DebugParameters +{ + INT32 _shadowCascadeIndex; +}; + + // <@if 1@> + // Trigger Scribe include + // <@endif@> +// + From c95b359aa74811971f3184c522632bb578b21c0c Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 2 Jul 2018 10:23:53 -0700 Subject: [PATCH 29/29] Fix MS16390: Correctly update UI when Buy endpoint fails --- interface/resources/qml/hifi/commerce/checkout/Checkout.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 16c1b55930..653d814020 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -92,9 +92,9 @@ Rectangle { onBuyResult: { if (result.status !== 'success') { - failureErrorText.text = result.message; + failureErrorText.text = result.data.message; root.activeView = "checkoutFailure"; - UserActivityLogger.commercePurchaseFailure(root.itemId, root.itemAuthor, root.itemPrice, !root.alreadyOwned, result.message); + UserActivityLogger.commercePurchaseFailure(root.itemId, root.itemAuthor, root.itemPrice, !root.alreadyOwned, result.data.message); } else { root.certificateId = result.data.certificate_id; root.itemHref = result.data.download_url;