From 6b34b0971f4f63cde025309237611b587f9b1472 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Fri, 14 Jun 2019 11:09:28 -0700 Subject: [PATCH 01/14] Enable KHR_robustness option --- CMakeLists.txt | 5 +++ libraries/gl/src/gl/Context.cpp | 55 +++++++++++++++++++++------------ libraries/gl/src/gl/Context.h | 2 +- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f6cffb7c1..9876a0d7ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,6 +139,7 @@ option(BUILD_MANUAL_TESTS "Build manual tests" ${BUILD_MANUAL_TESTS_OPTION}) option(BUILD_TOOLS "Build tools" ${BUILD_TOOLS_OPTION}) option(BUILD_INSTALLER "Build installer" ${BUILD_INSTALLER_OPTION}) option(USE_GLES "Use OpenGL ES" ${GLES_OPTION}) +option(USE_KHR_ROBUSTNESS "Use KHR_robustness" OFF) option(DISABLE_QML "Disable QML" ${DISABLE_QML_OPTION}) option(DISABLE_KTX_CACHE "Disable KTX Cache" OFF) option( @@ -149,6 +150,10 @@ option( set(PLATFORM_QT_GL OpenGL) +if (USE_KHR_ROBUSTNESS) + add_definitions(-DUSE_KHR_ROBUSTNESS) +endif() + if (USE_GLES) add_definitions(-DUSE_GLES) add_definitions(-DGPU_POINTER_STORAGE_SHARED) diff --git a/libraries/gl/src/gl/Context.cpp b/libraries/gl/src/gl/Context.cpp index a0d52ee223..d5d06d1195 100644 --- a/libraries/gl/src/gl/Context.cpp +++ b/libraries/gl/src/gl/Context.cpp @@ -27,6 +27,10 @@ #include "GLHelpers.h" #include "QOpenGLContextWrapper.h" +#if defined(GL_CUSTOM_CONTEXT) +#include +#endif + using namespace gl; #if defined(GL_CUSTOM_CONTEXT) @@ -42,7 +46,10 @@ std::atomic Context::_totalSwapchainMemoryUsage { 0 }; size_t Context::getSwapchainMemoryUsage() { return _totalSwapchainMemoryUsage.load(); } size_t Context::evalSurfaceMemoryUsage(uint32_t width, uint32_t height, uint32_t pixelSize) { - return width * height * pixelSize; + size_t result = width; + result *= height; + result *= pixelSize; + return result; } void Context::updateSwapchainMemoryUsage(size_t prevSize, size_t newSize) { @@ -126,7 +133,7 @@ void Context::clear() { #if defined(GL_CUSTOM_CONTEXT) static void setupPixelFormatSimple(HDC hdc) { - // FIXME build the PFD based on the + // FIXME build the PFD based on the static const PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor @@ -176,6 +183,7 @@ static void setupPixelFormatSimple(HDC hdc) { #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 // Context create flag bits +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 @@ -196,17 +204,17 @@ GLAPI PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); #if defined(GL_CUSTOM_CONTEXT) -bool Context::makeCurrent() { - BOOL result = wglMakeCurrent(_hdc, _hglrc); - assert(result); - updateSwapchainMemoryCounter(); - return result; -} - void Context::swapBuffers() { - SwapBuffers(_hdc); -} - void Context::doneCurrent() { - wglMakeCurrent(0, 0); +bool Context::makeCurrent() { + BOOL result = wglMakeCurrent(_hdc, _hglrc); + assert(result); + updateSwapchainMemoryCounter(); + return result; +} +void Context::swapBuffers() { + SwapBuffers(_hdc); +} +void Context::doneCurrent() { + wglMakeCurrent(0, 0); } #endif @@ -305,11 +313,18 @@ void Context::create(QOpenGLContext* shareContext) { #else contextAttribs.push_back(WGL_CONTEXT_CORE_PROFILE_BIT_ARB); #endif - contextAttribs.push_back(WGL_CONTEXT_FLAGS_ARB); - if (enableDebugLogger()) { - contextAttribs.push_back(WGL_CONTEXT_DEBUG_BIT_ARB); - } else { - contextAttribs.push_back(0); + { + int contextFlags = 0; + if (enableDebugLogger()) { + contextFlags |= WGL_CONTEXT_DEBUG_BIT_ARB; + } +#ifdef USE_KHR_ROBUSTNESS + contextFlags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB; +#endif + if (contextFlags != 0) { + contextAttribs.push_back(WGL_CONTEXT_FLAGS_ARB); + contextAttribs.push_back(contextFlags); + } } contextAttribs.push_back(0); HGLRC shareHglrc = nullptr; @@ -323,8 +338,8 @@ void Context::create(QOpenGLContext* shareContext) { if (_hglrc != 0) { createWrapperContext(); } - } - + } + if (_hglrc == 0) { // fallback, if the context creation failed, or USE_CUSTOM_CONTEXT is false qtCreate(shareContext); diff --git a/libraries/gl/src/gl/Context.h b/libraries/gl/src/gl/Context.h index 5254d58d38..7beb59e33f 100644 --- a/libraries/gl/src/gl/Context.h +++ b/libraries/gl/src/gl/Context.h @@ -23,7 +23,7 @@ class QOpenGLContext; class QThread; class QOpenGLDebugMessage; -#if defined(Q_OS_WIN) && defined(USE_GLES) +#if defined(Q_OS_WIN) && (defined(USE_GLES) || defined(USE_KHR_ROBUSTNESS)) //#if defined(Q_OS_WIN) #define GL_CUSTOM_CONTEXT #endif From f2e3218ec0a230648eb6128bc40fcf45ad21f0f1 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 19 Jun 2019 16:34:38 -0700 Subject: [PATCH 02/14] possible fix for do_setPipeline crash and other mac fixes --- .../display-plugins/OpenGLDisplayPlugin.cpp | 16 ++-------- .../src/display-plugins/OpenGLDisplayPlugin.h | 3 +- .../display-plugins/hmd/HmdDisplayPlugin.cpp | 31 +++++++------------ .../display-plugins/hmd/HmdDisplayPlugin.h | 7 ++--- .../physics/src/PhysicalEntitySimulation.cpp | 30 +++++++++--------- .../physics/src/ThreadSafeDynamicsWorld.cpp | 2 +- .../plugins/src/plugins/DisplayPlugin.cpp | 9 ------ libraries/plugins/src/plugins/DisplayPlugin.h | 5 +-- .../render-utils/src/RenderCommonTask.cpp | 2 +- libraries/render/src/render/Args.h | 16 +++++----- 10 files changed, 45 insertions(+), 76 deletions(-) diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index aa1233ce22..73bc1d0aad 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -593,9 +593,10 @@ std::function OpenGL hudEyeViewports[eye] = eyeViewport(eye); }); return [=](gpu::Batch& batch, const gpu::TexturePointer& hudTexture, bool mirror) { - if (hudPipeline && hudTexture) { + auto pipeline = mirror ? hudMirrorPipeline : hudPipeline; + if (pipeline && hudTexture) { batch.enableStereo(false); - batch.setPipeline(mirror ? hudMirrorPipeline : hudPipeline); + batch.setPipeline(pipeline); batch.setResourceTexture(0, hudTexture); if (hudStereo) { for_each_eye([&](Eye eye) { @@ -661,17 +662,6 @@ void OpenGLDisplayPlugin::compositeLayers() { compositeScene(); } -#ifdef HIFI_ENABLE_NSIGHT_DEBUG - if (false) // do not draw the HUD if running nsight debug -#endif - { - PROFILE_RANGE_EX(render_detail, "handleHUDBatch", 0xff0077ff, (uint64_t)presentCount()) - auto hudOperator = getHUDOperator(); - withPresentThreadLock([&] { - _hudOperator = hudOperator; - }); - } - { PROFILE_RANGE_EX(render_detail, "compositeExtra", 0xff0077ff, (uint64_t)presentCount()) compositeExtra(); diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h index 672d9a4beb..eae9f86710 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h @@ -86,6 +86,8 @@ public: void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target, GLsync* fenceSync) override; + virtual std::function getHUDOperator() override; + protected: friend class PresentThread; @@ -102,7 +104,6 @@ protected: virtual QThread::Priority getPresentPriority() { return QThread::HighPriority; } virtual void compositeLayers(); virtual void compositeScene(); - virtual std::function getHUDOperator(); virtual void compositePointer(); virtual void compositeExtra() {}; diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp index 874454b391..3952c2c90e 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp @@ -1,4 +1,4 @@ -// +// // Created by Bradley Austin Davis on 2016/02/15 // Copyright 2016 High Fidelity, Inc. // @@ -402,25 +402,18 @@ void HmdDisplayPlugin::HUDRenderer::build() { format->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); format->setAttribute(gpu::Stream::TEXCOORD, gpu::Stream::TEXCOORD, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV)); uniformsBuffer = std::make_shared(sizeof(Uniforms), nullptr); - updatePipeline(); + + auto program = gpu::Shader::createProgram(shader::render_utils::program::hmd_ui); + gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + state->setDepthTest(gpu::State::DepthTest(true, true, gpu::LESS_EQUAL)); + state->setBlendFunction(true, + gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, + gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); + + pipeline = gpu::Pipeline::create(program, state); } -void HmdDisplayPlugin::HUDRenderer::updatePipeline() { - if (!pipeline) { - auto program = gpu::Shader::createProgram(shader::render_utils::program::hmd_ui); - gpu::StatePointer state = gpu::StatePointer(new gpu::State()); - state->setDepthTest(gpu::State::DepthTest(true, true, gpu::LESS_EQUAL)); - state->setBlendFunction(true, - gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, - gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); - - pipeline = gpu::Pipeline::create(program, state); - } -} - -std::function HmdDisplayPlugin::HUDRenderer::render(HmdDisplayPlugin& plugin) { - updatePipeline(); - +std::function HmdDisplayPlugin::HUDRenderer::render() { auto hudPipeline = pipeline; auto hudFormat = format; auto hudVertices = vertices; @@ -479,7 +472,7 @@ void HmdDisplayPlugin::compositePointer() { } std::function HmdDisplayPlugin::getHUDOperator() { - return _hudRenderer.render(*this); + return _hudRenderer.render(); } HmdDisplayPlugin::~HmdDisplayPlugin() { diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h index e952b1e8db..9942222f48 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h @@ -48,6 +48,7 @@ public: void pluginUpdate() override {}; + std::function getHUDOperator() override; virtual StencilMaskMode getStencilMaskMode() const override { return StencilMaskMode::PAINT; } signals: @@ -62,7 +63,6 @@ protected: bool internalActivate() override; void internalDeactivate() override; - std::function getHUDOperator() override; void compositePointer() override; void internalPresent() override; void customizeContext() override; @@ -105,7 +105,7 @@ private: gpu::BufferPointer vertices; gpu::BufferPointer indices; uint32_t indexCount { 0 }; - gpu::PipelinePointer pipeline; + gpu::PipelinePointer pipeline { nullptr }; gpu::BufferPointer uniformsBuffer; @@ -123,7 +123,6 @@ private: static const int VERTEX_STRIDE { sizeof(Vertex) }; void build(); - void updatePipeline(); - std::function render(HmdDisplayPlugin& plugin); + std::function render(); } _hudRenderer; }; diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index f532d5209f..0a08aaa28d 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -309,20 +309,28 @@ void PhysicalEntitySimulation::buildMotionStatesForEntitiesThatNeedThem() { SetOfEntities::iterator entityItr = _entitiesToAddToPhysics.begin(); while (entityItr != _entitiesToAddToPhysics.end()) { EntityItemPointer entity = (*entityItr); - assert(!entity->getPhysicsInfo()); if (entity->isDead()) { prepareEntityForDelete(entity); entityItr = _entitiesToAddToPhysics.erase(entityItr); - } else if (!entity->shouldBePhysical()) { - // this entity should no longer be on _entitiesToAddToPhysics + continue; + } + if (entity->getPhysicsInfo()) { entityItr = _entitiesToAddToPhysics.erase(entityItr); + continue; + } + if (!entity->shouldBePhysical()) { + // this entity should no longer be on _entitiesToAddToPhysics if (entity->isMovingRelativeToParent()) { SetOfEntities::iterator itr = _simpleKinematicEntities.find(entity); if (itr == _simpleKinematicEntities.end()) { _simpleKinematicEntities.insert(entity); } } - } else if (entity->isReadyToComputeShape()) { + entityItr = _entitiesToAddToPhysics.erase(entityItr); + continue; + } + + if (entity->isReadyToComputeShape()) { ShapeRequest shapeRequest(entity); ShapeRequests::iterator requestItr = _shapeRequests.find(shapeRequest); if (requestItr == _shapeRequests.end()) { @@ -332,18 +340,7 @@ void PhysicalEntitySimulation::buildMotionStatesForEntitiesThatNeedThem() { uint32_t requestCount = ObjectMotionState::getShapeManager()->getWorkRequestCount(); btCollisionShape* shape = const_cast(ObjectMotionState::getShapeManager()->getShape(shapeInfo)); if (shape) { - EntityMotionState* motionState = static_cast(entity->getPhysicsInfo()); - if (!motionState) { - buildMotionState(shape, entity); - } else { - // Is it possible to fall in here? - // entity shouldn't be on _entitiesToAddToPhysics list if it already has a motionState. - // but just in case... - motionState->setShape(shape); - motionState->setRegion(_space->getRegion(entity->getSpaceIndex())); - _physicalObjects.insert(motionState); - _incomingChanges.insert(motionState); - } + buildMotionState(shape, entity); } else if (requestCount != ObjectMotionState::getShapeManager()->getWorkRequestCount()) { // shape doesn't exist but a new worker has been spawned to build it --> add to shapeRequests and wait shapeRequest.shapeHash = shapeInfo.getHash(); @@ -354,6 +351,7 @@ void PhysicalEntitySimulation::buildMotionStatesForEntitiesThatNeedThem() { } entityItr = _entitiesToAddToPhysics.erase(entityItr); } else { + // skip for later ++entityItr; } } diff --git a/libraries/physics/src/ThreadSafeDynamicsWorld.cpp b/libraries/physics/src/ThreadSafeDynamicsWorld.cpp index f6189121a9..00b8a71831 100644 --- a/libraries/physics/src/ThreadSafeDynamicsWorld.cpp +++ b/libraries/physics/src/ThreadSafeDynamicsWorld.cpp @@ -181,7 +181,7 @@ void ThreadSafeDynamicsWorld::drawConnectedSpheres(btIDebugDraw* drawer, btScala btVector3 xAxis = direction.cross(btVector3(0.0f, 1.0f, 0.0f)); xAxis = xAxis.length() < EPSILON ? btVector3(1.0f, 0.0f, 0.0f) : xAxis.normalize(); btVector3 zAxis = xAxis.cross(btVector3(0.0f, 1.0f, 0.0f)); - zAxis = (direction.normalize().getY() < EPSILON) ? btVector3(0.0f, 1.0f, 0.0f) : zAxis.normalize(); + zAxis = (direction.length2() < EPSILON || direction.normalize().getY() < EPSILON) ? btVector3(0.0f, 1.0f, 0.0f) : zAxis.normalize(); float fullCircle = 2.0f * PI; for (float i = 0; i < fullCircle; i += stepRadians) { float x1 = btSin(btScalar(i)) * radius1; diff --git a/libraries/plugins/src/plugins/DisplayPlugin.cpp b/libraries/plugins/src/plugins/DisplayPlugin.cpp index 47503e8f85..2fe3d5fbea 100644 --- a/libraries/plugins/src/plugins/DisplayPlugin.cpp +++ b/libraries/plugins/src/plugins/DisplayPlugin.cpp @@ -35,15 +35,6 @@ void DisplayPlugin::waitForPresent() { } } -std::function DisplayPlugin::getHUDOperator() { - std::function hudOperator; - { - QMutexLocker locker(&_presentMutex); - hudOperator = _hudOperator; - } - return hudOperator; -} - glm::mat4 HmdDisplay::getEyeToHeadTransform(Eye eye) const { static const glm::mat4 xform; return xform; diff --git a/libraries/plugins/src/plugins/DisplayPlugin.h b/libraries/plugins/src/plugins/DisplayPlugin.h index 9dc1d7002d..1cad9b1e11 100644 --- a/libraries/plugins/src/plugins/DisplayPlugin.h +++ b/libraries/plugins/src/plugins/DisplayPlugin.h @@ -213,13 +213,12 @@ public: void waitForPresent(); float getAveragePresentTime() { return _movingAveragePresent.average / (float)USECS_PER_MSEC; } // in msec - std::function getHUDOperator(); - static const QString& MENU_PATH(); // for updating plugin-related commands. Mimics the input plugin. virtual void pluginUpdate() = 0; + virtual std::function getHUDOperator() { return nullptr; } virtual StencilMaskMode getStencilMaskMode() const { return StencilMaskMode::NONE; } using StencilMaskMeshOperator = std::function; virtual StencilMaskMeshOperator getStencilMaskMeshOperator() { return nullptr; } @@ -234,8 +233,6 @@ protected: gpu::ContextPointer _gpuContext; - std::function _hudOperator { std::function() }; - MovingAverage _movingAveragePresent; float _renderResolutionScale { 1.0f }; diff --git a/libraries/render-utils/src/RenderCommonTask.cpp b/libraries/render-utils/src/RenderCommonTask.cpp index 18532b7a66..ae53539770 100644 --- a/libraries/render-utils/src/RenderCommonTask.cpp +++ b/libraries/render-utils/src/RenderCommonTask.cpp @@ -111,7 +111,7 @@ void CompositeHUD::run(const RenderContextPointer& renderContext, const gpu::Fra assert(renderContext->args->_context); // We do not want to render HUD elements in secondary camera - if (renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) { + if (nsightActive() || renderContext->args->_renderMode == RenderArgs::RenderMode::SECONDARY_CAMERA_RENDER_MODE) { return; } diff --git a/libraries/render/src/render/Args.h b/libraries/render/src/render/Args.h index 7821692a60..1798208981 100644 --- a/libraries/render/src/render/Args.h +++ b/libraries/render/src/render/Args.h @@ -124,20 +124,20 @@ namespace render { DebugFlags _debugFlags { RENDER_DEBUG_NONE }; gpu::Batch* _batch = nullptr; - uint32_t _globalShapeKey{ 0 }; - uint32_t _itemShapeKey{ 0 }; - bool _enableTexturing{ true }; - bool _enableBlendshape{ true }; - bool _enableSkinning{ true }; + uint32_t _globalShapeKey { 0 }; + uint32_t _itemShapeKey { 0 }; + bool _enableTexturing { true }; + bool _enableBlendshape { true }; + bool _enableSkinning { true }; - bool _enableFade{ false }; + bool _enableFade { false }; RenderDetails _details; render::ScenePointer _scene; int8_t _cameraMode { -1 }; - std::function _hudOperator; - gpu::TexturePointer _hudTexture; + std::function _hudOperator { nullptr }; + gpu::TexturePointer _hudTexture { nullptr }; bool _takingSnapshot { false }; StencilMaskMode _stencilMaskMode { StencilMaskMode::NONE }; From 53094ef70c93f6458e10b60618036046443809a3 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 19 Jun 2019 16:52:33 -0700 Subject: [PATCH 03/14] One more pass of clean up on the platform api, returning the complete description in a single call, adding the version of the OS and deprecating legacy PlatformInfo calls --- .../PlatformInfoScriptingInterface.cpp | 6 +- .../PlatformInfoScriptingInterface.h | 24 ++++- libraries/platform/src/platform/Platform.h | 7 +- .../platform/src/platform/PlatformKeys.h | 18 +++- .../src/platform/backend/AndroidPlatform.cpp | 22 +++-- .../src/platform/backend/AndroidPlatform.h | 6 +- .../src/platform/backend/LinuxPlatform.cpp | 21 +++-- .../src/platform/backend/LinuxPlatform.h | 6 +- .../src/platform/backend/MACOSPlatform.cpp | 21 +++-- .../src/platform/backend/MACOSPlatform.h | 8 +- .../src/platform/backend/Platform.cpp | 29 ++++-- .../src/platform/backend/PlatformInstance.cpp | 89 ++++++++++++------- .../src/platform/backend/PlatformInstance.h | 33 +++---- .../src/platform/backend/WINPlatform.cpp | 20 +++-- .../src/platform/backend/WINPlatform.h | 4 +- libraries/shared/src/GPUIdent.cpp | 9 +- 16 files changed, 211 insertions(+), 112 deletions(-) diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index 9a5a08503d..84c4d923d0 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -192,7 +192,7 @@ QString PlatformInfoScriptingInterface::getDisplay(int index) { } QString PlatformInfoScriptingInterface::getMemory() { - auto desc = platform::getMemory(0); + auto desc = platform::getMemory(); return QString(desc.dump().c_str()); } @@ -201,6 +201,10 @@ QString PlatformInfoScriptingInterface::getComputer() { return QString(desc.dump().c_str()); } +QString PlatformInfoScriptingInterface::getPlatform() { + auto desc = platform::getAll(); + return QString(desc.dump().c_str()); +} PlatformInfoScriptingInterface::PlatformTier PlatformInfoScriptingInterface::getTierProfiled() { return (PlatformInfoScriptingInterface::PlatformTier) platform::Profiler::profilePlatform(); diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index 476c5c5788..113509d6d9 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -51,6 +51,8 @@ public slots: * Gets the operating system type. * @function PlatformInfo.getOperatingSystemType * @returns {string} "WINDOWS", "MACOS", or "UNKNOWN". + * @deprecated This function is deprecated and will be removed. + * use getComputer()["OS"] instead */ QString getOperatingSystemType(); @@ -61,6 +63,10 @@ public slots: * @example Report the CPU being used. * print("CPU: " + PlatformInfo.getCPUBrand()); * // Example: Intel(R) Core(TM) i7-7820HK CPU @ 2.90GHz + * @deprecated This function is deprecated and will be removed. + * use getNumCPUs() to know the number of CPUs in the hardware, at least one is expected + * use getCPU(0)["vendor"] to get the brand of the vendor + * use getCPU(0)["model"] to get the model name of the cpu */ QString getCPUBrand(); @@ -68,6 +74,8 @@ public slots: * Gets the number of logical CPU cores. * @function PlatformInfo.getNumLogicalCores * @returns {number} The number of logical CPU cores. + * @deprecated This function is deprecated and will be removed. + * use getCPU(0)["numCores"] instead */ unsigned int getNumLogicalCores(); @@ -75,6 +83,8 @@ public slots: * Returns the total system memory in megabytes. * @function PlatformInfo.getTotalSystemMemoryMB * @returns {number} The total system memory in megabytes. + * @deprecated This function is deprecated and will be removed. + * use getMemory()["memTotal"] instead */ int getTotalSystemMemoryMB(); @@ -82,6 +92,10 @@ public slots: * Gets the graphics card type. * @function PlatformInfo.getGraphicsCardType * @returns {string} The graphics card type. + * @deprecated This function is deprecated and will be removed. + * use getNumGPUs() to know the number of GPUs in the hardware, at least one is expected + * use getGPU(0)["vendor"] to get the brand of the vendor + * use getGPU(0)["model"] to get the model name of the gpu */ QString getGraphicsCardType(); @@ -141,7 +155,7 @@ public slots: /**jsdoc * Get the description of the GPU at the index parameter * expected fields are: - * - gpuVendor... + * - vendor, model... * @param index The index of the GPU of the platform * @function PlatformInfo.getGPU * @returns {string} The GPU description json field @@ -183,6 +197,14 @@ public slots: */ QString getComputer(); + /**jsdoc + * Get the complete description of the Platform as an aggregated Json + * The expected object description is: + * { "computer": {...}, "memory": {...}, "cpus": [{...}, ...], "gpus": [{...}, ...], "displays": [{...}, ...] } + * @function PlatformInfo.getPlatform + * @returns {string} The Platform description json field + */ + QString getPlatform(); /**jsdoc * Get the Platform TIer profiled on startup of the Computer diff --git a/libraries/platform/src/platform/Platform.h b/libraries/platform/src/platform/Platform.h index 7f73ff4ff4..9405c77ae0 100644 --- a/libraries/platform/src/platform/Platform.h +++ b/libraries/platform/src/platform/Platform.h @@ -27,12 +27,13 @@ json getGPU(int index); int getNumDisplays(); json getDisplay(int index); - -int getNumMemories(); -json getMemory(int index); + +json getMemory(); json getComputer(); +json getAll(); + } // namespace platform #endif // hifi_platform_h diff --git a/libraries/platform/src/platform/PlatformKeys.h b/libraries/platform/src/platform/PlatformKeys.h index fd29b2ff7f..1008c5ca4b 100644 --- a/libraries/platform/src/platform/PlatformKeys.h +++ b/libraries/platform/src/platform/PlatformKeys.h @@ -9,6 +9,9 @@ #define hifi_platform_PlatformKeys_h namespace platform { namespace keys{ + // "UNKNOWN" + extern const char* UNKNOWN; + namespace cpu { extern const char* vendor; extern const char* vendor_Intel; @@ -36,8 +39,9 @@ namespace platform { namespace keys{ extern const char* coordsTop; extern const char* coordsBottom; } + namespace memory { extern const char* memTotal; - + } namespace computer { extern const char* OS; extern const char* OS_WINDOWS; @@ -45,6 +49,8 @@ namespace platform { namespace keys{ extern const char* OS_LINUX; extern const char* OS_ANDROID; + extern const char* OSVersion; + extern const char* vendor; extern const char* vendor_Apple; @@ -52,6 +58,14 @@ namespace platform { namespace keys{ extern const char* profileTier; } - } } // namespace plaform::keys + + // Keys for categories used in json returned by getAll() + extern const char* CPUS; + extern const char* GPUS; + extern const char* DISPLAYS; + extern const char* MEMORY; + extern const char* COMPUTER; + +} } // namespace plaform::keys #endif diff --git a/libraries/platform/src/platform/backend/AndroidPlatform.cpp b/libraries/platform/src/platform/backend/AndroidPlatform.cpp index ee5a7e39b9..b0a4c5e67b 100644 --- a/libraries/platform/src/platform/backend/AndroidPlatform.cpp +++ b/libraries/platform/src/platform/backend/AndroidPlatform.cpp @@ -9,39 +9,45 @@ #include "AndroidPlatform.h" #include "../PlatformKeys.h" #include +#include using namespace platform; -void AndroidInstance::enumerateCpu() { +void AndroidInstance::enumerateCpus() { json cpu; cpu[keys::cpu::vendor] = ""; cpu[keys::cpu::model] = ""; cpu[keys::cpu::clockSpeed] = ""; cpu[keys::cpu::numCores] = 0; - _cpu.push_back(cpu); + + _cpus.push_back(cpu); } -void AndroidInstance::enumerateGpu() { +void AndroidInstance::enumerateGpus() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu[keys::gpu::vendor] = ident->getName().toUtf8().constData(); gpu[keys::gpu::model] = ident->getName().toUtf8().constData(); + gpu[keys::gpu::vendor] = findGPUVendorInDescription(gpu[keys::gpu::model].get()); gpu[keys::gpu::videoMemory] = ident->getMemory(); gpu[keys::gpu::driver] = ident->getDriver().toUtf8().constData(); - _gpu.push_back(gpu); - _display = ident->getOutput(); + _gpus.push_back(gpu); + _displays = ident->getOutput(); } void AndroidInstance::enumerateMemory() { json ram = {}; - ram[keys::memTotal]=0; - _memory.push_back(ram); + ram[keys::memory::memTotal]=0; + _memory = ram; } void AndroidInstance::enumerateComputer(){ _computer[keys::computer::OS] = keys::computer::OS_ANDROID; _computer[keys::computer::vendor] = ""; _computer[keys::computer::model] = ""; + + auto sysInfo = QSysInfo(); + + _computer[keys::computer::OSVersion] = sysInfo.kernelVersion().toStdString(); } diff --git a/libraries/platform/src/platform/backend/AndroidPlatform.h b/libraries/platform/src/platform/backend/AndroidPlatform.h index d1496383c0..6592b3519d 100644 --- a/libraries/platform/src/platform/backend/AndroidPlatform.h +++ b/libraries/platform/src/platform/backend/AndroidPlatform.h @@ -15,10 +15,10 @@ namespace platform { class AndroidInstance : public Instance { public: - void enumerateCpu() override; + void enumerateCpus() override; + void enumerateGpus() override; void enumerateMemory() override; - void enumerateGpu() override; - void enumerateComputer () override; + void enumerateComputer() override; }; } // namespace platform diff --git a/libraries/platform/src/platform/backend/LinuxPlatform.cpp b/libraries/platform/src/platform/backend/LinuxPlatform.cpp index 356df27e0a..61501669cb 100644 --- a/libraries/platform/src/platform/backend/LinuxPlatform.cpp +++ b/libraries/platform/src/platform/backend/LinuxPlatform.cpp @@ -13,36 +13,37 @@ #include #include #include +#include using namespace platform; -void LinuxInstance::enumerateCpu() { +void LinuxInstance::enumerateCpus() { json cpu = {}; cpu[keys::cpu::vendor] = CPUIdent::Vendor(); cpu[keys::cpu::model] = CPUIdent::Brand(); cpu[keys::cpu::numCores] = std::thread::hardware_concurrency(); - _cpu.push_back(cpu); + _cpus.push_back(cpu); } -void LinuxInstance::enumerateGpu() { +void LinuxInstance::enumerateGpus() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu[keys::gpu::vendor] = ident->getName().toUtf8().constData(); gpu[keys::gpu::model] = ident->getName().toUtf8().constData(); + gpu[keys::gpu::vendor] = findGPUVendorInDescription(gpu[keys::gpu::model].get()); gpu[keys::gpu::videoMemory] = ident->getMemory(); gpu[keys::gpu::driver] = ident->getDriver().toUtf8().constData(); - _gpu.push_back(gpu); - _display = ident->getOutput(); + _gpus.push_back(gpu); + _displays = ident->getOutput(); } void LinuxInstance::enumerateMemory() { json ram = {}; - ram[keys::memTotal]=0; + ram[keys::memory::memTotal]=0; - _memory.push_back(ram); + _memory = ram; } void LinuxInstance::enumerateComputer(){ @@ -50,5 +51,9 @@ void LinuxInstance::enumerateComputer(){ _computer[keys::computer::OS] = keys::computer::OS_LINUX; _computer[keys::computer::vendor] = ""; _computer[keys::computer::model] = ""; + + auto sysInfo = QSysInfo(); + + _computer[keys::computer::OSVersion] = sysInfo.kernelVersion().toStdString(); } diff --git a/libraries/platform/src/platform/backend/LinuxPlatform.h b/libraries/platform/src/platform/backend/LinuxPlatform.h index 1629101f41..2f2529db7c 100644 --- a/libraries/platform/src/platform/backend/LinuxPlatform.h +++ b/libraries/platform/src/platform/backend/LinuxPlatform.h @@ -15,10 +15,10 @@ namespace platform { class LinuxInstance : public Instance { public: - void enumerateCpu() override; + void enumerateCpus() override; + void enumerateGpus() override; void enumerateMemory() override; - void enumerateGpu() override; - void enumerateComputer () override; + void enumerateComputer() override; }; } // namespace platform diff --git a/libraries/platform/src/platform/backend/MACOSPlatform.cpp b/libraries/platform/src/platform/backend/MACOSPlatform.cpp index 7dbc403783..cacbd06816 100644 --- a/libraries/platform/src/platform/backend/MACOSPlatform.cpp +++ b/libraries/platform/src/platform/backend/MACOSPlatform.cpp @@ -21,32 +21,33 @@ #include #include +#include #endif using namespace platform; -void MACOSInstance::enumerateCpu() { +void MACOSInstance::enumerateCpus() { json cpu = {}; cpu[keys::cpu::vendor] = CPUIdent::Vendor(); cpu[keys::cpu::model] = CPUIdent::Brand(); cpu[keys::cpu::numCores] = std::thread::hardware_concurrency(); - _cpu.push_back(cpu); + _cpus.push_back(cpu); } -void MACOSInstance::enumerateGpu() { +void MACOSInstance::enumerateGpus() { #ifdef Q_OS_MAC GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu[keys::gpu::vendor] = ident->getName().toUtf8().constData(); gpu[keys::gpu::model] = ident->getName().toUtf8().constData(); + gpu[keys::gpu::vendor] = findGPUVendorInDescription(gpu[keys::gpu::model].get()); gpu[keys::gpu::videoMemory] = ident->getMemory(); gpu[keys::gpu::driver] = ident->getDriver().toUtf8().constData(); - _gpu.push_back(gpu); + _gpus.push_back(gpu); #endif @@ -101,7 +102,7 @@ void MACOSInstance::enumerateDisplays() { display["modeWidth"] = displayModeWidth; display["modeHeight"] = displayModeHeight; - _display.push_back(display); + _displays.push_back(display); #endif } @@ -111,9 +112,9 @@ void MACOSInstance::enumerateMemory() { #ifdef Q_OS_MAC long pages = sysconf(_SC_PHYS_PAGES); long page_size = sysconf(_SC_PAGE_SIZE); - ram[keys::memTotal] = pages * page_size; + ram[keys::memory::memTotal] = pages * page_size; #endif - _memory.push_back(ram); + _memory = ram; } void MACOSInstance::enumerateComputer(){ @@ -133,5 +134,9 @@ void MACOSInstance::enumerateComputer(){ free(model); #endif + + auto sysInfo = QSysInfo(); + + _computer[keys::computer::OSVersion] = sysInfo.kernelVersion().toStdString(); } diff --git a/libraries/platform/src/platform/backend/MACOSPlatform.h b/libraries/platform/src/platform/backend/MACOSPlatform.h index 4a257d8be5..e893dda739 100644 --- a/libraries/platform/src/platform/backend/MACOSPlatform.h +++ b/libraries/platform/src/platform/backend/MACOSPlatform.h @@ -15,11 +15,11 @@ namespace platform { class MACOSInstance : public Instance { public: - void enumerateCpu() override; - void enumerateMemory() override; - void enumerateGpu() override; + void enumerateCpus() override; + void enumerateGpus() override; void enumerateDisplays() override; - void enumerateComputer () override; + void enumerateMemory() override; + void enumerateComputer() override; }; } // namespace platform diff --git a/libraries/platform/src/platform/backend/Platform.cpp b/libraries/platform/src/platform/backend/Platform.cpp index 8e9fda30ed..dba41ce121 100644 --- a/libraries/platform/src/platform/backend/Platform.cpp +++ b/libraries/platform/src/platform/backend/Platform.cpp @@ -11,6 +11,8 @@ #include "../PlatformKeys.h" namespace platform { namespace keys { + const char* UNKNOWN = "UNKNOWN"; + namespace cpu { const char* vendor = "vendor"; const char* vendor_Intel = "Intel"; @@ -38,8 +40,9 @@ namespace platform { namespace keys { const char* coordsTop = "coordinatestop"; const char* coordsBottom = "coordinatesbottom"; } - const char* memTotal = "memTotal"; - + namespace memory { + const char* memTotal = "memTotal"; + } namespace computer { const char* OS = "OS"; const char* OS_WINDOWS = "WINDOWS"; @@ -47,6 +50,8 @@ namespace platform { namespace keys { const char* OS_LINUX = "LINUX"; const char* OS_ANDROID = "ANDROID"; + const char* OSVersion = "OSVersion"; + const char* vendor = "vendor"; const char* vendor_Apple = "Apple"; @@ -54,6 +59,12 @@ namespace platform { namespace keys { const char* profileTier = "profileTier"; } + + const char* CPUS = "cpus"; + const char* GPUS = "gpus"; + const char* DISPLAYS = "displays"; + const char* MEMORY = "memory"; + const char* COMPUTER = "computer"; }} #include @@ -117,14 +128,14 @@ json platform::getDisplay(int index) { return _instance->getDisplay(index); } -int platform::getNumMemories() { - return _instance->getNumMemories(); +json platform::getMemory() { + return _instance->getMemory(); } -json platform::getMemory(int index) { - return _instance->getMemory(index); -} - -json platform::getComputer(){ +json platform::getComputer() { return _instance->getComputer(); } + +json platform::getAll() { + return _instance->getAll(); +} diff --git a/libraries/platform/src/platform/backend/PlatformInstance.cpp b/libraries/platform/src/platform/backend/PlatformInstance.cpp index 3dd3e5f592..f3a82f8cc4 100644 --- a/libraries/platform/src/platform/backend/PlatformInstance.cpp +++ b/libraries/platform/src/platform/backend/PlatformInstance.cpp @@ -16,10 +16,10 @@ using namespace platform; bool Instance::enumeratePlatform() { enumerateComputer(); - enumerateCpu(); - enumerateGpu(); - enumerateDisplays(); enumerateMemory(); + enumerateCpus(); + enumerateGpus(); + enumerateDisplays(); // And profile the platform and put the tier in "computer" _computer[keys::computer::profileTier] = Profiler::TierNames[Profiler::profilePlatform()]; @@ -28,55 +28,42 @@ bool Instance::enumeratePlatform() { } json Instance::getCPU(int index) { - assert(index <(int) _cpu.size()); - if (index >= (int)_cpu.size()) + assert(index <(int) _cpus.size()); + if (index >= (int)_cpus.size()) return json(); - return _cpu.at(index); -} - -//These are ripe for template.. will work on that next -json Instance::getMemory(int index) { - assert(index <(int) _memory.size()); - if(index >= (int)_memory.size()) - return json(); - - return _memory.at(index); + return _cpus.at(index); } json Instance::getGPU(int index) { - assert(index <(int) _gpu.size()); + assert(index <(int) _gpus.size()); - if (index >=(int) _gpu.size()) + if (index >=(int) _gpus.size()) return json(); - return _gpu.at(index); + return _gpus.at(index); } json Instance::getDisplay(int index) { - assert(index <(int) _display.size()); + assert(index <(int) _displays.size()); - if (index >=(int) _display.size()) + if (index >=(int) _displays.size()) return json(); - return _display.at(index); + return _displays.at(index); } Instance::~Instance() { - if (_cpu.size() > 0) { - _cpu.clear(); + if (_cpus.size() > 0) { + _cpus.clear(); } - if (_memory.size() > 0) { - _memory.clear(); + if (_gpus.size() > 0) { + _gpus.clear(); } - if (_gpu.size() > 0) { - _gpu.clear(); - } - - if (_display.size() > 0) { - _display.clear(); + if (_displays.size() > 0) { + _displays.clear(); } } @@ -106,17 +93,53 @@ json Instance::listAllKeys() { keys::display::coordsTop, keys::display::coordsBottom, - keys::memTotal, + keys::memory::memTotal, keys::computer::OS, keys::computer::OS_WINDOWS, keys::computer::OS_MACOS, keys::computer::OS_LINUX, keys::computer::OS_ANDROID, + keys::computer::OSVersion, keys::computer::vendor, keys::computer::vendor_Apple, keys::computer::model, - keys::computer::profileTier + keys::computer::profileTier, + + keys::CPUS, + keys::GPUS, + keys::DISPLAYS, + keys::MEMORY, + keys::COMPUTER, }}); return allKeys; } + +const char* Instance::findGPUVendorInDescription(const std::string& description) { + // intel integrated graphics + if (description.find(keys::gpu::vendor_Intel) != std::string::npos) { + return keys::gpu::vendor_Intel; + } + // AMD gpu + else if (description.find(keys::gpu::vendor_AMD) != std::string::npos) { + return keys::gpu::vendor_AMD; + } + // NVIDIA gpu + else if (description.find(keys::gpu::vendor_NVIDIA) != std::string::npos) { + return keys::gpu::vendor_NVIDIA; + } else { + return keys::UNKNOWN; + } +} + +json Instance::getAll() { + json all = {}; + + all[keys::COMPUTER] = _computer; + all[keys::MEMORY] = _memory; + all[keys::CPUS] = _cpus; + all[keys::GPUS] = _gpus; + all[keys::DISPLAYS] = _displays; + + return all; +} diff --git a/libraries/platform/src/platform/backend/PlatformInstance.h b/libraries/platform/src/platform/backend/PlatformInstance.h index 95eb2ef25e..b7983446f5 100644 --- a/libraries/platform/src/platform/backend/PlatformInstance.h +++ b/libraries/platform/src/platform/backend/PlatformInstance.h @@ -19,36 +19,39 @@ class Instance { public: bool virtual enumeratePlatform(); - int getNumCPUs() { return (int)_cpu.size(); } + int getNumCPUs() { return (int)_cpus.size(); } json getCPU(int index); - int getNumGPUs() { return (int)_gpu.size(); } + int getNumGPUs() { return (int)_gpus.size(); } json getGPU(int index); - int getNumMemories() { return (int)_memory.size(); } - json getMemory(int index); - - int getNumDisplays() { return (int)_display.size(); } + int getNumDisplays() { return (int)_displays.size(); } json getDisplay(int index); + json getMemory() { return _memory; } + + json getComputer() { return _computer; } - json getComputer() {return _computer;} - - void virtual enumerateCpu()=0; - void virtual enumerateMemory()=0; - void virtual enumerateGpu()=0; + json getAll(); + + void virtual enumerateCpus()=0; + void virtual enumerateGpus()=0; void virtual enumerateDisplays() {} + void virtual enumerateMemory() = 0; void virtual enumerateComputer()=0; virtual ~Instance(); static json listAllKeys(); + // Helper function to filter the vendor name out of the description of a GPU + static const char* findGPUVendorInDescription(const std::string& description); + protected: - std::vector _cpu; - std::vector _memory; - std::vector _gpu; - std::vector _display; + std::vector _cpus; + std::vector _gpus; + std::vector _displays; + json _memory; json _computer; }; diff --git a/libraries/platform/src/platform/backend/WINPlatform.cpp b/libraries/platform/src/platform/backend/WINPlatform.cpp index e34d87d853..9cf01ce4e0 100644 --- a/libraries/platform/src/platform/backend/WINPlatform.cpp +++ b/libraries/platform/src/platform/backend/WINPlatform.cpp @@ -16,32 +16,33 @@ #ifdef Q_OS_WIN #include +#include #endif using namespace platform; -void WINInstance::enumerateCpu() { +void WINInstance::enumerateCpus() { json cpu = {}; cpu[keys::cpu::vendor] = CPUIdent::Vendor(); cpu[keys::cpu::model] = CPUIdent::Brand(); cpu[keys::cpu::numCores] = std::thread::hardware_concurrency(); - _cpu.push_back(cpu); + _cpus.push_back(cpu); } -void WINInstance::enumerateGpu() { +void WINInstance::enumerateGpus() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu[keys::gpu::vendor] = ident->getName().toUtf8().constData(); gpu[keys::gpu::model] = ident->getName().toUtf8().constData(); + gpu[keys::gpu::vendor] = findGPUVendorInDescription(gpu[keys::gpu::model].get()); gpu[keys::gpu::videoMemory] = ident->getMemory(); gpu[keys::gpu::driver] = ident->getDriver().toUtf8().constData(); - _gpu.push_back(gpu); - _display = ident->getOutput(); + _gpus.push_back(gpu); + _displays = ident->getOutput(); } void WINInstance::enumerateMemory() { @@ -52,9 +53,9 @@ void WINInstance::enumerateMemory() { statex.dwLength = sizeof(statex); GlobalMemoryStatusEx(&statex); int totalRam = statex.ullTotalPhys / 1024 / 1024; - ram[platform::keys::memTotal] = totalRam; + ram[platform::keys::memory::memTotal] = totalRam; #endif - _memory.push_back(ram); + _memory = ram; } void WINInstance::enumerateComputer(){ @@ -62,5 +63,8 @@ void WINInstance::enumerateComputer(){ _computer[keys::computer::vendor] = ""; _computer[keys::computer::model] = ""; + auto sysInfo = QSysInfo(); + + _computer[keys::computer::OSVersion] = sysInfo.kernelVersion().toStdString(); } diff --git a/libraries/platform/src/platform/backend/WINPlatform.h b/libraries/platform/src/platform/backend/WINPlatform.h index e540335d94..cb6d3f482f 100644 --- a/libraries/platform/src/platform/backend/WINPlatform.h +++ b/libraries/platform/src/platform/backend/WINPlatform.h @@ -15,9 +15,9 @@ namespace platform { class WINInstance : public Instance { public: - void enumerateCpu() override; + void enumerateCpus() override; + void enumerateGpus() override; void enumerateMemory() override; - void enumerateGpu() override; void enumerateComputer () override; }; } // namespace platform diff --git a/libraries/shared/src/GPUIdent.cpp b/libraries/shared/src/GPUIdent.cpp index f092a56c17..c195b2ec3a 100644 --- a/libraries/shared/src/GPUIdent.cpp +++ b/libraries/shared/src/GPUIdent.cpp @@ -282,12 +282,13 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer) if (!validAdapterList.empty()) { for (auto outy = adapterToOutputs.begin(); outy != adapterToOutputs.end(); ++outy) { - AdapterEntry entry = *outy; + AdapterEntry entry = *outy; for (auto test = entry.second.begin(); test != entry.second.end(); ++test) { - + std::wstring wDeviceName(test->DeviceName); + std::string deviceName(wDeviceName.begin(), wDeviceName.end()); + nlohmann::json output = {}; - output["description"] = entry.first.first.Description; - output["deviceName"]= test->DeviceName; + output["model"] = deviceName; output["coordinatesleft"] = test->DesktopCoordinates.left; output["coordinatesright"] = test->DesktopCoordinates.right; output["coordinatestop"] = test->DesktopCoordinates.top; From 50df5e0bc52634287bc954b2656247df6f21b7d4 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 19 Jun 2019 16:56:45 -0700 Subject: [PATCH 04/14] small cleanup to shared object etc. --- .../qml/src/qml/impl/RenderEventHandler.cpp | 11 ++--- libraries/qml/src/qml/impl/SharedObject.cpp | 45 +++++++------------ libraries/qml/src/qml/impl/SharedObject.h | 41 ++++++++--------- libraries/qml/src/qml/impl/TextureCache.h | 5 +-- 4 files changed, 44 insertions(+), 58 deletions(-) diff --git a/libraries/qml/src/qml/impl/RenderEventHandler.cpp b/libraries/qml/src/qml/impl/RenderEventHandler.cpp index a1edfd6789..cc9fe34edc 100644 --- a/libraries/qml/src/qml/impl/RenderEventHandler.cpp +++ b/libraries/qml/src/qml/impl/RenderEventHandler.cpp @@ -49,8 +49,8 @@ bool RenderEventHandler::event(QEvent* e) { return QObject::event(e); } -RenderEventHandler::RenderEventHandler(SharedObject* shared, QThread* targetThread) - : _shared(shared) { +RenderEventHandler::RenderEventHandler(SharedObject* shared, QThread* targetThread) : + _shared(shared) { // Create the GL canvas in the same thread as the share canvas if (!_canvas.create(SharedObject::getSharedContext())) { qFatal("Unable to create new offscreen GL context"); @@ -136,7 +136,8 @@ void RenderEventHandler::qmlRender(bool sceneGraphSync) { resize(); - { + + if (_currentSize != QSize()) { PROFILE_RANGE(render_qml_gl, "render"); GLuint texture = SharedObject::getTextureCache().acquireTexture(_currentSize); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo); @@ -146,7 +147,7 @@ void RenderEventHandler::qmlRender(bool sceneGraphSync) { glClear(GL_COLOR_BUFFER_BIT); } else { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - _shared->_quickWindow->setRenderTarget(_fbo, _currentSize); + _shared->setRenderTarget(_fbo, _currentSize); _shared->_renderControl->render(); } _shared->_lastRenderTime = usecTimestampNow(); @@ -179,7 +180,7 @@ void RenderEventHandler::onQuit() { _fbo = 0; } - _shared->shutdownRendering(_canvas, _currentSize); + _shared->shutdownRendering(_currentSize); _canvas.doneCurrent(); } _canvas.moveToThreadWithContext(qApp->thread()); diff --git a/libraries/qml/src/qml/impl/SharedObject.cpp b/libraries/qml/src/qml/impl/SharedObject.cpp index b72f37481b..55788c8a02 100644 --- a/libraries/qml/src/qml/impl/SharedObject.cpp +++ b/libraries/qml/src/qml/impl/SharedObject.cpp @@ -78,7 +78,6 @@ SharedObject::SharedObject() { QObject::connect(qApp, &QCoreApplication::aboutToQuit, this, &SharedObject::onAboutToQuit); } - SharedObject::~SharedObject() { // After destroy returns, the rendering thread should be gone destroy(); @@ -173,7 +172,6 @@ void SharedObject::setRootItem(QQuickItem* rootItem) { QObject::connect(_renderControl, &QQuickRenderControl::renderRequested, this, &SharedObject::requestRender); QObject::connect(_renderControl, &QQuickRenderControl::sceneChanged, this, &SharedObject::requestRenderSync); #endif - } void SharedObject::destroy() { @@ -210,7 +208,7 @@ void SharedObject::destroy() { } // Block until the rendering thread has stopped // FIXME this is undesirable because this is blocking the main thread, - // but I haven't found a reliable way to do this only at application + // but I haven't found a reliable way to do this only at application // shutdown if (_renderThread) { _renderThread->wait(); @@ -220,10 +218,8 @@ void SharedObject::destroy() { #endif } - #define SINGLE_QML_ENGINE 0 - #if SINGLE_QML_ENGINE static QQmlEngine* globalEngine{ nullptr }; static size_t globalEngineRefCount{ 0 }; @@ -344,6 +340,11 @@ void SharedObject::setSize(const QSize& size) { #endif } +void SharedObject::setMaxFps(uint8_t maxFps) { + QMutexLocker locker(&_mutex); + _maxFps = maxFps; +} + bool SharedObject::preRender(bool sceneGraphSync) { #ifndef DISABLE_QML QMutexLocker lock(&_mutex); @@ -370,9 +371,9 @@ bool SharedObject::preRender(bool sceneGraphSync) { return true; } -void SharedObject::shutdownRendering(OffscreenGLCanvas& canvas, const QSize& size) { +void SharedObject::shutdownRendering(const QSize& size) { QMutexLocker locker(&_mutex); - if (size != QSize(0, 0)) { + if (size != QSize()) { getTextureCache().releaseSize(size); if (_latestTextureAndFence.first) { getTextureCache().releaseTexture(_latestTextureAndFence); @@ -380,19 +381,17 @@ void SharedObject::shutdownRendering(OffscreenGLCanvas& canvas, const QSize& siz } #ifndef DISABLE_QML _renderControl->invalidate(); - canvas.doneCurrent(); #endif wake(); } -bool SharedObject::isQuit() { +bool SharedObject::isQuit() const { QMutexLocker locker(&_mutex); return _quit; } void SharedObject::requestRender() { - // Don't queue multiple renders - if (_renderRequested) { + if (_quit) { return; } _renderRequested = true; @@ -402,18 +401,13 @@ void SharedObject::requestRenderSync() { if (_quit) { return; } - - { - QMutexLocker lock(&_mutex); - _syncRequested = true; - } - - requestRender(); + _renderRequested = true; + _syncRequested = true; } bool SharedObject::fetchTexture(TextureAndFence& textureAndFence) { QMutexLocker locker(&_mutex); - if (0 == _latestTextureAndFence.first) { + if (!_latestTextureAndFence.first) { return false; } textureAndFence = { 0, 0 }; @@ -421,8 +415,7 @@ bool SharedObject::fetchTexture(TextureAndFence& textureAndFence) { return true; } -void hifi::qml::impl::SharedObject::addToDeletionList(QObject * object) -{ +void SharedObject::addToDeletionList(QObject* object) { _deletionList.append(QPointer(object)); } @@ -469,11 +462,9 @@ void SharedObject::onRender() { return; } - QMutexLocker lock(&_mutex); if (_syncRequested) { - lock.unlock(); _renderControl->polishItems(); - lock.relock(); + QMutexLocker lock(&_mutex); QCoreApplication::postEvent(_renderObject, new OffscreenEvent(OffscreenEvent::RenderSync)); // sync and render request, main and render threads must be synchronized wait(); @@ -494,13 +485,11 @@ void SharedObject::onTimer() { { QMutexLocker locker(&_mutex); // Don't queue more than one frame at a time - if (0 != _latestTextureAndFence.first) { + if (_latestTextureAndFence.first) { return; } - } - { - if (_maxFps == 0) { + if (!_maxFps) { return; } auto minRenderInterval = USECS_PER_SECOND / _maxFps; diff --git a/libraries/qml/src/qml/impl/SharedObject.h b/libraries/qml/src/qml/impl/SharedObject.h index c9c0ef7bd0..50c56ad714 100644 --- a/libraries/qml/src/qml/impl/SharedObject.h +++ b/libraries/qml/src/qml/impl/SharedObject.h @@ -16,7 +16,6 @@ #include "TextureCache.h" - class QWindow; class QTimer; class QQuickWindow; @@ -24,7 +23,6 @@ class QQuickItem; class QOpenGLContext; class QQmlEngine; class QQmlContext; -class OffscreenGLCanvas; namespace hifi { namespace qml { @@ -51,11 +49,11 @@ public: void create(OffscreenSurface* surface); void setRootItem(QQuickItem* rootItem); void destroy(); - bool isQuit(); + bool isQuit() const; QSize getSize() const; void setSize(const QSize& size); - void setMaxFps(uint8_t maxFps) { _maxFps = maxFps; } + void setMaxFps(uint8_t maxFps); QQuickWindow* getWindow() { return _quickWindow; } QQuickItem* getRootItem() { return _rootItem; } @@ -72,7 +70,7 @@ private: bool event(QEvent* e) override; bool preRender(bool sceneGraphSync); - void shutdownRendering(OffscreenGLCanvas& canvas, const QSize& size); + void shutdownRendering(const QSize& size); // Called by the render event handler, from the render thread void initializeRenderControl(QOpenGLContext* context); void releaseTextureAndFence(); @@ -94,31 +92,30 @@ private: QList> _deletionList; // Texture management - TextureAndFence _latestTextureAndFence{ 0, 0 }; - QQuickItem* _item{ nullptr }; - QQuickItem* _rootItem{ nullptr }; - QQuickWindow* _quickWindow{ nullptr }; - QQmlContext* _qmlContext{ nullptr }; + TextureAndFence _latestTextureAndFence { 0, 0 }; + QQuickItem* _rootItem { nullptr }; + QQuickWindow* _quickWindow { nullptr }; + QQmlContext* _qmlContext { nullptr }; mutable QMutex _mutex; QWaitCondition _cond; #ifndef DISABLE_QML - QWindow* _proxyWindow{ nullptr }; - RenderControl* _renderControl{ nullptr }; - RenderEventHandler* _renderObject{ nullptr }; + QWindow* _proxyWindow { nullptr }; + RenderControl* _renderControl { nullptr }; + RenderEventHandler* _renderObject { nullptr }; - QTimer* _renderTimer{ nullptr }; - QThread* _renderThread{ nullptr }; + QTimer* _renderTimer { nullptr }; + QThread* _renderThread { nullptr }; #endif - uint64_t _lastRenderTime{ 0 }; - QSize _size{ 100, 100 }; - uint8_t _maxFps{ 60 }; + uint64_t _lastRenderTime { 0 }; + QSize _size { 100, 100 }; + uint8_t _maxFps { 60 }; - bool _renderRequested{ false }; - bool _syncRequested{ false }; - bool _quit{ false }; - bool _paused{ false }; + bool _renderRequested { false }; + bool _syncRequested { false }; + bool _quit { false }; + bool _paused { false }; }; } // namespace impl diff --git a/libraries/qml/src/qml/impl/TextureCache.h b/libraries/qml/src/qml/impl/TextureCache.h index c146d0bdbf..29f88955a4 100644 --- a/libraries/qml/src/qml/impl/TextureCache.h +++ b/libraries/qml/src/qml/impl/TextureCache.h @@ -35,9 +35,8 @@ public: using Size = uint64_t; struct TextureSet { - Size textureSize; // The number of surfaces with this size - size_t clientCount{ 0 }; + size_t clientCount { 0 }; ValueList returnedTextures; }; @@ -66,7 +65,7 @@ private: std::unordered_map _textureSizes; Mutex _mutex; std::list _returnedTextures; - size_t _totalTextureUsage{ 0 }; + size_t _totalTextureUsage { 0 }; }; }}} // namespace hifi::qml::impl From 87d7a0a72fd2cd297e0f8ea4cc09f3319ae913bd Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 19 Jun 2019 17:11:05 -0700 Subject: [PATCH 05/14] recover the Good Parts from first attempt to fix bugz-512 --- .../src/EntityTreeRenderer.cpp | 28 +++++++++++++------ .../src/RenderableWebEntityItem.cpp | 16 +++++------ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 1ecbcb0c8b..8671b3da7e 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -256,18 +256,28 @@ void EntityTreeRenderer::clear() { } // reset the engine - if (_wantScripts && !_shuttingDown) { - resetEntitiesScriptEngine(); - } - // remove all entities from the scene auto scene = _viewState->getMain3DScene(); - if (scene) { - for (const auto& entry : _entitiesInScene) { - const auto& renderer = entry.second; - fadeOutRenderable(renderer); + if (_shuttingDown) { + if (scene) { + render::Transaction transaction; + for (const auto& entry : _entitiesInScene) { + const auto& renderer = entry.second; + renderer->removeFromScene(scene, transaction); + } + scene->enqueueTransaction(transaction); } } else { - qCWarning(entitiesrenderer) << "EntitityTreeRenderer::clear(), Unexpected null scene, possibly during application shutdown"; + if (_wantScripts) { + resetEntitiesScriptEngine(); + } + if (scene) { + for (const auto& entry : _entitiesInScene) { + const auto& renderer = entry.second; + fadeOutRenderable(renderer); + } + } else { + qCWarning(entitiesrenderer) << "EntitityTreeRenderer::clear(), Unexpected null scene"; + } } _entitiesInScene.clear(); _renderablesToUpdate.clear(); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 3b615ba467..bb3e99157e 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -7,6 +7,7 @@ // #include "RenderableWebEntityItem.h" +#include #include #include @@ -46,7 +47,7 @@ static uint64_t MAX_NO_RENDER_INTERVAL = 30 * USECS_PER_SECOND; static uint8_t YOUTUBE_MAX_FPS = 30; // Don't allow more than 20 concurrent web views -static uint32_t _currentWebCount { 0 }; +static std::atomic _currentWebCount(0); static const uint32_t MAX_CONCURRENT_WEB_VIEWS = 20; static QTouchDevice _touchDevice; @@ -356,16 +357,15 @@ void WebEntityRenderer::buildWebSurface(const EntityItemPointer& entity, const Q void WebEntityRenderer::destroyWebSurface() { QSharedPointer webSurface; - ContentType contentType = ContentType::NoContent; withWriteLock([&] { webSurface.swap(_webSurface); - _contentType = contentType; - }); + _contentType = ContentType::NoContent; - if (webSurface) { - --_currentWebCount; - WebEntityRenderer::releaseWebSurface(webSurface, _cachedWebSurface, _connections); - } + if (webSurface) { + --_currentWebCount; + WebEntityRenderer::releaseWebSurface(webSurface, _cachedWebSurface, _connections); + } + }); } glm::vec2 WebEntityRenderer::getWindowSize(const TypedEntityPointer& entity) const { From 1ea0dba083a023f9ca0488caf08cfe251f2fa472 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 20 Jun 2019 09:29:12 -0700 Subject: [PATCH 06/14] use weak_ptr for fade-out-finished lambda --- .../entities-renderer/src/EntityTreeRenderer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 8671b3da7e..5ac6e4f642 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -1066,10 +1066,14 @@ void EntityTreeRenderer::fadeOutRenderable(const EntityRendererPointer& renderab render::Transaction transaction; auto scene = _viewState->getMain3DScene(); - transaction.setTransitionFinishedOperator(renderable->getRenderItemID(), [scene, renderable]() { - render::Transaction transaction; - renderable->removeFromScene(scene, transaction); - scene->enqueueTransaction(transaction); + EntityRendererWeakPointer weakRenderable = renderable; + transaction.setTransitionFinishedOperator(renderable->getRenderItemID(), [scene, weakRenderable]() { + auto renderable = weakRenderable.lock(); + if (renderable) { + render::Transaction transaction; + renderable->removeFromScene(scene, transaction); + scene->enqueueTransaction(transaction); + } }); scene->enqueueTransaction(transaction); From c0250275a12e1cd7f78691b92275c7e4791cb792 Mon Sep 17 00:00:00 2001 From: dante ruiz Date: Thu, 20 Jun 2019 13:01:07 -0700 Subject: [PATCH 07/14] extra logging --- launchers/darwin/src/LatestBuildRequest.m | 24 +++++++++++++++++++---- launchers/darwin/src/main.mm | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/launchers/darwin/src/LatestBuildRequest.m b/launchers/darwin/src/LatestBuildRequest.m index 019637ed55..7100026416 100644 --- a/launchers/darwin/src/LatestBuildRequest.m +++ b/launchers/darwin/src/LatestBuildRequest.m @@ -1,7 +1,8 @@ #import "LatestBuildRequest.h" #import "Launcher.h" #import "Settings.h" - +// https://thunder.highfidelity.com/builds/api/tags/latest?format=json +// https://httpbin.org/status/500 @implementation LatestBuildRequest - (void) requestLatestBuildInfo { @@ -14,16 +15,26 @@ NSURLSession* session = [NSURLSession sharedSession]; NSURLSessionDataTask* dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + + NSLog(@"Latest Build Request error: %@", error); + NSLog(@"Latest Build Request Data: %@", data); + NSHTTPURLResponse *ne = (NSHTTPURLResponse *)response; + NSLog(@"Latest Build Request Response: %ld", [ne statusCode]); Launcher* sharedLauncher = [Launcher sharedLauncher]; - NSLog(@"credentials request finished"); NSMutableData* webData = [NSMutableData data]; [webData appendData:data]; NSString* jsonString = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[data length] encoding:NSUTF8StringEncoding]; NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; - id json = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil]; + NSLog(@"Latest Build Request -> json string: %@", jsonString); + NSError *jsonError = nil; + id json = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&jsonError]; + + if (jsonError) { + NSLog(@"Latest Build request: Failed to convert Json to data"); + } NSFileManager* fileManager = [NSFileManager defaultManager]; - NSArray *values = [json valueForKey:@"results"]; + NSArray *values = [json valueForKey:@"results"]; NSDictionary *value = [values objectAtIndex:0]; @@ -37,10 +48,15 @@ dispatch_async(dispatch_get_main_queue(), ^{ Settings* settings = [Settings sharedSettings]; NSInteger currentVersion = [settings latestBuildVersion]; + NSLog(@"Latest Build Request -> does build directory exist: %@", appDirectoryExist ? @"TRUE" : @"FALSE"); + NSLog(@"Latest Build Request -> current version: %ld", currentVersion); + NSLog(@"Latest Build Request -> latest version: %ld", buildNumber.integerValue); + NSLog(@"Latest Build Request -> mac url: %@", macInstallerUrl); BOOL latestVersionAvailable = (currentVersion != buildNumber.integerValue); [[Settings sharedSettings] buildVersion:buildNumber.integerValue]; BOOL shouldDownloadInterface = (latestVersionAvailable || !appDirectoryExist); + NSLog(@"Latest Build Request -> SHOULD DOWNLOAD: %@", shouldDownloadInterface ? @"TRUE" : @"FALSE"); [sharedLauncher shouldDownloadLatestBuild:shouldDownloadInterface :macInstallerUrl]; }); }]; diff --git a/launchers/darwin/src/main.mm b/launchers/darwin/src/main.mm index 7feab64d86..0a8ad4cf4a 100644 --- a/launchers/darwin/src/main.mm +++ b/launchers/darwin/src/main.mm @@ -17,7 +17,7 @@ void redirectLogToDocuments() int main(int argc, const char* argv[]) { //NSApp.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua]; - redirectLogToDocuments(); + //redirectLogToDocuments(); NSArray* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.highfidelity.launcher"]; if ([apps count] > 1) { NSLog(@"launcher is already running"); From 5fed710035195ae9f04de7441b045c2835739df9 Mon Sep 17 00:00:00 2001 From: dante ruiz Date: Thu, 20 Jun 2019 13:48:33 -0700 Subject: [PATCH 08/14] enable log --- launchers/darwin/src/main.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launchers/darwin/src/main.mm b/launchers/darwin/src/main.mm index 0a8ad4cf4a..7feab64d86 100644 --- a/launchers/darwin/src/main.mm +++ b/launchers/darwin/src/main.mm @@ -17,7 +17,7 @@ void redirectLogToDocuments() int main(int argc, const char* argv[]) { //NSApp.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua]; - //redirectLogToDocuments(); + redirectLogToDocuments(); NSArray* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.highfidelity.launcher"]; if ([apps count] > 1) { NSLog(@"launcher is already running"); From b42306739db39a4a7411f6e957931c9d5e02f226 Mon Sep 17 00:00:00 2001 From: dante ruiz Date: Thu, 20 Jun 2019 14:00:50 -0700 Subject: [PATCH 09/14] remove comments --- launchers/darwin/src/LatestBuildRequest.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/launchers/darwin/src/LatestBuildRequest.m b/launchers/darwin/src/LatestBuildRequest.m index 7100026416..5119efa8f6 100644 --- a/launchers/darwin/src/LatestBuildRequest.m +++ b/launchers/darwin/src/LatestBuildRequest.m @@ -1,8 +1,7 @@ #import "LatestBuildRequest.h" #import "Launcher.h" #import "Settings.h" -// https://thunder.highfidelity.com/builds/api/tags/latest?format=json -// https://httpbin.org/status/500 + @implementation LatestBuildRequest - (void) requestLatestBuildInfo { From bde50aa21cbacf52ee95ea7d53acf26fe4ffdbb2 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Thu, 20 Jun 2019 14:24:04 -0700 Subject: [PATCH 10/14] Detect AMD gpu on more than one possible token... --- libraries/platform/src/platform/backend/PlatformInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/platform/src/platform/backend/PlatformInstance.cpp b/libraries/platform/src/platform/backend/PlatformInstance.cpp index f3a82f8cc4..41786bca1f 100644 --- a/libraries/platform/src/platform/backend/PlatformInstance.cpp +++ b/libraries/platform/src/platform/backend/PlatformInstance.cpp @@ -121,7 +121,7 @@ const char* Instance::findGPUVendorInDescription(const std::string& description) return keys::gpu::vendor_Intel; } // AMD gpu - else if (description.find(keys::gpu::vendor_AMD) != std::string::npos) { + else if ((description.find(keys::gpu::vendor_AMD) != std::string::npos) || (description.find("Radeon") != std::string::npos)) { return keys::gpu::vendor_AMD; } // NVIDIA gpu From cd9b45047532b26883b22693b4c7651f0f8c8aa8 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 20 Jun 2019 15:03:15 -0700 Subject: [PATCH 11/14] re-expose mic and camera to disable crash --- interface/src/Application.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f9470782bf..c874505e98 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2935,8 +2935,10 @@ void Application::initializeGL() { #if !defined(DISABLE_QML) QStringList chromiumFlags; + // HACK: re-expose mic and camera to prevent crash on domain-change in chromium's media::FakeAudioInputStream::ReadAudioFromSource() // Bug 21993: disable microphone and camera input - chromiumFlags << "--use-fake-device-for-media-stream"; + //chromiumFlags << "--use-fake-device-for-media-stream"; + // Disable signed distance field font rendering on ATI/AMD GPUs, due to // https://highfidelity.manuscript.com/f/cases/13677/Text-showing-up-white-on-Marketplace-app std::string vendor{ (const char*)glGetString(GL_VENDOR) }; From e7cec0f11fd6f86a5ca3445c13e32ca0d5a11bde Mon Sep 17 00:00:00 2001 From: RebeccaStankus Date: Thu, 20 Jun 2019 15:07:39 -0700 Subject: [PATCH 12/14] Fixed dialogs imports --- scripts/system/create/NewMaterialDialog.qml | 2 +- scripts/system/create/NewModelDialog.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/create/NewMaterialDialog.qml b/scripts/system/create/NewMaterialDialog.qml index 75570327e0..1631632fb4 100644 --- a/scripts/system/create/NewMaterialDialog.qml +++ b/scripts/system/create/NewMaterialDialog.qml @@ -15,7 +15,7 @@ import QtQuick.Dialogs 1.2 as OriginalDialogs import stylesUit 1.0 import controlsUit 1.0 -import dialogs 1.0 +import hifi.dialogs 1.0 Rectangle { id: newMaterialDialog diff --git a/scripts/system/create/NewModelDialog.qml b/scripts/system/create/NewModelDialog.qml index 1ded00d701..92a08df10d 100644 --- a/scripts/system/create/NewModelDialog.qml +++ b/scripts/system/create/NewModelDialog.qml @@ -14,7 +14,7 @@ import QtQuick.Dialogs 1.2 as OriginalDialogs import stylesUit 1.0 import controlsUit 1.0 -import dialogs 1.0 +import hifi.dialogs 1.0 Rectangle { id: newModelDialog From b28763a017b710a581ef0346aecd477e8ae29569 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 20 Jun 2019 15:11:35 -0700 Subject: [PATCH 13/14] Add extra logging to Windows launcher --- launchers/win32/LauncherDlg.cpp | 3 +++ launchers/win32/LauncherManager.cpp | 10 ++++++++++ launchers/win32/LauncherUtils.cpp | 17 +++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/launchers/win32/LauncherDlg.cpp b/launchers/win32/LauncherDlg.cpp index d3cae39013..98c61794a0 100644 --- a/launchers/win32/LauncherDlg.cpp +++ b/launchers/win32/LauncherDlg.cpp @@ -213,6 +213,9 @@ BOOL CLauncherDlg::getHQInfo(const CString& orgname) { CString lowerOrgName = orgname; lowerOrgName.MakeLower(); LauncherUtils::hMac256(lowerOrgName, LAUNCHER_HMAC_SECRET, hash); + CString msg; + msg.Format(_T("Calculated hash: \"%s\" => \"%s\""), lowerOrgName, hash); + theApp._manager.addToLog(msg); return theApp._manager.readOrganizationJSON(hash) == LauncherUtils::ResponseError::NoError; } diff --git a/launchers/win32/LauncherManager.cpp b/launchers/win32/LauncherManager.cpp index fc79287457..47c84f1124 100644 --- a/launchers/win32/LauncherManager.cpp +++ b/launchers/win32/LauncherManager.cpp @@ -427,6 +427,11 @@ BOOL LauncherManager::extractApplication() { LauncherUtils::cStringToStd(installPath), [&](int type, int size) { onZipExtracted((ZipType)type, size); }); + if (success) { + addToLog(_T("Created thread for unzipping application.")); + } else { + addToLog(_T("Failed to create thread for unzipping application.")); + } return success; } @@ -449,6 +454,11 @@ BOOL LauncherManager::installContent() { LauncherUtils::cStringToStd(contentPath), [&](int type, int size) { onZipExtracted((ZipType)type, size); }); + if (success) { + addToLog(_T("Created thread for unzipping content.")); + } else { + addToLog(_T("Failed to create thread for unzipping content.")); + } return success; } diff --git a/launchers/win32/LauncherUtils.cpp b/launchers/win32/LauncherUtils.cpp index cfb8b765c5..11ac10b5f2 100644 --- a/launchers/win32/LauncherUtils.cpp +++ b/launchers/win32/LauncherUtils.cpp @@ -16,6 +16,7 @@ #pragma comment(lib, "winhttp") +#include "LauncherApp.h" #include "LauncherUtils.h" CString LauncherUtils::urlEncodeString(const CString& url) { @@ -230,14 +231,24 @@ uint64_t LauncherUtils::extractZip(const std::string& zipFile, const std::string auto status = mz_zip_reader_init_file(&zip_archive, zipFile.c_str(), 0); + { + CString msg; + msg.Format(_T("Reading zip file %s, extracting to %s"), CString(zipFile.c_str()), CString(path.c_str())); + theApp._manager.addToLog(msg); + } + if (!status) return 0; int fileCount = (int)mz_zip_reader_get_num_files(&zip_archive); if (fileCount == 0) { + theApp._manager.addToLog(_T("Zip archive has a file count of 0")); + mz_zip_reader_end(&zip_archive); return 0; } mz_zip_archive_file_stat file_stat; if (!mz_zip_reader_file_stat(&zip_archive, 0, &file_stat)) { + theApp._manager.addToLog(_T("Zip archive cannot be stat'd")); + mz_zip_reader_end(&zip_archive); return 0; } @@ -263,6 +274,12 @@ uint64_t LauncherUtils::extractZip(const std::string& zipFile, const std::string } } + { + CString msg; + msg.Format(_T("Done unzipping archive, total size: %llu"), totalSize); + theApp._manager.addToLog(msg); + } + // Close the archive, freeing any resources it was using mz_zip_reader_end(&zip_archive); return totalSize; From 3a6d8dc3836f01aa0909967599508147c84ffe6a Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 20 Jun 2019 15:52:36 -0700 Subject: [PATCH 14/14] Disable handTouch.js to prevent finger twitching This PR disables handTouch.js. handTouch.js allows the fingers to animate on the surface of an object. However, it can sometimes detect collisions with walls or tables when the avatar is standing next to them. We will more properly fix handTouch.js in a future PR, but for now we will disable the functionality. Also, a small bug fix was made to the Rig to prevent the idleOverlayAlpha from exceeding the 0.0 to 1.0 range. This can cause the fingers to bend incorrectly for a moment. Also, three new items were added to the Developer > Show Animation Stats panel. * Joint Override Count: displays the current count of joints that are overriden by MyAvatar.setJointRotation() JS API calls. * Flow: displays if flow is active of disabled. * Network Graph: displays if the network anim graph, used for teleportation, is enabled or disabled. https://highfidelity.atlassian.net/browse/BUGZ-154 --- interface/resources/qml/AnimStats.qml | 9 +++++++ interface/src/avatar/MyAvatar.cpp | 24 +++++++++++++++++++ interface/src/avatar/MyAvatar.h | 4 ++++ interface/src/ui/AnimStats.cpp | 15 ++++++++++++ interface/src/ui/AnimStats.h | 12 ++++++++++ libraries/animation/src/Rig.cpp | 24 +++++++++++++++++++ libraries/animation/src/Rig.h | 4 ++++ .../system/controllers/handTouch.js | 3 ++- scripts/system/controllers/handTouch.js | 3 ++- 9 files changed, 96 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/AnimStats.qml b/interface/resources/qml/AnimStats.qml index d06a0484cb..70f2e37927 100644 --- a/interface/resources/qml/AnimStats.qml +++ b/interface/resources/qml/AnimStats.qml @@ -53,6 +53,9 @@ Item { StatText { text: root.recenterText } + StatText { + text: root.overrideJointText + } StatText { text: "Anim Vars:--------------------------------------------------------------------------------" } @@ -98,6 +101,9 @@ Item { StatText { text: root.sittingText } + StatText { + text: root.flowText + } StatText { text: "State Machines:---------------------------------------------------------------------------" } @@ -131,6 +137,9 @@ Item { StatText { text: root.walkingText } + StatText { + text: root.networkGraphText + } StatText { text: "Alpha Values:--------------------------------------------------------------------------" } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index aba74806c0..cce2af466d 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -6100,6 +6100,30 @@ QVariantList MyAvatar::getCollidingFlowJoints() { return result; } +int MyAvatar::getOverrideJointCount() const { + if (_skeletonModel) { + return _skeletonModel->getRig().getOverrideJointCount(); + } else { + return 0; + } +} + +bool MyAvatar::getFlowActive() const { + if (_skeletonModel) { + return _skeletonModel->getRig().getFlowActive(); + } else { + return false; + } +} + +bool MyAvatar::getNetworkGraphActive() const { + if (_skeletonModel) { + return _skeletonModel->getRig().getNetworkGraphActive(); + } else { + return false; + } +} + void MyAvatar::initFlowFromFST() { if (_skeletonModel->isLoaded()) { auto &flowData = _skeletonModel->getHFMModel().flowData; diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 8cd2c44088..d092122863 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -1835,6 +1835,10 @@ public: */ Q_INVOKABLE QVariantList getCollidingFlowJoints(); + int getOverrideJointCount() const; + bool getFlowActive() const; + bool getNetworkGraphActive() const; + public slots: /**jsdoc diff --git a/interface/src/ui/AnimStats.cpp b/interface/src/ui/AnimStats.cpp index 6317c069f4..d4696a8c04 100644 --- a/interface/src/ui/AnimStats.cpp +++ b/interface/src/ui/AnimStats.cpp @@ -94,6 +94,21 @@ void AnimStats::updateStats(bool force) { } emit walkingTextChanged(); + // print current overrideJointText + int overrideJointCount = myAvatar->getOverrideJointCount(); + _overrideJointText = QString("Override Joint Count: %1").arg(overrideJointCount); + emit overrideJointTextChanged(); + + // print current flowText + bool flowActive = myAvatar->getFlowActive(); + _flowText = QString("Flow: %1").arg(flowActive ? "enabled" : "disabled"); + emit flowTextChanged(); + + // print current networkGraphText + bool networkGraphActive = myAvatar->getNetworkGraphActive(); + _networkGraphText = QString("Network Graph: %1").arg(networkGraphActive ? "enabled" : "disabled"); + emit networkGraphTextChanged(); + // update animation debug alpha values QStringList newAnimAlphaValues; qint64 now = usecTimestampNow(); diff --git a/interface/src/ui/AnimStats.h b/interface/src/ui/AnimStats.h index 57d2a4f1a6..ccd7187d9b 100644 --- a/interface/src/ui/AnimStats.h +++ b/interface/src/ui/AnimStats.h @@ -25,6 +25,9 @@ class AnimStats : public QQuickItem { Q_PROPERTY(QString recenterText READ recenterText NOTIFY recenterTextChanged) Q_PROPERTY(QString sittingText READ sittingText NOTIFY sittingTextChanged) Q_PROPERTY(QString walkingText READ walkingText NOTIFY walkingTextChanged) + Q_PROPERTY(QString overrideJointText READ overrideJointText NOTIFY overrideJointTextChanged) + Q_PROPERTY(QString flowText READ flowText NOTIFY flowTextChanged) + Q_PROPERTY(QString networkGraphText READ networkGraphText NOTIFY networkGraphTextChanged) public: static AnimStats* getInstance(); @@ -43,6 +46,9 @@ public: QString recenterText() const { return _recenterText; } QString sittingText() const { return _sittingText; } QString walkingText() const { return _walkingText; } + QString overrideJointText() const { return _overrideJointText; } + QString flowText() const { return _flowText; } + QString networkGraphText() const { return _networkGraphText; } public slots: void forceUpdateStats() { updateStats(true); } @@ -58,6 +64,9 @@ signals: void recenterTextChanged(); void sittingTextChanged(); void walkingTextChanged(); + void overrideJointTextChanged(); + void flowTextChanged(); + void networkGraphTextChanged(); private: QStringList _animAlphaValues; @@ -76,6 +85,9 @@ private: QString _recenterText; QString _sittingText; QString _walkingText; + QString _overrideJointText; + QString _flowText; + QString _networkGraphText; }; #endif // hifi_AnimStats_h diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index a58b8745d7..0f0c67b846 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -2025,6 +2025,9 @@ void Rig::updateFromControllerParameters(const ControllerParameters& params, flo if (params.isTalking) { if (_talkIdleInterpTime < 1.0f) { _talkIdleInterpTime += dt / TOTAL_EASE_IN_TIME; + if (_talkIdleInterpTime > 1.0f) { + _talkIdleInterpTime = 1.0f; + } float easeOutInValue = _talkIdleInterpTime < 0.5f ? 4.0f * powf(_talkIdleInterpTime, 3.0f) : 4.0f * powf((_talkIdleInterpTime - 1.0f), 3.0f) + 1.0f; _animVars.set("idleOverlayAlpha", easeOutInValue); } else { @@ -2033,6 +2036,9 @@ void Rig::updateFromControllerParameters(const ControllerParameters& params, flo } else { if (_talkIdleInterpTime < 1.0f) { _talkIdleInterpTime += dt / TOTAL_EASE_OUT_TIME; + if (_talkIdleInterpTime > 1.0f) { + _talkIdleInterpTime = 1.0f; + } float easeOutInValue = _talkIdleInterpTime < 0.5f ? 4.0f * powf(_talkIdleInterpTime, 3.0f) : 4.0f * powf((_talkIdleInterpTime - 1.0f), 3.0f) + 1.0f; float talkAlpha = 1.0f - easeOutInValue; _animVars.set("idleOverlayAlpha", talkAlpha); @@ -2287,6 +2293,24 @@ void Rig::buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& a } } +int Rig::getOverrideJointCount() const { + int count = 0; + for (size_t i = 0; i < _internalPoseSet._overrideFlags.size(); i++) { + if (_internalPoseSet._overrideFlags[i]) { + count++; + } + } + return count; +} + +bool Rig::getFlowActive() const { + return _internalFlow.getActive(); +} + +bool Rig::getNetworkGraphActive() const { + return _sendNetworkNode; +} + glm::mat4 Rig::getJointTransform(int jointIndex) const { static const glm::mat4 IDENTITY; if (isIndexValid(jointIndex)) { diff --git a/libraries/animation/src/Rig.h b/libraries/animation/src/Rig.h index 02fa965f64..9baf4644f2 100644 --- a/libraries/animation/src/Rig.h +++ b/libraries/animation/src/Rig.h @@ -246,6 +246,10 @@ public: float getUnscaledEyeHeight() const; void buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePosesOut) const; + int getOverrideJointCount() const; + bool getFlowActive() const; + bool getNetworkGraphActive() const; + signals: void onLoadComplete(); diff --git a/scripts/simplifiedUI/system/controllers/handTouch.js b/scripts/simplifiedUI/system/controllers/handTouch.js index c706d054c1..5939c6e3d2 100644 --- a/scripts/simplifiedUI/system/controllers/handTouch.js +++ b/scripts/simplifiedUI/system/controllers/handTouch.js @@ -17,7 +17,8 @@ (function () { var LEAP_MOTION_NAME = "LeapMotion"; - var handTouchEnabled = true; + // Hand touch is disabled due to twitchy finger bug when walking near walls or tables. see BUGZ-154. + var handTouchEnabled = false; var leapMotionEnabled = Controller.getRunningInputDeviceNames().indexOf(LEAP_MOTION_NAME) >= 0; var MSECONDS_AFTER_LOAD = 2000; var updateFingerWithIndex = 0; diff --git a/scripts/system/controllers/handTouch.js b/scripts/system/controllers/handTouch.js index c706d054c1..5939c6e3d2 100644 --- a/scripts/system/controllers/handTouch.js +++ b/scripts/system/controllers/handTouch.js @@ -17,7 +17,8 @@ (function () { var LEAP_MOTION_NAME = "LeapMotion"; - var handTouchEnabled = true; + // Hand touch is disabled due to twitchy finger bug when walking near walls or tables. see BUGZ-154. + var handTouchEnabled = false; var leapMotionEnabled = Controller.getRunningInputDeviceNames().indexOf(LEAP_MOTION_NAME) >= 0; var MSECONDS_AFTER_LOAD = 2000; var updateFingerWithIndex = 0;