From 0f42943bfbeb72088f6569e2e42e3315fe2fff7c Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 29 Aug 2016 11:55:04 -0700 Subject: [PATCH 01/20] Marketplace tablet is a bit larger and lower DPI. Bug fix for grabbing/equipping large objects, they no longer will drop immediately if your grab point is too far away from the grabbed entity position. --- .../system/controllers/handControllerGrab.js | 42 +++++++++++++++---- scripts/system/libraries/WebTablet.js | 9 ++-- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 32e0b047de..1f90918a69 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -21,7 +21,7 @@ Script.include("/~/system/libraries/Xform.js"); // add lines where the hand ray picking is happening // var WANT_DEBUG = false; -var WANT_DEBUG_STATE = false; +var WANT_DEBUG_STATE = true; var WANT_DEBUG_SEARCH_NAME = null; // @@ -125,6 +125,12 @@ var ZERO_VEC = { z: 0 }; +var ONE_VEC = { + x: 1, + y: 1, + z: 1 +}; + var NULL_UUID = "{00000000-0000-0000-0000-000000000000}"; // these control how long an abandoned pointer line or action will hang around @@ -232,6 +238,25 @@ CONTROLLER_STATE_MACHINE[STATE_ENTITY_TOUCHING] = { updateMethod: "entityTouching" }; +function distanceBetweenPointAndEntityBoundingBox(point, entityProps) { + var entityXform = new Xform(entityProps.rotation, entityProps.position); + var localPoint = entityXform.inv().xformPoint(point); + var minOffset = Vec3.multiplyVbyV(entityProps.registrationPoint, entityProps.dimensions); + var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions); + var localMin = Vec3.subtract(entityXform.trans, minOffset); + var localMax = Vec3.sum(entityXform.trans, maxOffset); + + var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z}; + v.x = Math.max(v.x, localMin.x); + v.x = Math.min(v.x, localMax.x); + v.y = Math.max(v.y, localMin.y); + v.y = Math.min(v.y, localMax.y); + v.z = Math.max(v.z, localMin.z); + v.z = Math.min(v.z, localMax.z); + + return Vec3.distance(v, localPoint); +} + function angleBetween(a, b) { return Math.acos(Vec3.dot(Vec3.normalize(a), Vec3.normalize(b))); } @@ -1961,7 +1986,8 @@ function MyController(hand) { this.heartBeat(this.grabbedEntity); var props = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "parentID", - "position", "rotation", "dimensions"]); + "position", "rotation", "dimensions", + "registrationPoint"]); if (!props.position) { // server may have reset, taking our equipped entity with it. move back to "off" stte this.callEntityMethodOnGrabbed("releaseGrab"); @@ -1975,14 +2001,12 @@ function MyController(hand) { if (props.parentID == MyAvatar.sessionUUID) { var handPosition = this.getHandPosition(); - // the center of the equipped object being far from the hand isn't enough to auto-unequip -- we also - // need to fail the findEntities test. - var TEAR_AWAY_DISTANCE = 0.04; - var nearPickedCandidateEntities = Entities.findEntities(handPosition, NEAR_GRAB_RADIUS + TEAR_AWAY_DISTANCE); - if (nearPickedCandidateEntities.indexOf(this.grabbedEntity) == -1) { - // for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip. + + var TEAR_AWAY_DISTANCE = 0.1; + var dist = distanceBetweenPointAndEntityBoundingBox(handPosition, props); + if (dist > TEAR_AWAY_DISTANCE) { print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." + - props.parentID + " " + vec3toStr(props.position)); + props.parentID + ", dist = " + dist); if (this.state == STATE_NEAR_GRABBING) { this.callEntityMethodOnGrabbed("releaseGrab"); diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 34368e475b..adbcd78381 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -11,6 +11,8 @@ var RAD_TO_DEG = 180 / Math.PI; var X_AXIS = {x: 1, y: 0, z: 0}; var Y_AXIS = {x: 0, y: 1, z: 0}; +var DEFAULT_DPI = 30; +var DEFAULT_WIDTH = 0.5; var TABLET_URL = "https://s3.amazonaws.com/hifi-public/tony/tablet.fbx"; @@ -37,12 +39,13 @@ function calcSpawnInfo() { } // ctor -WebTablet = function (url) { +WebTablet = function (url, width, dpi) { var ASPECT = 4.0 / 3.0; - var WIDTH = 0.4; + var WIDTH = width || DEFAULT_WIDTH; var HEIGHT = WIDTH * ASPECT; var DEPTH = 0.025; + var DPI = dpi || DEFAULT_DPI; var spawnInfo = calcSpawnInfo(); @@ -78,7 +81,7 @@ WebTablet = function (url) { position: webEntityPosition, rotation: webEntityRotation, shapeType: "box", - dpi: 45, + dpi: DPI, parentID: this.tabletEntityID, parentJointIndex: -1 }); From dcd91d43981a809c6fb3bd7d5ae96bc6404d0887 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 29 Aug 2016 12:04:48 -0700 Subject: [PATCH 02/20] removed debug flag --- scripts/system/controllers/handControllerGrab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 1f90918a69..611e8d77be 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -21,7 +21,7 @@ Script.include("/~/system/libraries/Xform.js"); // add lines where the hand ray picking is happening // var WANT_DEBUG = false; -var WANT_DEBUG_STATE = true; +var WANT_DEBUG_STATE = false; var WANT_DEBUG_SEARCH_NAME = null; // From c4ec02c4bfb556952987c7851e7f174884ddf102 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 24 Aug 2016 10:32:59 -0700 Subject: [PATCH 03/20] add removal of resources folder during install process --- cmake/templates/NSIS.template.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in index 4786b12743..e8d89ccad7 100644 --- a/cmake/templates/NSIS.template.in +++ b/cmake/templates/NSIS.template.in @@ -589,6 +589,9 @@ Section "-Core installation" Delete "$INSTDIR\version" Delete "$INSTDIR\xinput1_3.dll" + ; Remove the resources folder so we don't end up including removed QML files + RMDir /r "$INSTDIR\resources" + ; Delete old desktop shortcuts before they were renamed during Sandbox rename Delete "$DESKTOP\@PRE_SANDBOX_INTERFACE_SHORTCUT_NAME@.lnk" Delete "$DESKTOP\@PRE_SANDBOX_CONSOLE_SHORTCUT_NAME@.lnk" From 0e4fb51d0924ce5f7bf8632c556f41eae39c9c7d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 24 Aug 2016 11:36:36 -0700 Subject: [PATCH 04/20] force cleanup section to be first --- cmake/templates/NSIS.template.in | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in index e8d89ccad7..abecf0fc62 100644 --- a/cmake/templates/NSIS.template.in +++ b/cmake/templates/NSIS.template.in @@ -243,6 +243,16 @@ FunctionEnd ;-------------------------------- ; Installation types + +Section "-Previous Install Cleanup" + + ${If} ${SectionIsSelected} ${@CLIENT_COMPONENT_NAME@} + ; Remove the resources folder so we don't end up including removed QML files + RMDir /r "$INSTDIR\resources" + ${EndIf} + +SectionEnd + @CPACK_NSIS_INSTALLATION_TYPES@ ;-------------------------------- @@ -589,9 +599,6 @@ Section "-Core installation" Delete "$INSTDIR\version" Delete "$INSTDIR\xinput1_3.dll" - ; Remove the resources folder so we don't end up including removed QML files - RMDir /r "$INSTDIR\resources" - ; Delete old desktop shortcuts before they were renamed during Sandbox rename Delete "$DESKTOP\@PRE_SANDBOX_INTERFACE_SHORTCUT_NAME@.lnk" Delete "$DESKTOP\@PRE_SANDBOX_CONSOLE_SHORTCUT_NAME@.lnk" From fab25686245f57e1d39a3f07f10eb28081074a1e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 24 Aug 2016 16:16:16 -0700 Subject: [PATCH 05/20] always remove the resources dir, make client required --- cmake/macros/GenerateInstallers.cmake | 3 +++ cmake/templates/NSIS.template.in | 8 ++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmake/macros/GenerateInstallers.cmake b/cmake/macros/GenerateInstallers.cmake index 0def701739..d0da908554 100644 --- a/cmake/macros/GenerateInstallers.cmake +++ b/cmake/macros/GenerateInstallers.cmake @@ -24,6 +24,9 @@ macro(GENERATE_INSTALLERS) set(CPACK_NSIS_PACKAGE_NAME ${_DISPLAY_NAME}) set(CPACK_PACKAGE_INSTALL_DIRECTORY ${_DISPLAY_NAME}) + # make the Interface client a required component + set(CPACK_COMPONENT_${CLIENT_COMPONENT}_REQUIRED TRUE) + if (WIN32) # include CMake module that will install compiler system libraries # so that we have msvcr120 and msvcp120 installed with targets diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in index abecf0fc62..29e3869abe 100644 --- a/cmake/templates/NSIS.template.in +++ b/cmake/templates/NSIS.template.in @@ -245,12 +245,8 @@ FunctionEnd ; Installation types Section "-Previous Install Cleanup" - - ${If} ${SectionIsSelected} ${@CLIENT_COMPONENT_NAME@} - ; Remove the resources folder so we don't end up including removed QML files - RMDir /r "$INSTDIR\resources" - ${EndIf} - + ; Remove the resources folder so we don't end up including removed QML files + RMDir /r "$INSTDIR\resources" SectionEnd @CPACK_NSIS_INSTALLATION_TYPES@ From 87ecc65dce05d301bdb186e77033cb2f437e0d0e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 24 Aug 2016 17:01:59 -0700 Subject: [PATCH 06/20] set component requirement in cpack add componeent command --- cmake/macros/GenerateInstallers.cmake | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmake/macros/GenerateInstallers.cmake b/cmake/macros/GenerateInstallers.cmake index d0da908554..34997a21c8 100644 --- a/cmake/macros/GenerateInstallers.cmake +++ b/cmake/macros/GenerateInstallers.cmake @@ -24,9 +24,6 @@ macro(GENERATE_INSTALLERS) set(CPACK_NSIS_PACKAGE_NAME ${_DISPLAY_NAME}) set(CPACK_PACKAGE_INSTALL_DIRECTORY ${_DISPLAY_NAME}) - # make the Interface client a required component - set(CPACK_COMPONENT_${CLIENT_COMPONENT}_REQUIRED TRUE) - if (WIN32) # include CMake module that will install compiler system libraries # so that we have msvcr120 and msvcp120 installed with targets @@ -88,7 +85,7 @@ macro(GENERATE_INSTALLERS) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") - cpack_add_component(${CLIENT_COMPONENT} DISPLAY_NAME "High Fidelity Interface") + cpack_add_component(${CLIENT_COMPONENT} DISPLAY_NAME "High Fidelity Interface" REQUIRED) cpack_add_component(${SERVER_COMPONENT} DISPLAY_NAME "High Fidelity Sandbox") include(CPack) From 20777bd19a11e99987da52e62469d479e27df819 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 25 Aug 2016 15:50:13 -0700 Subject: [PATCH 07/20] force default selection of client on install --- cmake/macros/GenerateInstallers.cmake | 2 +- cmake/templates/NSIS.template.in | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/macros/GenerateInstallers.cmake b/cmake/macros/GenerateInstallers.cmake index 34997a21c8..0def701739 100644 --- a/cmake/macros/GenerateInstallers.cmake +++ b/cmake/macros/GenerateInstallers.cmake @@ -85,7 +85,7 @@ macro(GENERATE_INSTALLERS) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") - cpack_add_component(${CLIENT_COMPONENT} DISPLAY_NAME "High Fidelity Interface" REQUIRED) + cpack_add_component(${CLIENT_COMPONENT} DISPLAY_NAME "High Fidelity Interface") cpack_add_component(${SERVER_COMPONENT} DISPLAY_NAME "High Fidelity Sandbox") include(CPack) diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in index 29e3869abe..94f77a35c0 100644 --- a/cmake/templates/NSIS.template.in +++ b/cmake/templates/NSIS.template.in @@ -129,6 +129,11 @@ Var AR_RegFlags ;Writing modified flags SectionSetFlags ${${SecName}} $AR_SecFlags + ; The client is always selected by default + ${If} ${SecName} == @CLIENT_COMPONENT_NAME@ + SectionSetFlags ${${SecName}} 17 + ${EndIf} + "default_${SecName}:" !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected !macroend From a8272712bbb841a59eacf7a98ae85eded5492493 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 29 Aug 2016 15:40:45 -0700 Subject: [PATCH 08/20] move forced client selection to apply to all installs --- cmake/templates/NSIS.template.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in index 94f77a35c0..65e801d321 100644 --- a/cmake/templates/NSIS.template.in +++ b/cmake/templates/NSIS.template.in @@ -129,12 +129,12 @@ Var AR_RegFlags ;Writing modified flags SectionSetFlags ${${SecName}} $AR_SecFlags - ; The client is always selected by default - ${If} ${SecName} == @CLIENT_COMPONENT_NAME@ - SectionSetFlags ${${SecName}} 17 - ${EndIf} - "default_${SecName}:" + ; The client is always selected by default + ${If} ${SecName} == @CLIENT_COMPONENT_NAME@ + SectionSetFlags ${${SecName}} 17 + ${EndIf} + !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected !macroend From faef8a9930e3a537ec6ae3dd396529ba93ef1104 Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 30 Aug 2016 12:22:21 -0700 Subject: [PATCH 09/20] Adding the timing for GPU support with a simpelr JobConfig --- .../gpu-gl/src/gpu/gl/GLBackendQuery.cpp | 7 ++- libraries/gpu-gl/src/gpu/gl/GLQuery.h | 1 + libraries/gpu/src/gpu/Query.cpp | 20 ++++--- libraries/gpu/src/gpu/Query.h | 15 ++++-- .../src/AmbientOcclusionEffect.cpp | 3 +- .../render-utils/src/AmbientOcclusionEffect.h | 8 ++- .../src/DeferredLightingEffect.cpp | 2 +- .../render-utils/src/DeferredLightingEffect.h | 16 +----- .../render-utils/src/RenderDeferredTask.cpp | 2 +- .../render-utils/src/RenderDeferredTask.h | 27 ++-------- .../render-utils/src/SurfaceGeometryPass.cpp | 4 +- .../render-utils/src/SurfaceGeometryPass.h | 24 +++------ libraries/render/src/render/Task.h | 52 ++++++++++++++++--- .../utilities/render/ambientOcclusionPass.qml | 2 +- scripts/developer/utilities/render/stats.qml | 2 +- .../developer/utilities/render/statsGPU.qml | 50 ++++++++++++++++-- 16 files changed, 146 insertions(+), 89 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackendQuery.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackendQuery.cpp index 60b204ba60..19d008da2c 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackendQuery.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackendQuery.cpp @@ -25,6 +25,7 @@ void GLBackend::do_beginQuery(const Batch& batch, size_t paramOffset) { auto query = batch._queries.get(batch._params[paramOffset]._uint); GLQuery* glquery = syncGPUObject(*query); if (glquery) { + glGetInteger64v(GL_TIMESTAMP, (GLint64*)&glquery->_batchElapsedTime); if (timeElapsed) { glBeginQuery(GL_TIME_ELAPSED, glquery->_endqo); } else { @@ -43,6 +44,10 @@ void GLBackend::do_endQuery(const Batch& batch, size_t paramOffset) { } else { glQueryCounter(glquery->_endqo, GL_TIMESTAMP); } + GLint64 now; + glGetInteger64v(GL_TIMESTAMP, &now); + glquery->_batchElapsedTime = now - glquery->_batchElapsedTime; + (void)CHECK_GL_ERROR(); } } @@ -61,7 +66,7 @@ void GLBackend::do_getQuery(const Batch& batch, size_t paramOffset) { glGetQueryObjectui64v(glquery->_endqo, GL_QUERY_RESULT, &end); glquery->_result = end - start; } - query->triggerReturnHandler(glquery->_result); + query->triggerReturnHandler(glquery->_result, glquery->_batchElapsedTime); } (void)CHECK_GL_ERROR(); } diff --git a/libraries/gpu-gl/src/gpu/gl/GLQuery.h b/libraries/gpu-gl/src/gpu/gl/GLQuery.h index 4bed659ba3..bf10d002e6 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLQuery.h +++ b/libraries/gpu-gl/src/gpu/gl/GLQuery.h @@ -48,6 +48,7 @@ public: const GLuint& _endqo = { _id }; const GLuint _beginqo = { 0 }; GLuint64 _result { (GLuint64)-1 }; + GLuint64 _batchElapsedTime { (GLuint64) 0 }; protected: GLQuery(const std::weak_ptr& backend, const Query& query, GLuint endId, GLuint beginId) : Parent(backend, query, endId), _beginqo(beginId) {} diff --git a/libraries/gpu/src/gpu/Query.cpp b/libraries/gpu/src/gpu/Query.cpp index 76c239b1e0..51be04d682 100644 --- a/libraries/gpu/src/gpu/Query.cpp +++ b/libraries/gpu/src/gpu/Query.cpp @@ -24,12 +24,16 @@ Query::~Query() { } -double Query::getElapsedTime() const { +double Query::getGPUElapsedTime() const { return ((double)_queryResult) / 1000000.0; } +double Query::getBatchElapsedTime() const { + return ((double)_usecBatchElapsedTime) / 1000000.0; +} -void Query::triggerReturnHandler(uint64_t queryResult) { +void Query::triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime) { _queryResult = queryResult; + _usecBatchElapsedTime = batchElapsedTime; if (_returnHandler) { _returnHandler(*this); } @@ -40,8 +44,8 @@ RangeTimer::RangeTimer() { for (int i = 0; i < QUERY_QUEUE_SIZE; i++) { _timerQueries.push_back(std::make_shared([&, i] (const Query& query) { _tailIndex ++; - auto elapsedTime = query.getElapsedTime(); - _movingAverage.addSample(elapsedTime); + _movingAverageGPU.addSample(query.getGPUElapsedTime()); + _movingAverageBatch.addSample(query.getBatchElapsedTime()); })); } } @@ -66,6 +70,10 @@ void RangeTimer::end(gpu::Batch& batch) { } } -double RangeTimer::getAverage() const { - return _movingAverage.average; +double RangeTimer::getGPUAverage() const { + return _movingAverageGPU.average; +} + +double RangeTimer::getBatchAverage() const { + return _movingAverageBatch.average; } \ No newline at end of file diff --git a/libraries/gpu/src/gpu/Query.h b/libraries/gpu/src/gpu/Query.h index 48b9d0a0d5..ab259541b5 100644 --- a/libraries/gpu/src/gpu/Query.h +++ b/libraries/gpu/src/gpu/Query.h @@ -30,14 +30,17 @@ namespace gpu { Query(const Handler& returnHandler); ~Query(); - double getElapsedTime() const; + double getGPUElapsedTime() const; + double getBatchElapsedTime() const; + // Only for gpu::Context const GPUObjectPointer gpuObject {}; - void triggerReturnHandler(uint64_t queryResult); + void triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime); protected: Handler _returnHandler; - uint64_t _queryResult = 0; + uint64_t _queryResult { 0 }; + uint64_t _usecBatchElapsedTime { 0 }; }; typedef std::shared_ptr QueryPointer; @@ -53,7 +56,8 @@ namespace gpu { void begin(gpu::Batch& batch); void end(gpu::Batch& batch); - double getAverage() const; + double getGPUAverage() const; + double getBatchAverage() const; protected: @@ -62,7 +66,8 @@ namespace gpu { gpu::Queries _timerQueries; int _headIndex = -1; int _tailIndex = -1; - MovingAverage _movingAverage; + MovingAverage _movingAverageGPU; + MovingAverage _movingAverageBatch; int rangeIndex(int index) const { return (index % QUERY_QUEUE_SIZE); } }; diff --git a/libraries/render-utils/src/AmbientOcclusionEffect.cpp b/libraries/render-utils/src/AmbientOcclusionEffect.cpp index 86223e9877..3bf887e1b6 100644 --- a/libraries/render-utils/src/AmbientOcclusionEffect.cpp +++ b/libraries/render-utils/src/AmbientOcclusionEffect.cpp @@ -432,7 +432,8 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext }); // Update the timer - std::static_pointer_cast(renderContext->jobConfig)->gpuTime = _gpuTimer.getAverage(); + auto config = std::static_pointer_cast(renderContext->jobConfig); + config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage()); } diff --git a/libraries/render-utils/src/AmbientOcclusionEffect.h b/libraries/render-utils/src/AmbientOcclusionEffect.h index 8bb4600d3c..1a828cb2c0 100644 --- a/libraries/render-utils/src/AmbientOcclusionEffect.h +++ b/libraries/render-utils/src/AmbientOcclusionEffect.h @@ -53,7 +53,7 @@ protected: using AmbientOcclusionFramebufferPointer = std::shared_ptr; -class AmbientOcclusionEffectConfig : public render::Job::Config::Persistent { +class AmbientOcclusionEffectConfig : public render::GPUJobConfig::Persistent { Q_OBJECT Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty) Q_PROPERTY(bool ditheringEnabled MEMBER ditheringEnabled NOTIFY dirty) @@ -68,9 +68,9 @@ class AmbientOcclusionEffectConfig : public render::Job::Config::Persistent { Q_PROPERTY(int numSamples MEMBER numSamples WRITE setNumSamples) Q_PROPERTY(int resolutionLevel MEMBER resolutionLevel WRITE setResolutionLevel) Q_PROPERTY(int blurRadius MEMBER blurRadius WRITE setBlurRadius) - Q_PROPERTY(double gpuTime READ getGpuTime) + public: - AmbientOcclusionEffectConfig() : render::Job::Config::Persistent("Ambient Occlusion", false) {} + AmbientOcclusionEffectConfig() : render::GPUJobConfig::Persistent("Ambient Occlusion", false) {} const int MAX_RESOLUTION_LEVEL = 4; const int MAX_BLUR_RADIUS = 6; @@ -84,7 +84,6 @@ public: void setNumSamples(int samples) { numSamples = std::max(1.0f, (float)samples); emit dirty(); } void setResolutionLevel(int level) { resolutionLevel = std::max(0, std::min(level, MAX_RESOLUTION_LEVEL)); emit dirty(); } void setBlurRadius(int radius) { blurRadius = std::max(0, std::min(MAX_BLUR_RADIUS, radius)); emit dirty(); } - double getGpuTime() { return gpuTime; } float radius{ 0.5f }; float perspectiveScale{ 1.0f }; @@ -99,7 +98,6 @@ public: bool ditheringEnabled{ true }; // randomize the distribution of taps per pixel, should always be true bool borderingEnabled{ true }; // avoid evaluating information from non existing pixels out of the frame, should always be true bool fetchMipsEnabled{ true }; // fetch taps in sub mips to otpimize cache, should always be true - double gpuTime{ 0.0 }; signals: void dirty(); diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 5dd4c0a232..8e83f737ea 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -714,5 +714,5 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo }); auto config = std::static_pointer_cast(renderContext->jobConfig); - config->gpuTime = _gpuTimer.getAverage(); + config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage()); } diff --git a/libraries/render-utils/src/DeferredLightingEffect.h b/libraries/render-utils/src/DeferredLightingEffect.h index 466c58c36e..61bac2f063 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.h +++ b/libraries/render-utils/src/DeferredLightingEffect.h @@ -161,21 +161,7 @@ public: void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); }; - -class RenderDeferredConfig : public render::Job::Config { - Q_OBJECT - Q_PROPERTY(double gpuTime READ getGpuTime) -public: - RenderDeferredConfig() : render::Job::Config(true) {} - - double getGpuTime() { return gpuTime; } - - double gpuTime{ 0.0 }; - -signals: - void dirty(); -}; - +using RenderDeferredConfig = render::GPUJobConfig; class RenderDeferred { public: diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index cedc2ef45e..1e63cba8da 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -245,7 +245,7 @@ void EndGPURangeTimer::run(const render::SceneContextPointer& sceneContext, cons }); auto config = std::static_pointer_cast(renderContext->jobConfig); - config->gpuTime = timer->getAverage(); + config->setGPUBatchRunTime(timer->getGPUAverage(), timer->getBatchAverage()); } diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index 749cc09edc..21494336b3 100755 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -29,18 +29,8 @@ protected: gpu::RangeTimerPointer _gpuTimer; }; +using GPURangeTimerConfig = render::GPUJobConfig; -class GPURangeTimerConfig : public render::Job::Config { - Q_OBJECT - Q_PROPERTY(double gpuTime READ getGpuTime) -public: - double getGpuTime() { return gpuTime; } - -protected: - friend class EndGPURangeTimer; - double gpuTime; -}; - class EndGPURangeTimer { public: using Config = GPURangeTimerConfig; @@ -143,16 +133,7 @@ protected: gpu::PipelinePointer getOpaquePipeline(); }; -class DrawBackgroundDeferredConfig : public render::Job::Config { - Q_OBJECT - Q_PROPERTY(double gpuTime READ getGpuTime) -public: - double getGpuTime() { return gpuTime; } - -protected: - friend class DrawBackgroundDeferred; - double gpuTime; -}; +using DrawBackgroundDeferredConfig = render::GPUJobConfig; class DrawBackgroundDeferred { public: @@ -211,6 +192,8 @@ public: void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& srcFramebuffer); }; +using RenderDeferredTaskConfig = render::GPUTaskConfig; +/** class RenderDeferredTaskConfig : public render::Task::Config { Q_OBJECT Q_PROPERTY(double gpuTime READ getGpuTime) @@ -220,7 +203,7 @@ public: protected: friend class RenderDeferredTask; double gpuTime; -}; +};*/ class RenderDeferredTask : public render::Task { public: diff --git a/libraries/render-utils/src/SurfaceGeometryPass.cpp b/libraries/render-utils/src/SurfaceGeometryPass.cpp index 7a5a34c756..1957f8456a 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.cpp +++ b/libraries/render-utils/src/SurfaceGeometryPass.cpp @@ -201,7 +201,7 @@ void LinearDepthPass::run(const render::SceneContextPointer& sceneContext, const }); auto config = std::static_pointer_cast(renderContext->jobConfig); - config->gpuTime = _gpuTimer.getAverage(); + config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage()); } @@ -524,7 +524,7 @@ void SurfaceGeometryPass::run(const render::SceneContextPointer& sceneContext, c auto config = std::static_pointer_cast(renderContext->jobConfig); - config->gpuTime = _gpuTimer.getAverage(); + config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage()); } diff --git a/libraries/render-utils/src/SurfaceGeometryPass.h b/libraries/render-utils/src/SurfaceGeometryPass.h index 24f0c56cdd..7c60cbce86 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.h +++ b/libraries/render-utils/src/SurfaceGeometryPass.h @@ -62,20 +62,15 @@ protected: using LinearDepthFramebufferPointer = std::shared_ptr; - -class LinearDepthPassConfig : public render::Job::Config { +using LinearDepthPassConfig = render::GPUJobConfig; +/* +class LinearDepthPassConfig : public render::GPUJobConfig { Q_OBJECT - Q_PROPERTY(double gpuTime READ getGpuTime) public: - LinearDepthPassConfig() : render::Job::Config(true) {} - - double getGpuTime() { return gpuTime; } - - double gpuTime{ 0.0 }; - + LinearDepthPassConfig() : render::GPUJobConfig(true) {} signals: void dirty(); -}; +};*/ class LinearDepthPass { public: @@ -148,7 +143,7 @@ protected: using SurfaceGeometryFramebufferPointer = std::shared_ptr; -class SurfaceGeometryPassConfig : public render::Job::Config { +class SurfaceGeometryPassConfig : public render::GPUJobConfig { Q_OBJECT Q_PROPERTY(float depthThreshold MEMBER depthThreshold NOTIFY dirty) Q_PROPERTY(float basisScale MEMBER basisScale NOTIFY dirty) @@ -158,9 +153,8 @@ class SurfaceGeometryPassConfig : public render::Job::Config { Q_PROPERTY(float diffuseFilterScale MEMBER diffuseFilterScale NOTIFY dirty) Q_PROPERTY(float diffuseDepthThreshold MEMBER diffuseDepthThreshold NOTIFY dirty) - Q_PROPERTY(double gpuTime READ getGpuTime) public: - SurfaceGeometryPassConfig() : render::Job::Config(true) {} + SurfaceGeometryPassConfig() : render::GPUJobConfig(true) {} float depthThreshold{ 5.0f }; // centimeters float basisScale{ 1.0f }; @@ -169,10 +163,6 @@ public: float diffuseFilterScale{ 0.2f }; float diffuseDepthThreshold{ 1.0f }; - double getGpuTime() { return gpuTime; } - - double gpuTime{ 0.0 }; - signals: void dirty(); }; diff --git a/libraries/render/src/render/Task.h b/libraries/render/src/render/Task.h index 6ba1e3c625..204e5d5dee 100644 --- a/libraries/render/src/render/Task.h +++ b/libraries/render/src/render/Task.h @@ -334,9 +334,9 @@ protected: // A default Config is always on; to create an enableable Config, use the ctor JobConfig(bool enabled) class JobConfig : public QObject { Q_OBJECT - Q_PROPERTY(quint64 cpuRunTime READ getCPUTRunTime NOTIFY newStats()) + Q_PROPERTY(double cpuRunTime READ getCPURunTime NOTIFY newStats()) //ms - quint64 _CPURunTime{ 0 }; + double _msCPURunTime{ 0.0 }; public: using Persistent = PersistentConfig; @@ -364,8 +364,8 @@ public: // Running Time measurement // The new stats signal is emitted once per run time of a job when stats (cpu runtime) are updated - void setCPURunTime(quint64 ustime) { _CPURunTime = ustime; emit newStats(); } - quint64 getCPUTRunTime() const { return _CPURunTime; } + void setCPURunTime(double mstime) { _msCPURunTime = mstime; emit newStats(); } + double getCPURunTime() const { return _msCPURunTime; } public slots: void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); } @@ -418,6 +418,46 @@ template void jobRun(T& data, const SceneContextPoin data.run(sceneContext, renderContext, input, output); } +class GPUJobConfig : public JobConfig { + Q_OBJECT + Q_PROPERTY(double gpuRunTime READ getGPURunTime) + Q_PROPERTY(double batchRunTime READ getBatchRunTime) + + double _msGPURunTime { 0.0 }; + double _msBatchRunTime { 0.0 }; +public: + using Persistent = PersistentConfig; + + GPUJobConfig() = default; + GPUJobConfig(bool enabled) : JobConfig(enabled) {} + + // Running Time measurement on GPU and for Batch execution + void setGPUBatchRunTime(double msGpuTime, double msBatchTime) { _msGPURunTime = msGpuTime; _msBatchRunTime = msBatchTime; } + double getGPURunTime() const { return _msGPURunTime; } + double getBatchRunTime() const { return _msBatchRunTime; } +}; + +class GPUTaskConfig : public TaskConfig { + Q_OBJECT + Q_PROPERTY(double gpuRunTime READ getGPURunTime) + Q_PROPERTY(double batchRunTime READ getBatchRunTime) + + double _msGPURunTime { 0.0 }; + double _msBatchRunTime { 0.0 }; +public: + + using Persistent = PersistentConfig; + + + GPUTaskConfig() = default; + GPUTaskConfig(bool enabled) : TaskConfig(enabled) {} + + // Running Time measurement on GPU and for Batch execution + void setGPUBatchRunTime(double msGpuTime, double msBatchTime) { _msGPURunTime = msGpuTime; _msBatchRunTime = msBatchTime; } + double getGPURunTime() const { return _msGPURunTime; } + double getBatchRunTime() const { return _msBatchRunTime; } +}; + class Job { public: using Config = JobConfig; @@ -439,7 +479,7 @@ public: virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) = 0; protected: - void setCPURunTime(quint64 ustime) { std::static_pointer_cast(_config)->setCPURunTime(ustime); } + void setCPURunTime(double mstime) { std::static_pointer_cast(_config)->setCPURunTime(mstime); } QConfigPointer _config; @@ -502,7 +542,7 @@ public: _concept->run(sceneContext, renderContext); - _concept->setCPURunTime(usecTimestampNow() - start); + _concept->setCPURunTime((double)(usecTimestampNow() - start) / 1000000.0); } protected: diff --git a/scripts/developer/utilities/render/ambientOcclusionPass.qml b/scripts/developer/utilities/render/ambientOcclusionPass.qml index a461c06a19..6eeaad3f8a 100644 --- a/scripts/developer/utilities/render/ambientOcclusionPass.qml +++ b/scripts/developer/utilities/render/ambientOcclusionPass.qml @@ -78,7 +78,7 @@ Column { valueNumDigits: "4" plots: [ { - prop: "gpuTime", + prop: "gpuRunTime", label: "gpu", color: "#FFFFFF" } diff --git a/scripts/developer/utilities/render/stats.qml b/scripts/developer/utilities/render/stats.qml index d20efc1f10..31c9f3859b 100644 --- a/scripts/developer/utilities/render/stats.qml +++ b/scripts/developer/utilities/render/stats.qml @@ -213,7 +213,7 @@ Item { height: parent.evalEvenHeight() object: parent.drawOpaqueConfig valueUnit: "ms" - valueScale: 1000 + valueScale: 1 valueNumDigits: "1" plots: [ { diff --git a/scripts/developer/utilities/render/statsGPU.qml b/scripts/developer/utilities/render/statsGPU.qml index 74bd376a00..3798de1200 100644 --- a/scripts/developer/utilities/render/statsGPU.qml +++ b/scripts/developer/utilities/render/statsGPU.qml @@ -39,31 +39,71 @@ Item { plots: [ { object: Render.getConfig("OpaqueRangeTimer"), - prop: "gpuTime", + prop: "gpuRunTime", label: "Opaque", color: "#FFFFFF" }, { object: Render.getConfig("LinearDepth"), - prop: "gpuTime", + prop: "gpuRunTime", label: "LinearDepth", color: "#00FF00" },{ object: Render.getConfig("SurfaceGeometry"), - prop: "gpuTime", + prop: "gpuRunTime", label: "SurfaceGeometry", color: "#00FFFF" }, { object: Render.getConfig("RenderDeferred"), - prop: "gpuTime", + prop: "gpuRunTime", label: "DeferredLighting", color: "#FF00FF" } , { object: Render.getConfig("ToneAndPostRangeTimer"), - prop: "gpuTime", + prop: "gpuRunTime", + label: "tone and post", + color: "#FF0000" + } + ] + } + PlotPerf { + title: "Timing" + height: parent.evalEvenHeight() + object: parent.drawOpaqueConfig + valueUnit: "ms" + valueScale: 1 + valueNumDigits: "4" + plots: [ + { + object: Render.getConfig("OpaqueRangeTimer"), + prop: "batchRunTime", + label: "Opaque", + color: "#FFFFFF" + }, + { + object: Render.getConfig("LinearDepth"), + prop: "batchRunTime", + label: "LinearDepth", + color: "#00FF00" + },{ + object: Render.getConfig("SurfaceGeometry"), + prop: "batchRunTime", + label: "SurfaceGeometry", + color: "#00FFFF" + }, + { + object: Render.getConfig("RenderDeferred"), + prop: "batchRunTime", + label: "DeferredLighting", + color: "#FF00FF" + } + , + { + object: Render.getConfig("ToneAndPostRangeTimer"), + prop: "batchRunTime", label: "tone and post", color: "#FF0000" } From c553e5f2fefcfca79e32727f04e06113da404cda Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 30 Aug 2016 13:57:47 -0700 Subject: [PATCH 10/20] fine tune the scripts for proper presentation of the timing values --- scripts/developer/utilities/render/ambientOcclusionPass.qml | 2 +- scripts/developer/utilities/render/stats.qml | 2 +- scripts/developer/utilities/render/statsGPU.qml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/developer/utilities/render/ambientOcclusionPass.qml b/scripts/developer/utilities/render/ambientOcclusionPass.qml index 6eeaad3f8a..3ebc80d2f1 100644 --- a/scripts/developer/utilities/render/ambientOcclusionPass.qml +++ b/scripts/developer/utilities/render/ambientOcclusionPass.qml @@ -75,7 +75,7 @@ Column { object: Render.getConfig("AmbientOcclusion") valueUnit: "ms" valueScale: 1 - valueNumDigits: "4" + valueNumDigits: "3" plots: [ { prop: "gpuRunTime", diff --git a/scripts/developer/utilities/render/stats.qml b/scripts/developer/utilities/render/stats.qml index 31c9f3859b..f20c545503 100644 --- a/scripts/developer/utilities/render/stats.qml +++ b/scripts/developer/utilities/render/stats.qml @@ -214,7 +214,7 @@ Item { object: parent.drawOpaqueConfig valueUnit: "ms" valueScale: 1 - valueNumDigits: "1" + valueNumDigits: "2" plots: [ { object: Render.getConfig("DrawOpaqueDeferred"), diff --git a/scripts/developer/utilities/render/statsGPU.qml b/scripts/developer/utilities/render/statsGPU.qml index 3798de1200..1dc08d4cbb 100644 --- a/scripts/developer/utilities/render/statsGPU.qml +++ b/scripts/developer/utilities/render/statsGPU.qml @@ -75,7 +75,7 @@ Item { object: parent.drawOpaqueConfig valueUnit: "ms" valueScale: 1 - valueNumDigits: "4" + valueNumDigits: "3" plots: [ { object: Render.getConfig("OpaqueRangeTimer"), From a6a834f2c7c4e279c2d69cd331be4146063e6acf Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 30 Aug 2016 13:58:28 -0700 Subject: [PATCH 11/20] remember and work on toggle --- scripts/defaultScripts.js | 73 ++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 12 deletions(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 98825c594d..ae525a20cc 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -37,35 +37,76 @@ var DEFAULT_SCRIPTS = [ // add a menu item for debugging var MENU_CATEGORY = "Developer"; var MENU_ITEM = "Debug defaultScripts.js"; -var debuggingDefaultScripts = false; + +var SETTINGS_KEY = '_debugDefaultScriptsIsChecked'; +var previousSetting = Settings.getValue(SETTINGS_KEY); + +if (previousSetting === '' || previousSetting === false || previousSetting === 'false') { + previousSetting = false; +} + +if (previousSetting === true || previousSetting === 'true') { + previousSetting = true; +} + + + +var debuggingDefaultScripts = previousSetting; if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_ITEM)) { Menu.addMenuItem({ menuName: MENU_CATEGORY, menuItemName: MENU_ITEM, isCheckable: true, - isChecked: false, + isChecked: previousSetting, grouping: "Advanced" }); } +function runDefaultsTogether() { + for (var j in DEFAULT_SCRIPTS) { + print('trying to include:'+DEFAULT_SCRIPTS[j]) + Script.include(DEFAULT_SCRIPTS[j]+"?"+Math.random()); + } +} + +function runDefaultsSeparately() { + for (var i in DEFAULT_SCRIPTS) { + Script.load(DEFAULT_SCRIPTS[i]); + } +} // start all scripts if (Menu.isOptionChecked(MENU_ITEM)) { // we're debugging individual default scripts // so we load each into its own ScriptEngine instance debuggingDefaultScripts = true; - for (var i in DEFAULT_SCRIPTS) { - Script.load(DEFAULT_SCRIPTS[i]); - } + runDefaultsSeparately(); } else { // include all default scripts into this ScriptEngine - for (var j in DEFAULT_SCRIPTS) { - Script.include(DEFAULT_SCRIPTS[j]); + runDefaultsTogether(); +} + +function menuItemEvent(menuItem) { + if (menuItem == MENU_ITEM) { + isChecked = Menu.isOptionChecked(MENU_ITEM); + if (isChecked === true) { + Settings.setValue(SETTINGS_KEY, true); + debuggingDefaultScripts = true; + stopLoadedScripts(); + runDefaultsSeparately(); + } else if (isChecked === false) { + Settings.setValue(SETTINGS_KEY, false); + debuggingDefaultScripts = false; + stopLoadedScripts(); + runDefaultsTogether(); + } } } + + function stopLoadedScripts() { - if (debuggingDefaultScripts) { + // remove debug script loads var runningScripts = ScriptDiscoveryService.getRunning(); for (var i in runningScripts) { @@ -76,10 +117,18 @@ function stopLoadedScripts() { } } } - if (!Menu.isOptionChecked(MENU_ITEM)) { - Menu.removeMenuItem(MENU_CATEGORY, MENU_ITEM); - } + +} + +function removeMenuItem() { + if (!Menu.isOptionChecked(MENU_ITEM)) { + Menu.removeMenuItem(MENU_CATEGORY, MENU_ITEM); } } -Script.scriptEnding.connect(stopLoadedScripts); +Script.scriptEnding.connect(function() { + stopLoadedScripts(); + removeMenuItem(); +}); + +Menu.menuItemEvent.connect(menuItemEvent); \ No newline at end of file From e4bdc2e86c71c5bf3dd03fae5e4cb5892106cb6d Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 30 Aug 2016 14:17:27 -0700 Subject: [PATCH 12/20] cleanup --- scripts/defaultScripts.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index ae525a20cc..a95f2c41b2 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -65,8 +65,7 @@ if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_I function runDefaultsTogether() { for (var j in DEFAULT_SCRIPTS) { - print('trying to include:'+DEFAULT_SCRIPTS[j]) - Script.include(DEFAULT_SCRIPTS[j]+"?"+Math.random()); + Script.include(DEFAULT_SCRIPTS[j] + "?" + Math.random()); } } @@ -106,18 +105,16 @@ function menuItemEvent(menuItem) { function stopLoadedScripts() { - // remove debug script loads - var runningScripts = ScriptDiscoveryService.getRunning(); - for (var i in runningScripts) { - var scriptName = runningScripts[i].name; - for (var j in DEFAULT_SCRIPTS) { - if (DEFAULT_SCRIPTS[j].slice(-scriptName.length) === scriptName) { - ScriptDiscoveryService.stopScript(runningScripts[i].url); - } + var runningScripts = ScriptDiscoveryService.getRunning(); + for (var i in runningScripts) { + var scriptName = runningScripts[i].name; + for (var j in DEFAULT_SCRIPTS) { + if (DEFAULT_SCRIPTS[j].slice(-scriptName.length) === scriptName) { + ScriptDiscoveryService.stopScript(runningScripts[i].url); } } - + } } function removeMenuItem() { From 2a5ee5d6b1ec34f5b2207413ba7d8855921bc427 Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 30 Aug 2016 14:28:52 -0700 Subject: [PATCH 13/20] Fixing the unit for the cpuTIme feed and the titles for the GPU PERf Plots --- libraries/render/src/render/Task.h | 2 +- scripts/developer/utilities/render/statsGPU.qml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/render/src/render/Task.h b/libraries/render/src/render/Task.h index 204e5d5dee..df24a08c05 100644 --- a/libraries/render/src/render/Task.h +++ b/libraries/render/src/render/Task.h @@ -542,7 +542,7 @@ public: _concept->run(sceneContext, renderContext); - _concept->setCPURunTime((double)(usecTimestampNow() - start) / 1000000.0); + _concept->setCPURunTime((double)(usecTimestampNow() - start) / 1000.0); } protected: diff --git a/scripts/developer/utilities/render/statsGPU.qml b/scripts/developer/utilities/render/statsGPU.qml index 1dc08d4cbb..3d23c2c6dc 100644 --- a/scripts/developer/utilities/render/statsGPU.qml +++ b/scripts/developer/utilities/render/statsGPU.qml @@ -30,7 +30,7 @@ Item { PlotPerf { - title: "Timing" + title: "GPU Timing" height: parent.evalEvenHeight() object: parent.drawOpaqueConfig valueUnit: "ms" @@ -70,7 +70,7 @@ Item { ] } PlotPerf { - title: "Timing" + title: "Batch Timing" height: parent.evalEvenHeight() object: parent.drawOpaqueConfig valueUnit: "ms" From af68a2550ec8db0f4b652d8f1db57a33aa918d0b Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 30 Aug 2016 14:53:37 -0700 Subject: [PATCH 14/20] Remve dead code --- libraries/render-utils/src/RenderDeferredTask.h | 11 ----------- libraries/render-utils/src/SurfaceGeometryPass.h | 8 -------- 2 files changed, 19 deletions(-) diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index 21494336b3..e379e42445 100755 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -193,17 +193,6 @@ public: }; using RenderDeferredTaskConfig = render::GPUTaskConfig; -/** -class RenderDeferredTaskConfig : public render::Task::Config { - Q_OBJECT - Q_PROPERTY(double gpuTime READ getGpuTime) -public: - double getGpuTime() { return gpuTime; } - -protected: - friend class RenderDeferredTask; - double gpuTime; -};*/ class RenderDeferredTask : public render::Task { public: diff --git a/libraries/render-utils/src/SurfaceGeometryPass.h b/libraries/render-utils/src/SurfaceGeometryPass.h index 7c60cbce86..3bc6b45c7c 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.h +++ b/libraries/render-utils/src/SurfaceGeometryPass.h @@ -63,14 +63,6 @@ protected: using LinearDepthFramebufferPointer = std::shared_ptr; using LinearDepthPassConfig = render::GPUJobConfig; -/* -class LinearDepthPassConfig : public render::GPUJobConfig { - Q_OBJECT -public: - LinearDepthPassConfig() : render::GPUJobConfig(true) {} -signals: - void dirty(); -};*/ class LinearDepthPass { public: From e5b63aa18f0800b7bafb98c801381738ba2e4a80 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 31 Aug 2016 10:54:02 -0700 Subject: [PATCH 15/20] remove cruft from updateModel() arguments --- libraries/entities-renderer/src/EntityTreeRenderer.cpp | 5 ++--- libraries/entities-renderer/src/EntityTreeRenderer.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index ece667422c..e3f1608b74 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -528,14 +528,13 @@ ModelPointer EntityTreeRenderer::allocateModel(const QString& url, float loading return model; } -ModelPointer EntityTreeRenderer::updateModel(ModelPointer model, const QString& newUrl, const QString& collisionUrl) { +ModelPointer EntityTreeRenderer::updateModel(ModelPointer model, const QString& newUrl) { // Only create and delete models on the thread that owns the EntityTreeRenderer if (QThread::currentThread() != thread()) { QMetaObject::invokeMethod(this, "updateModel", Qt::BlockingQueuedConnection, Q_RETURN_ARG(ModelPointer, model), Q_ARG(ModelPointer, model), - Q_ARG(const QString&, newUrl), - Q_ARG(const QString&, collisionUrl)); + Q_ARG(const QString&, newUrl)); return model; } diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index 7ca11ccdbb..18c67d674f 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -76,7 +76,7 @@ public: Q_INVOKABLE ModelPointer allocateModel(const QString& url, float loadingPriority = 0.0f); /// if a renderable entity item needs to update the URL of a model, we will handle that for the entity - Q_INVOKABLE ModelPointer updateModel(ModelPointer original, const QString& newUrl, const QString& collisionUrl); + Q_INVOKABLE ModelPointer updateModel(ModelPointer original, const QString& newUrl); /// if a renderable entity item is done with a model, it should return it to us void releaseModel(ModelPointer model); From 193065eb059a9e8d64663bfbeff44932c6f5e10b Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 31 Aug 2016 12:36:28 -0700 Subject: [PATCH 16/20] remove auto toggle --- scripts/defaultScripts.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index a95f2c41b2..9889b98d9a 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -51,7 +51,6 @@ if (previousSetting === true || previousSetting === 'true') { -var debuggingDefaultScripts = previousSetting; if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_ITEM)) { Menu.addMenuItem({ @@ -87,19 +86,16 @@ if (Menu.isOptionChecked(MENU_ITEM)) { function menuItemEvent(menuItem) { if (menuItem == MENU_ITEM) { + isChecked = Menu.isOptionChecked(MENU_ITEM); if (isChecked === true) { Settings.setValue(SETTINGS_KEY, true); - debuggingDefaultScripts = true; - stopLoadedScripts(); - runDefaultsSeparately(); } else if (isChecked === false) { Settings.setValue(SETTINGS_KEY, false); - debuggingDefaultScripts = false; - stopLoadedScripts(); - runDefaultsTogether(); } } + Window.alert('You must reload all scripts for this to take effect.') + } From 2acf316d1ce1f22d70607062a20b243902c5b25e Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 31 Aug 2016 13:45:58 -0700 Subject: [PATCH 17/20] fix --- scripts/defaultScripts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 9889b98d9a..1d0a955336 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -93,8 +93,9 @@ function menuItemEvent(menuItem) { } else if (isChecked === false) { Settings.setValue(SETTINGS_KEY, false); } + Window.alert('You must reload all scripts for this to take effect.') } - Window.alert('You must reload all scripts for this to take effect.') + } From e1845e2c3f78b39fd8852d6b659cccc735766ec7 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Wed, 31 Aug 2016 14:59:02 -0700 Subject: [PATCH 18/20] add support for renderInfo properties to model entities --- .../src/RenderableModelEntityItem.cpp | 9 ++++ .../entities/src/EntityItemProperties.cpp | 18 ++++++++ libraries/entities/src/EntityItemProperties.h | 19 +++++++++ libraries/model/src/model/TextureMap.h | 1 + .../render-utils/src/MeshPartPayload.cpp | 33 ++++++++++++++- libraries/render-utils/src/MeshPartPayload.h | 7 ++++ libraries/render-utils/src/Model.cpp | 42 ++++++++++++++++++- libraries/render-utils/src/Model.h | 13 ++++++ 8 files changed, 139 insertions(+), 3 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index fc3245f322..abc4e1c767 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -548,6 +548,15 @@ EntityItemProperties RenderableModelEntityItem::getProperties(EntityPropertyFlag if (_originalTexturesRead) { properties.setTextureNames(_originalTextures); } + + if (_model) { + properties.setRenderInfoVertexCount(_model->getRenderInfoVertexCount()); + properties.setRenderInfoTextureCount(_model->getRenderInfoTextureCount()); + properties.setRenderInfoTextureSize(_model->getRenderInfoTextureSize()); + properties.setRenderInfoDrawCalls(_model->getRenderInfoDrawCalls()); + properties.setRenderInfoHasTransparent(_model->getRenderInfoHasTransparent()); + } + return properties; } diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 06c91b4f32..0e40278824 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -580,6 +580,24 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_CLIENT_ONLY, clientOnly); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_OWNING_AVATAR_ID, owningAvatarID); + // Rendering info + if (!skipDefaults) { + QScriptValue renderInfo = engine->newObject(); + + // currently only supported by models + if (_type == EntityTypes::Model) { + renderInfo.setProperty("verticesCount", (int)getRenderInfoVertexCount()); // FIXME - theoretically the number of vertex could be > max int + renderInfo.setProperty("texturesSize", (int)getRenderInfoTextureSize()); // FIXME - theoretically the size of textures could be > max int + renderInfo.setProperty("hasTransparent", getRenderInfoHasTransparent()); + renderInfo.setProperty("drawCalls", getRenderInfoDrawCalls()); + } + + if (_type == EntityTypes::Model || _type == EntityTypes::PolyLine || _type == EntityTypes::ParticleEffect) { + renderInfo.setProperty("texturesCount", QScriptValue(_textureNames.count())); + } + COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_NO_SKIP(renderInfo, renderInfo); // Gettable but not settable + } + properties.setProperty("clientOnly", convertScriptValue(engine, getClientOnly())); properties.setProperty("owningAvatarID", convertScriptValue(engine, getOwningAvatarID())); diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 4591dabc51..473966dd60 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -285,6 +285,19 @@ public: void setJointRotationsDirty() { _jointRotationsSetChanged = true; _jointRotationsChanged = true; } void setJointTranslationsDirty() { _jointTranslationsSetChanged = true; _jointTranslationsChanged = true; } + // render info related items + size_t getRenderInfoVertexCount() const { return _renderInfoVertexCount; } + void setRenderInfoVertexCount(size_t value) { _renderInfoVertexCount = value; } + int getRenderInfoTextureCount() const { return _renderInfoTextureCount; } + void setRenderInfoTextureCount(int value) { _renderInfoTextureCount = value; } + size_t getRenderInfoTextureSize() const { return _renderInfoTextureSize; } + void setRenderInfoTextureSize(size_t value) { _renderInfoTextureSize = value; } + int getRenderInfoDrawCalls() const { return _renderInfoDrawCalls; } + void setRenderInfoDrawCalls(int value) { _renderInfoDrawCalls = value; } + bool getRenderInfoHasTransparent() const { return _renderInfoHasTransparent; } + void setRenderInfoHasTransparent(bool value) { _renderInfoHasTransparent = value; } + + protected: QString getCollisionMaskAsString() const; void setCollisionMaskFromString(const QString& maskString); @@ -308,6 +321,12 @@ private: glm::vec3 _naturalDimensions; glm::vec3 _naturalPosition; + size_t _renderInfoVertexCount { 0 }; + int _renderInfoTextureCount { 0 }; + size_t _renderInfoTextureSize { 0 }; + int _renderInfoDrawCalls { 0 }; + bool _renderInfoHasTransparent { false }; + EntityPropertyFlags _desiredProperties; // if set will narrow scopes of copy/to/from to just these properties }; diff --git a/libraries/model/src/model/TextureMap.h b/libraries/model/src/model/TextureMap.h index 795b685f27..ac35db2f03 100755 --- a/libraries/model/src/model/TextureMap.h +++ b/libraries/model/src/model/TextureMap.h @@ -59,6 +59,7 @@ public: TextureMap() {} void setTextureSource(gpu::TextureSourcePointer& textureSource); + gpu::TextureSourcePointer getTextureSource() const { return _textureSource; } bool isDefined() const; gpu::TextureView getTextureView() const; diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index 42dd41c739..3e891bffe2 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -71,8 +71,37 @@ void MeshPartPayload::updateTransform(const Transform& transform, const Transfor void MeshPartPayload::updateMaterial(model::MaterialPointer drawMaterial) { _drawMaterial = drawMaterial; + calculateMaterialSize(); } +bool MeshPartPayload::calculateMaterialSize() { + bool allTextures = true; // assume we got this... + _materialTextureSize = 0; + auto textureMaps = _drawMaterial->getTextureMaps(); + for (auto const &textureMapItem : textureMaps) { + auto textureMap = textureMapItem.second; + if (textureMap) { + auto textureSoure = textureMap->getTextureSource(); + if (textureSoure) { + auto texture = textureSoure->getGPUTexture(); + if (texture) { + //auto storedSize = texture->getStoredSize(); + auto size = texture->getSize(); + _materialTextureSize += size; + } else { + allTextures = false; + } + } else { + allTextures = false; + } + } else { + allTextures = false; + } + } + return allTextures; +} + + ItemKey MeshPartPayload::getKey() const { ItemKey::Builder builder; builder.withTypeShape(); @@ -347,8 +376,8 @@ void ModelMeshPartPayload::initCache() { auto networkMaterial = _model->getGeometry()->getShapeMaterial(_shapeID); if (networkMaterial) { _drawMaterial = networkMaterial; - }; - + calculateMaterialSize(); + } } void ModelMeshPartPayload::notifyLocationChanged() { diff --git a/libraries/render-utils/src/MeshPartPayload.h b/libraries/render-utils/src/MeshPartPayload.h index a934863846..f7ea77beba 100644 --- a/libraries/render-utils/src/MeshPartPayload.h +++ b/libraries/render-utils/src/MeshPartPayload.h @@ -64,6 +64,13 @@ public: mutable model::Box _worldBound; bool _hasColorAttrib = false; + + size_t getVerticesCount() const { return _drawMesh ? _drawMesh->getNumVertices() : 0; } + size_t getMaterialTextureSize() { return _materialTextureSize; } + bool calculateMaterialSize(); + +protected: + size_t _materialTextureSize { 0 }; }; namespace render { diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 3a7308c277..ebf5cb4327 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -161,6 +161,23 @@ void Model::setOffset(const glm::vec3& offset) { _snappedToRegistrationPoint = false; } +size_t Model::getRenderInfoTextureSize() { + if (!_hasCalculatedTextureSize && isLoaded() && getGeometry()->areTexturesLoaded()) { + size_t textureSize = 0; + bool allTexturesLoaded = true; + foreach(auto renderItem, _modelMeshRenderItemsSet) { + auto meshPart = renderItem.get(); + bool allTexturesForThisMesh = meshPart->calculateMaterialSize(); + allTexturesLoaded = allTexturesLoaded & allTexturesForThisMesh; + textureSize += meshPart->getMaterialTextureSize(); + } + _renderInfoTextureSize = textureSize; + _hasCalculatedTextureSize = allTexturesLoaded; // only do this once + } + return _renderInfoTextureSize; +} + + void Model::updateRenderItems() { if (!_addedToScene) { return; @@ -615,16 +632,26 @@ bool Model::addToScene(std::shared_ptr scene, } } else { if (_modelMeshRenderItems.empty()) { - foreach (auto renderItem, _modelMeshRenderItemsSet) { + + bool hasTransparent = false; + size_t verticesCount = 0; + foreach(auto renderItem, _modelMeshRenderItemsSet) { auto item = scene->allocateID(); auto renderPayload = std::make_shared(renderItem); if (statusGetters.size()) { renderPayload->addStatusGetters(statusGetters); } pendingChanges.resetItem(item, renderPayload); + + hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent(); + verticesCount += renderItem.get()->getVerticesCount(); _modelMeshRenderItems.insert(item, renderPayload); } somethingAdded = !_modelMeshRenderItems.empty(); + + _renderInfoVertexCount = verticesCount; + _renderInfoDrawCalls = _modelMeshRenderItems.count(); + _renderInfoHasTransparent = hasTransparent; } } @@ -650,6 +677,11 @@ void Model::removeFromScene(std::shared_ptr scene, render::Pendin _collisionRenderItems.clear(); _collisionRenderItemsSet.clear(); _addedToScene = false; + + _renderInfoVertexCount = 0; + _renderInfoDrawCalls = 0; + _renderInfoTextureSize = 0; + _renderInfoHasTransparent = false; } void Model::renderDebugMeshBoxes(gpu::Batch& batch) { @@ -1332,13 +1364,21 @@ bool Model::initWhenReady(render::ScenePointer scene) { } addedPendingChanges = !_collisionRenderItems.empty(); } else { + bool hasTransparent = false; + size_t verticesCount = 0; foreach (auto renderItem, _modelMeshRenderItemsSet) { auto item = scene->allocateID(); auto renderPayload = std::make_shared(renderItem); + + hasTransparent = hasTransparent || renderItem.get()->getShapeKey().isTranslucent(); + verticesCount += renderItem.get()->getVerticesCount(); _modelMeshRenderItems.insert(item, renderPayload); pendingChanges.resetItem(item, renderPayload); } addedPendingChanges = !_modelMeshRenderItems.empty(); + _renderInfoVertexCount = verticesCount; + _renderInfoDrawCalls = _modelMeshRenderItems.count(); + _renderInfoHasTransparent = hasTransparent; } _addedToScene = addedPendingChanges; if (addedPendingChanges) { diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index 7a193b1d47..1b16892296 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -232,6 +232,12 @@ public: void setLoadingPriority(float priority) { _loadingPriority = priority; } + size_t getRenderInfoVertexCount() const { return _renderInfoVertexCount; } + int getRenderInfoTextureCount() const { return _renderInfoTextureCount; } + size_t getRenderInfoTextureSize(); + int getRenderInfoDrawCalls() const { return _renderInfoDrawCalls; } + bool getRenderInfoHasTransparent() const { return _renderInfoHasTransparent; } + public slots: void loadURLFinished(bool success); @@ -400,6 +406,13 @@ protected: bool _renderItemsNeedUpdate { false }; + size_t _renderInfoVertexCount { 0 }; + int _renderInfoTextureCount { 0 }; + size_t _renderInfoTextureSize { 0 }; + bool _hasCalculatedTextureSize { false }; + int _renderInfoDrawCalls { 0 }; + int _renderInfoHasTransparent { false }; + private: float _loadingPriority { 0.0f }; From a8a95778662afdc3b06e6afa89acb8107331da1d Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 31 Aug 2016 21:14:50 -0700 Subject: [PATCH 19/20] actually remove the math.random --- scripts/defaultScripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 1d0a955336..f9cd32be46 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -64,7 +64,7 @@ if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_I function runDefaultsTogether() { for (var j in DEFAULT_SCRIPTS) { - Script.include(DEFAULT_SCRIPTS[j] + "?" + Math.random()); + Script.include(DEFAULT_SCRIPTS[j]); } } From 2c8b795c5f2a8898ff312d49d1c08855fe16492a Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 30 Aug 2016 14:48:04 -0700 Subject: [PATCH 20/20] Fix incorrect fence delete --- libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp b/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp index 9b933cfb90..1d22ae7a52 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTextureTransfer.cpp @@ -104,7 +104,7 @@ bool GLTextureTransferHelper::processQueueItems(const Queue& messages) { QThread::usleep(1); result = glClientWaitSync(fence, 0, 0); } - glDeleteSync(package.fence); + glDeleteSync(fence); } object->_contentStamp = texturePointer->getDataStamp();