From 633c0dfbac045885edddfdece9f47ea032337579 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Wed, 15 May 2019 14:57:33 -0700 Subject: [PATCH 01/16] testing gcc warnings --- libraries/platform/src/AndroidPlatform.cpp | 16 ++++++------ libraries/platform/src/LinuxPlatform.cpp | 16 ++++++------ libraries/platform/src/MACOSPlatform.cpp | 16 ++++++------ libraries/platform/src/WINPlatform.cpp | 14 +++++----- libraries/platform/src/platformJsonKeys.h | 30 ++++++++++------------ 5 files changed, 45 insertions(+), 47 deletions(-) diff --git a/libraries/platform/src/AndroidPlatform.cpp b/libraries/platform/src/AndroidPlatform.cpp index e998f6f938..58274df9f5 100644 --- a/libraries/platform/src/AndroidPlatform.cpp +++ b/libraries/platform/src/AndroidPlatform.cpp @@ -15,19 +15,19 @@ using namespace platform; void AndroidInstance::enumerateCpu() { json cpu; - cpu["cpuBrand"] = ""; - cpu["cpuModel"] = ""; - cpu["cpuClockSpeed"] = ""; - cpu["cpuNumCores"] = ""; + cpu[jsonKeys::cpuBrand] = ""; + cpu[jsonKeys::cpuModel] = ""; + cpu[jsonKeys::cpuClockSpeed] = ""; + cpu[jsonKeys::cpuNumCores] = ""; _cpu.push_back(cpu); } void AndroidInstance::enumerateGpu() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu["gpuName"] = ident->getName().toUtf8().constData(); - gpu["gpuMemory"] = ident->getMemory(); - gpu["gpuDriver"] = ident->getDriver().toUtf8().constData(); + gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData(); + gpu[jsonKeys::gpuMemory] = ident->getMemory(); + gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData(); _gpu.push_back(gpu); _display = ident->getOutput(); @@ -35,6 +35,6 @@ void AndroidInstance::enumerateGpu() { void AndroidInstance::enumerateMemory() { json ram = {}; - + ram[jsonKeys::totalMemory]=""; _memory.push_back(ram); } diff --git a/libraries/platform/src/LinuxPlatform.cpp b/libraries/platform/src/LinuxPlatform.cpp index 96c105826f..b22344e728 100644 --- a/libraries/platform/src/LinuxPlatform.cpp +++ b/libraries/platform/src/LinuxPlatform.cpp @@ -15,10 +15,10 @@ using namespace platform; void LinuxInstance::enumerateCpu() { json cpu = {}; - cpu["cpuBrand"] = ""; - cpu["cpuModel"] = ""; - cpu["cpuClockSpeed"] = ""; - cpu["cpuNumCores"] = ""; + cpu[jsonKeys::cpuBrand] = ""; + cpu[jsonKeys::cpuModel] = ""; + cpu[jsonKeys::cpuClockSpeed] = ""; + cpu[jsonKeys::cpuNumCores] = ""; _cpu.push_back(cpu); } @@ -26,9 +26,9 @@ void LinuxInstance::enumerateCpu() { void LinuxInstance::enumerateGpu() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu["gpuName"] = ident->getName().toUtf8().constData(); - gpu["gpuMemory"] = ident->getMemory(); - gpu["gpuDriver"] = ident->getDriver().toUtf8().constData(); + gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData(); + gpu[jsonKeys::gpuMemory] = ident->getMemory(); + gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData(); _gpu.push_back(gpu); _display = ident->getOutput(); @@ -36,7 +36,7 @@ void LinuxInstance::enumerateGpu() { void LinuxInstance::enumerateMemory() { json ram = {}; - + ram[jsonKeys::totalMemory]=""; _memory.push_back(ram); } diff --git a/libraries/platform/src/MACOSPlatform.cpp b/libraries/platform/src/MACOSPlatform.cpp index 172cd642aa..a215f46335 100644 --- a/libraries/platform/src/MACOSPlatform.cpp +++ b/libraries/platform/src/MACOSPlatform.cpp @@ -55,10 +55,10 @@ void MACOSInstance::enumerateCpu() { } } - cpu["cpuBrand"] = CPUBrandString; - cpu["cpuModel"] = CPUModelString; - cpu["cpuClockSpeed"] = CPUClockString; - cpu["cpuNumCores"] = std::thread::hardware_concurrency(); + cpu[jsonKeys::cpuBrand] = CPUBrandString; + cpu[jsonKeys::cpuModel] = CPUModelString; + cpu[jsonKeys::cpuClockSpeed] = CPUClockString; + cpu[jsonKeys::cpuNumCores] = std::thread::hardware_concurrency(); _cpu.push_back(cpu); } @@ -66,9 +66,9 @@ void MACOSInstance::enumerateCpu() { void MACOSInstance::enumerateGpu() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu["gpuName"] = ident->getName().toUtf8().constData(); - gpu["gpuMemory"] = ident->getMemory(); - gpu["gpuDriver"] = ident->getDriver().toUtf8().constData(); + gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData(); + gpu[jsonKeys::gpuMemory] = ident->getMemory(); + gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData(); _gpu.push_back(gpu); _display = ident->getOutput(); @@ -80,7 +80,7 @@ void MACOSInstance::enumerateMemory() { #ifdef Q_OS_MAC long pages = sysconf(_SC_PHYS_PAGES); long page_size = sysconf(_SC_PAGE_SIZE); - ram["totalMemory"] = pages * page_size;; + ram[jsonKeys::totalMemory] = pages * page_size;; #endif _memory.push_back(ram); } diff --git a/libraries/platform/src/WINPlatform.cpp b/libraries/platform/src/WINPlatform.cpp index 601a9d7290..f1ed146c93 100644 --- a/libraries/platform/src/WINPlatform.cpp +++ b/libraries/platform/src/WINPlatform.cpp @@ -46,10 +46,10 @@ void WINInstance::enumerateCpu() { } } - cpu["cpuBrand"] = CPUBrandString; - cpu["cpuModel"] = CPUModelString; - cpu["cpuClockSpeed"] = CPUClockString; - cpu["cpuNumCores"] = std::thread::hardware_concurrency(); + cpu[platform::json::cpuBrand] = CPUBrandString; + cpu[jsonKeys::cpuModel] = CPUModelString; + cpu[jsonKeys::cpuClockSpeed] = CPUClockString; + cpu[jsonKeys::cpuNumCores] = std::thread::hardware_concurrency(); #endif _cpu.push_back(cpu); @@ -60,9 +60,9 @@ void WINInstance::enumerateGpu() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu["gpuName"] = ident->getName().toUtf8().constData(); - gpu["gpuMemory"] = ident->getMemory(); - gpu["gpuDriver"] = ident->getDriver().toUtf8().constData(); + gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData(); + gpu[jsonKeys::gpuMemory] = ident->getMemory(); + gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData(); _gpu.push_back(gpu); _display = ident->getOutput(); diff --git a/libraries/platform/src/platformJsonKeys.h b/libraries/platform/src/platformJsonKeys.h index 633add2b7e..cc2832a584 100644 --- a/libraries/platform/src/platformJsonKeys.h +++ b/libraries/platform/src/platformJsonKeys.h @@ -11,22 +11,20 @@ namespace platform { namespace jsonKeys{ -#if 0 - static const char* cpuBrand { "cpuBrand"}; - static const char* cpuModel {"cpuModel"}; - static const char* cpuClockSpeed {"clockSpeed"}; - static const char* cpuNumCores { "numCores"}; - static const char* gpuName {"GpuName"}; - static const char* gpuMemory {"gpuMemory"}; - static const char* gpuDriver {"gpuDriver"}; - static const char* totalMemory {"totalMem"}; - static const char* displayDescription { "description"}; - static const char* displayName {"deviceName"}; - static const char* displayCoordsLeft {"coordinatesleft"}; - static const char* displayCoordsRight { "coordinatesright"}; - static const char* displayCoordsTop { "coordinatestop"}; - static const char* displayCoordsBottom { "coordinatesbottom"}; -#endif + const char* cpuBrand { "cpuBrand"}; + const char* cpuModel {"cpuModel"}; + const char* cpuClockSpeed {"clockSpeed"}; + const char* cpuNumCores { "numCores"}; + const char* gpuName {"GpuName"}; + const char* gpuMemory {"gpuMemory"}; + const char* gpuDriver {"gpuDriver"}; + const char* totalMemory {"totalMem"}; + const char* displayDescription { "description"}; + const char* displayName {"deviceName"}; + const char* displayCoordsLeft {"coordinatesleft"}; + const char* displayCoordsRight { "coordinatesright"}; + const char* displayCoordsTop { "coordinatestop"}; + const char* displayCoordsBottom { "coordinatesbottom"}; } } // namespace platform From 9c786f3c5af9e71b4df0a03c19d2f46330a0e193 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Wed, 15 May 2019 15:48:08 -0700 Subject: [PATCH 02/16] testing change --- libraries/platform/src/AndroidPlatform.cpp | 2 +- libraries/platform/src/LinuxPlatform.cpp | 2 +- libraries/platform/src/MACOSPlatform.cpp | 2 +- libraries/platform/src/WINPlatform.cpp | 2 +- libraries/platform/src/platformInstance.h | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/platform/src/AndroidPlatform.cpp b/libraries/platform/src/AndroidPlatform.cpp index 58274df9f5..e44e8e156a 100644 --- a/libraries/platform/src/AndroidPlatform.cpp +++ b/libraries/platform/src/AndroidPlatform.cpp @@ -7,7 +7,7 @@ // #include "AndroidPlatform.h" -#include "platformJsonKeys.h" + #include #include diff --git a/libraries/platform/src/LinuxPlatform.cpp b/libraries/platform/src/LinuxPlatform.cpp index b22344e728..df72b899b3 100644 --- a/libraries/platform/src/LinuxPlatform.cpp +++ b/libraries/platform/src/LinuxPlatform.cpp @@ -7,7 +7,7 @@ // #include "LinuxPlatform.h" -#include "platformJsonKeys.h" + #include #include diff --git a/libraries/platform/src/MACOSPlatform.cpp b/libraries/platform/src/MACOSPlatform.cpp index a215f46335..c48fe32079 100644 --- a/libraries/platform/src/MACOSPlatform.cpp +++ b/libraries/platform/src/MACOSPlatform.cpp @@ -7,7 +7,7 @@ // #include "MACOSPlatform.h" -#include "platformJsonKeys.h" + #include #include #include diff --git a/libraries/platform/src/WINPlatform.cpp b/libraries/platform/src/WINPlatform.cpp index f1ed146c93..93c7aee84d 100644 --- a/libraries/platform/src/WINPlatform.cpp +++ b/libraries/platform/src/WINPlatform.cpp @@ -7,7 +7,7 @@ // #include "WINPlatform.h" -#include "platformJsonKeys.h" + #ifdef Q_OS_WINDOWS #include #include diff --git a/libraries/platform/src/platformInstance.h b/libraries/platform/src/platformInstance.h index 4770200f07..7ebefc7c6d 100644 --- a/libraries/platform/src/platformInstance.h +++ b/libraries/platform/src/platformInstance.h @@ -11,6 +11,7 @@ #include #include +#include "platformJsonKeys.h" namespace platform { using json = nlohmann::json; From 52afa64215c7b9ba95492a1c2ab2f5b86e9a5d08 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Wed, 15 May 2019 16:33:05 -0700 Subject: [PATCH 03/16] undoing testing stuff also removing circular reference --- libraries/platform/src/AndroidPlatform.cpp | 2 +- libraries/platform/src/LinuxPlatform.cpp | 2 +- libraries/platform/src/MACOSPlatform.cpp | 1 + libraries/platform/src/WINPlatform.cpp | 1 + libraries/platform/src/platformInstance.cpp | 12 +-------- libraries/platform/src/platformInstance.h | 1 - libraries/platform/src/platformJsonKeys.h | 28 ++++++++++----------- 7 files changed, 19 insertions(+), 28 deletions(-) diff --git a/libraries/platform/src/AndroidPlatform.cpp b/libraries/platform/src/AndroidPlatform.cpp index e44e8e156a..58274df9f5 100644 --- a/libraries/platform/src/AndroidPlatform.cpp +++ b/libraries/platform/src/AndroidPlatform.cpp @@ -7,7 +7,7 @@ // #include "AndroidPlatform.h" - +#include "platformJsonKeys.h" #include #include diff --git a/libraries/platform/src/LinuxPlatform.cpp b/libraries/platform/src/LinuxPlatform.cpp index df72b899b3..b22344e728 100644 --- a/libraries/platform/src/LinuxPlatform.cpp +++ b/libraries/platform/src/LinuxPlatform.cpp @@ -7,7 +7,7 @@ // #include "LinuxPlatform.h" - +#include "platformJsonKeys.h" #include #include diff --git a/libraries/platform/src/MACOSPlatform.cpp b/libraries/platform/src/MACOSPlatform.cpp index c48fe32079..cdb9283657 100644 --- a/libraries/platform/src/MACOSPlatform.cpp +++ b/libraries/platform/src/MACOSPlatform.cpp @@ -7,6 +7,7 @@ // #include "MACOSPlatform.h" +#include "platformJsonKeys.h" #include #include diff --git a/libraries/platform/src/WINPlatform.cpp b/libraries/platform/src/WINPlatform.cpp index 93c7aee84d..cc10b47442 100644 --- a/libraries/platform/src/WINPlatform.cpp +++ b/libraries/platform/src/WINPlatform.cpp @@ -7,6 +7,7 @@ // #include "WINPlatform.h" +#include "platformJsonKeys.h" #ifdef Q_OS_WINDOWS #include diff --git a/libraries/platform/src/platformInstance.cpp b/libraries/platform/src/platformInstance.cpp index 705f5bd358..f1cef32096 100644 --- a/libraries/platform/src/platformInstance.cpp +++ b/libraries/platform/src/platformInstance.cpp @@ -10,17 +10,7 @@ #include "platform.h" #include - -#ifdef Q_OS_WIN -#include "WINPlatform.h" -#endif - -#ifdef Q_OS_MACOS -#include "MACOSPlatform.h" -#endif - -#ifdef Q_OS_LINUX -#endif +#include "platformInstance.h" using namespace platform; diff --git a/libraries/platform/src/platformInstance.h b/libraries/platform/src/platformInstance.h index 7ebefc7c6d..4770200f07 100644 --- a/libraries/platform/src/platformInstance.h +++ b/libraries/platform/src/platformInstance.h @@ -11,7 +11,6 @@ #include #include -#include "platformJsonKeys.h" namespace platform { using json = nlohmann::json; diff --git a/libraries/platform/src/platformJsonKeys.h b/libraries/platform/src/platformJsonKeys.h index cc2832a584..a46d5e5b89 100644 --- a/libraries/platform/src/platformJsonKeys.h +++ b/libraries/platform/src/platformJsonKeys.h @@ -11,20 +11,20 @@ namespace platform { namespace jsonKeys{ - const char* cpuBrand { "cpuBrand"}; - const char* cpuModel {"cpuModel"}; - const char* cpuClockSpeed {"clockSpeed"}; - const char* cpuNumCores { "numCores"}; - const char* gpuName {"GpuName"}; - const char* gpuMemory {"gpuMemory"}; - const char* gpuDriver {"gpuDriver"}; - const char* totalMemory {"totalMem"}; - const char* displayDescription { "description"}; - const char* displayName {"deviceName"}; - const char* displayCoordsLeft {"coordinatesleft"}; - const char* displayCoordsRight { "coordinatesright"}; - const char* displayCoordsTop { "coordinatestop"}; - const char* displayCoordsBottom { "coordinatesbottom"}; + static const char* cpuBrand { "cpuBrand"}; + static const char* cpuModel {"cpuModel"}; + static const char* cpuClockSpeed {"clockSpeed"}; + static const char* cpuNumCores { "numCores"}; + static const char* gpuName {"GpuName"}; + static const char* gpuMemory {"gpuMemory"}; + static const char* gpuDriver {"gpuDriver"}; + static const char* totalMemory {"totalMem"}; + static const char* displayDescription { "description"}; + static const char* displayName {"deviceName"}; + static const char* displayCoordsLeft {"coordinatesleft"}; + static const char* displayCoordsRight { "coordinatesright"}; + static const char* displayCoordsTop { "coordinatestop"}; + static const char* displayCoordsBottom { "coordinatesbottom"}; } } // namespace platform From 98fe059d970f8e502e06f091662e473615be19f7 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 16 May 2019 13:12:16 -0700 Subject: [PATCH 04/16] Fix blender::run crash Pass a shared_ptr of the HFMModel to the Blender. This will prevent the HFMModel from being destroyed on the main thread if an Avatar changes their skeletonModelURL. Also the _blendshapeOffset hash in Model has been eliminated, it was not necessary and was also a source of data races. The body of Blender::run has been updated slightly to reduce the number of allocation necessary for temporary QVectors. --- libraries/hfm/src/hfm/HFM.h | 1 + .../src/model-networking/ModelCache.h | 3 +- .../render-utils/src/CauterizedModel.cpp | 5 +- libraries/render-utils/src/Model.cpp | 153 ++++++++---------- libraries/render-utils/src/Model.h | 5 - .../render-utils/src/SoftAttachmentModel.cpp | 2 +- 6 files changed, 70 insertions(+), 99 deletions(-) diff --git a/libraries/hfm/src/hfm/HFM.h b/libraries/hfm/src/hfm/HFM.h index 8c60169289..484a10aa3b 100644 --- a/libraries/hfm/src/hfm/HFM.h +++ b/libraries/hfm/src/hfm/HFM.h @@ -291,6 +291,7 @@ public: class Model { public: using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; QString originalURL; QString author; diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index f9ae2dccd6..5b78c18184 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -46,6 +46,7 @@ public: bool isHFMModelLoaded() const { return (bool)_hfmModel; } const HFMModel& getHFMModel() const { return *_hfmModel; } + const HFMModel::ConstPointer& getConstHFMModelPointer() const { return _hfmModel; } const MaterialMapping& getMaterialMapping() const { return _materialMapping; } const GeometryMeshes& getMeshes() const { return *_meshes; } const std::shared_ptr getShapeMaterial(int shapeID) const; @@ -59,7 +60,7 @@ public: protected: // Shared across all geometries, constant throughout lifetime - std::shared_ptr _hfmModel; + HFMModel::ConstPointer _hfmModel; MaterialMapping _materialMapping; std::shared_ptr _meshes; std::shared_ptr _meshParts; diff --git a/libraries/render-utils/src/CauterizedModel.cpp b/libraries/render-utils/src/CauterizedModel.cpp index c700f1ad3f..2cc3f49259 100644 --- a/libraries/render-utils/src/CauterizedModel.cpp +++ b/libraries/render-utils/src/CauterizedModel.cpp @@ -86,8 +86,6 @@ void CauterizedModel::createRenderItemSet() { // Create the render payloads int numParts = (int)mesh->getNumParts(); for (int partIndex = 0; partIndex < numParts; partIndex++) { - initializeBlendshapes(hfmModel.meshes[i], i); - auto ptr = std::make_shared(shared_from_this(), i, partIndex, shapeID, transform, offset); _modelMeshRenderItems << std::static_pointer_cast(ptr); auto material = getGeometry()->getShapeMaterial(shapeID); @@ -96,7 +94,6 @@ void CauterizedModel::createRenderItemSet() { shapeID++; } } - _blendshapeOffsetsInitialized = true; } else { Model::createRenderItemSet(); } @@ -181,7 +178,7 @@ void CauterizedModel::updateClusterMatrices() { // post the blender if we're not currently waiting for one to finish auto modelBlender = DependencyManager::get(); - if (_blendshapeOffsetsInitialized && modelBlender->shouldComputeBlendshapes() && hfmModel.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) { + if (modelBlender->shouldComputeBlendshapes() && hfmModel.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) { _blendedBlendshapeCoefficients = _blendshapeCoefficients; modelBlender->noteRequiresBlend(getThisPointer()); } diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 96979a23a9..7cb20de526 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -314,10 +314,8 @@ bool Model::updateGeometry() { state.clusterDualQuaternions.resize(mesh.clusters.size()); state.clusterMatrices.resize(mesh.clusters.size()); _meshStates.push_back(state); - initializeBlendshapes(mesh, i); i++; } - _blendshapeOffsetsInitialized = true; needFullUpdate = true; emit rigReady(); } @@ -1022,9 +1020,6 @@ void Model::removeFromScene(const render::ScenePointer& scene, render::Transacti _modelMeshRenderItemShapes.clear(); _priorityMap.clear(); - _blendshapeOffsets.clear(); - _blendshapeOffsetsInitialized = false; - _addedToScene = false; _renderInfoVertexCount = 0; @@ -1415,7 +1410,7 @@ void Model::updateClusterMatrices() { // post the blender if we're not currently waiting for one to finish auto modelBlender = DependencyManager::get(); - if (_blendshapeOffsetsInitialized && modelBlender->shouldComputeBlendshapes() && hfmModel.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) { + if (modelBlender->shouldComputeBlendshapes() && hfmModel.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) { _blendedBlendshapeCoefficients = _blendshapeCoefficients; modelBlender->noteRequiresBlend(getThisPointer()); } @@ -1423,8 +1418,6 @@ void Model::updateClusterMatrices() { void Model::deleteGeometry() { _deleteGeometryCounter++; - _blendshapeOffsets.clear(); - _blendshapeOffsetsInitialized = false; _meshStates.clear(); _rig.destroyAnimGraph(); _blendedBlendshapeCoefficients.clear(); @@ -1494,7 +1487,6 @@ void Model::createRenderItemSet() { // Create the render payloads int numParts = (int)mesh->getNumParts(); for (int partIndex = 0; partIndex < numParts; partIndex++) { - initializeBlendshapes(hfmModel.meshes[i], i); _modelMeshRenderItems << std::make_shared(shared_from_this(), i, partIndex, shapeID, transform, offset); auto material = getGeometry()->getShapeMaterial(shapeID); _modelMeshMaterialNames.push_back(material ? material->getName() : ""); @@ -1502,7 +1494,6 @@ void Model::createRenderItemSet() { shapeID++; } } - _blendshapeOffsetsInitialized = true; } bool Model::isRenderable() const { @@ -1722,119 +1713,105 @@ void packBlendshapeOffsetTo_Pos_F32_3xSN10_Nor_3xSN10_Tan_3xSN10(glm::uvec4& pac class Blender : public QRunnable { public: - Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointer& geometry, const QVector& blendshapeCoefficients); + Blender(ModelPointer model, HFMModel::ConstPointer hfmModel, int blendNumber, const QVector& blendshapeCoefficients); virtual void run() override; private: - ModelPointer _model; + HFMModel::ConstPointer _hfmModel; int _blendNumber; - Geometry::WeakPointer _geometry; QVector _blendshapeCoefficients; }; -Blender::Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointer& geometry, const QVector& blendshapeCoefficients) : +Blender::Blender(ModelPointer model, HFMModel::ConstPointer hfmModel, int blendNumber, const QVector& blendshapeCoefficients) : _model(model), + _hfmModel(hfmModel), _blendNumber(blendNumber), - _geometry(geometry), _blendshapeCoefficients(blendshapeCoefficients) { } void Blender::run() { - QVector blendshapeOffsets; + DETAILED_PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } }); + int numBlendshapeOffsets = 0; // number of offsets required for all meshes. + int numMeshes = 0; // number of meshes in this model. + int maxVertsInMesh = 0; // number of vertices in the largest mesh. + for (auto meshIter = _hfmModel->meshes.cbegin(); meshIter != _hfmModel->meshes.cend(); ++meshIter) { + numMeshes++; + int numVertsInMesh = meshIter->vertices.size(); + numBlendshapeOffsets += numVertsInMesh; + } + + // all elements are default constructed to zero offsets. + QVector packedBlendshapeOffsets(numBlendshapeOffsets); + QVector unpackedBlendshapeOffsets(numBlendshapeOffsets); + + // allocate the required size QVector blendedMeshSizes; - if (_model && _model->isLoaded()) { - DETAILED_PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } }); - int offset = 0; - const auto& meshes = _model->getHFMModel().meshes; - int meshIndex = 0; - for(const HFMMesh& mesh : meshes) { - auto modelMeshBlendshapeOffsets = _model->_blendshapeOffsets.find(meshIndex++); - if (mesh.blendshapes.isEmpty() || modelMeshBlendshapeOffsets == _model->_blendshapeOffsets.end()) { - // Not blendshaped or not initialized - blendedMeshSizes.push_back(0); + blendedMeshSizes.reserve(numMeshes); + + int offset = 0; + for (auto meshIter = _hfmModel->meshes.cbegin(); meshIter != _hfmModel->meshes.cend(); ++meshIter) { + if (meshIter->blendshapes.isEmpty()) { + blendedMeshSizes.push_back(0); + continue; + } + int numVertsInMesh = meshIter->vertices.size(); + blendedMeshSizes.push_back(numVertsInMesh); + + // for each blendshape in this mesh, accumulate the offsets into unpackedBlendshapeOffsets. + const float NORMAL_COEFFICIENT_SCALE = 0.01f; + for (int i = 0, n = qMin(_blendshapeCoefficients.size(), meshIter->blendshapes.size()); i < n; i++) { + float vertexCoefficient = _blendshapeCoefficients.at(i); + const float EPSILON = 0.0001f; + if (vertexCoefficient < EPSILON) { continue; } - if (mesh.vertices.size() != modelMeshBlendshapeOffsets->second.size()) { - // Mesh sizes don't match. Something has gone wrong - blendedMeshSizes.push_back(0); - continue; - } + float normalCoefficient = vertexCoefficient * NORMAL_COEFFICIENT_SCALE; + const HFMBlendshape& blendshape = meshIter->blendshapes.at(i); + for (int j = 0; j < blendshape.indices.size(); ++j) { + int index = blendshape.indices.at(j); - blendshapeOffsets += modelMeshBlendshapeOffsets->second; - BlendshapeOffset* meshBlendshapeOffsets = blendshapeOffsets.data() + offset; - int numVertices = modelMeshBlendshapeOffsets->second.size(); - blendedMeshSizes.push_back(numVertices); - offset += numVertices; - std::vector unpackedBlendshapeOffsets(modelMeshBlendshapeOffsets->second.size()); - - const float NORMAL_COEFFICIENT_SCALE = 0.01f; - for (int i = 0, n = qMin(_blendshapeCoefficients.size(), mesh.blendshapes.size()); i < n; i++) { - float vertexCoefficient = _blendshapeCoefficients.at(i); - const float EPSILON = 0.0001f; - if (vertexCoefficient < EPSILON) { - continue; - } - - float normalCoefficient = vertexCoefficient * NORMAL_COEFFICIENT_SCALE; - const HFMBlendshape& blendshape = mesh.blendshapes.at(i); - for (int j = 0; j < blendshape.indices.size(); ++j) { - int index = blendshape.indices.at(j); - - auto& currentBlendshapeOffset = unpackedBlendshapeOffsets[index]; - currentBlendshapeOffset.positionOffset += blendshape.vertices.at(j) * vertexCoefficient; - - currentBlendshapeOffset.normalOffset += blendshape.normals.at(j) * normalCoefficient; - if (j < blendshape.tangents.size()) { - currentBlendshapeOffset.tangentOffset += blendshape.tangents.at(j) * normalCoefficient; - } - } - } - - // Blendshape offsets are generrated, now let's pack it on its way to gpu - // FIXME it feels like we could be more effectively using SIMD here - { - auto unpacked = unpackedBlendshapeOffsets.data(); - auto packed = meshBlendshapeOffsets; - for (int j = 0; j < (int)unpackedBlendshapeOffsets.size(); ++j) { - packBlendshapeOffsetTo_Pos_F32_3xSN10_Nor_3xSN10_Tan_3xSN10((*packed).packedPosNorTan, (*unpacked)); - ++unpacked; - ++packed; + auto& currentBlendshapeOffset = unpackedBlendshapeOffsets[offset + index]; + currentBlendshapeOffset.positionOffset += blendshape.vertices.at(j) * vertexCoefficient; + currentBlendshapeOffset.normalOffset += blendshape.normals.at(j) * normalCoefficient; + if (j < blendshape.tangents.size()) { + currentBlendshapeOffset.tangentOffset += blendshape.tangents.at(j) * normalCoefficient; } } } + offset += numVertsInMesh; } + + // convert unpackedBlendshapeOffsets into packedBlendshapeOffsets for the gpu. + // FIXME it feels like we could be more effectively using SIMD here + { + auto unpacked = unpackedBlendshapeOffsets.data(); + auto packed = packedBlendshapeOffsets.data(); + for (int i = 0; i < unpackedBlendshapeOffsets.size(); ++i) { + packBlendshapeOffsetTo_Pos_F32_3xSN10_Nor_3xSN10_Tan_3xSN10((*packed).packedPosNorTan, (*unpacked)); + ++unpacked; + ++packed; + } + } + // post the result to the ModelBlender, which will dispatch to the model if still alive QMetaObject::invokeMethod(DependencyManager::get().data(), "setBlendedVertices", - Q_ARG(ModelPointer, _model), Q_ARG(int, _blendNumber), Q_ARG(QVector, blendshapeOffsets), Q_ARG(QVector, blendedMeshSizes)); + Q_ARG(ModelPointer, _model), Q_ARG(int, _blendNumber), + Q_ARG(QVector, packedBlendshapeOffsets), + Q_ARG(QVector, blendedMeshSizes)); } bool Model::maybeStartBlender() { if (isLoaded()) { - QThreadPool::globalInstance()->start(new Blender(getThisPointer(), ++_blendNumber, _renderGeometry, _blendshapeCoefficients)); + QThreadPool::globalInstance()->start(new Blender(getThisPointer(), getGeometry()->getConstHFMModelPointer(), + ++_blendNumber, _blendshapeCoefficients)); return true; } return false; } -void Model::initializeBlendshapes(const HFMMesh& mesh, int index) { - if (mesh.blendshapes.empty()) { - // mesh doesn't have blendshape, did we allocate one though ? - if (_blendshapeOffsets.find(index) != _blendshapeOffsets.end()) { - qWarning() << "Mesh does not have Blendshape yet the blendshapeOffsets are allocated ?"; - } - return; - } - // Mesh has blendshape, let s allocate the local buffer if not done yet - if (_blendshapeOffsets.find(index) == _blendshapeOffsets.end()) { - QVector blendshapeOffset; - blendshapeOffset.fill(BlendshapeOffset(), mesh.vertices.size()); - _blendshapeOffsets[index] = blendshapeOffset; - } -} - ModelBlender::ModelBlender() : _pendingBlenders(0) { } diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index 7c861a3bc1..2ea1f87fae 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -363,8 +363,6 @@ public: void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName); void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName); - std::unordered_map> _blendshapeOffsets; - public slots: void loadURLFinished(bool success); @@ -446,7 +444,6 @@ protected: QVector _blendshapeCoefficients; QVector _blendedBlendshapeCoefficients; int _blendNumber { 0 }; - bool _blendshapeOffsetsInitialized { false }; mutable QMutex _mutex{ QMutex::Recursive }; @@ -509,8 +506,6 @@ protected: bool shouldInvalidatePayloadShapeKey(int meshIndex); - void initializeBlendshapes(const HFMMesh& mesh, int index); - private: float _loadingPriority { 0.0f }; diff --git a/libraries/render-utils/src/SoftAttachmentModel.cpp b/libraries/render-utils/src/SoftAttachmentModel.cpp index a6f82e1417..186f9e682a 100644 --- a/libraries/render-utils/src/SoftAttachmentModel.cpp +++ b/libraries/render-utils/src/SoftAttachmentModel.cpp @@ -71,7 +71,7 @@ void SoftAttachmentModel::updateClusterMatrices() { // post the blender if we're not currently waiting for one to finish auto modelBlender = DependencyManager::get(); - if (_blendshapeOffsetsInitialized && modelBlender->shouldComputeBlendshapes() && hfmModel.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) { + if (modelBlender->shouldComputeBlendshapes() && hfmModel.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) { _blendedBlendshapeCoefficients = _blendshapeCoefficients; modelBlender->noteRequiresBlend(getThisPointer()); } From 9e00920884357b04d6c99a3ebe163daee3dab526 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 16 May 2019 14:30:11 -0700 Subject: [PATCH 05/16] adding computer model to platform for macos --- libraries/platform/src/MACOSPlatform.cpp | 13 +++++++++++++ libraries/platform/src/platform.cpp | 4 ++++ libraries/platform/src/platform.h | 1 + libraries/platform/src/platformInstance.h | 3 +++ libraries/shared/src/GPUIdent.cpp | 2 ++ 5 files changed, 23 insertions(+) diff --git a/libraries/platform/src/MACOSPlatform.cpp b/libraries/platform/src/MACOSPlatform.cpp index cdb9283657..6b2e39bac5 100644 --- a/libraries/platform/src/MACOSPlatform.cpp +++ b/libraries/platform/src/MACOSPlatform.cpp @@ -16,6 +16,7 @@ #ifdef Q_OS_MAC #include #include +#include #endif using namespace platform; @@ -34,6 +35,7 @@ static void getCpuId( uint32_t* p, uint32_t ax ) #endif } + void MACOSInstance::enumerateCpu() { json cpu = {}; uint32_t cpuInfo[4]={0,0,0,0}; @@ -62,6 +64,16 @@ void MACOSInstance::enumerateCpu() { cpu[jsonKeys::cpuNumCores] = std::thread::hardware_concurrency(); _cpu.push_back(cpu); + + + //get system name + size_t len=0; + sysctlbyname("hw.model",NULL, &len, NULL, 0); + char* model = (char *) malloc(sizeof(char)*len+1); + sysctlbyname("hw.model", model, &len, NULL,0); + + _computerModel=std::string(model); + free(model); } void MACOSInstance::enumerateGpu() { @@ -73,6 +85,7 @@ void MACOSInstance::enumerateGpu() { _gpu.push_back(gpu); _display = ident->getOutput(); + } void MACOSInstance::enumerateMemory() { diff --git a/libraries/platform/src/platform.cpp b/libraries/platform/src/platform.cpp index 27e773d435..6f9dc78768 100644 --- a/libraries/platform/src/platform.cpp +++ b/libraries/platform/src/platform.cpp @@ -77,3 +77,7 @@ int platform::getNumMemory() { json platform::getMemory(int index) { return _instance->getMemory(index); } + +std::string platform::getComputerModel(){ + return _instance->getComputerModel(); +} diff --git a/libraries/platform/src/platform.h b/libraries/platform/src/platform.h index 895114ba6d..250b9144ac 100644 --- a/libraries/platform/src/platform.h +++ b/libraries/platform/src/platform.h @@ -32,6 +32,7 @@ json getDisplay(int index); int getNumMemory(); json getMemory(int index); +std::string getComputerModel(); } // namespace platform #endif // hifi_platform_h diff --git a/libraries/platform/src/platformInstance.h b/libraries/platform/src/platformInstance.h index 4770200f07..59aede1fb3 100644 --- a/libraries/platform/src/platformInstance.h +++ b/libraries/platform/src/platformInstance.h @@ -31,6 +31,8 @@ public: int getNumDisplay() { return (int)_display.size(); } json getDisplay(int index); + std::string getComputerModel(){return _computerModel;} + void virtual enumerateCpu()=0; void virtual enumerateMemory()=0; void virtual enumerateGpu()=0; @@ -42,6 +44,7 @@ protected: std::vector _memory; std::vector _gpu; std::vector _display; + std::string _computerModel; }; } // namespace platform diff --git a/libraries/shared/src/GPUIdent.cpp b/libraries/shared/src/GPUIdent.cpp index a78ded483b..658f68a689 100644 --- a/libraries/shared/src/GPUIdent.cpp +++ b/libraries/shared/src/GPUIdent.cpp @@ -22,6 +22,7 @@ #elif defined(Q_OS_MAC) #include +#include #endif #include @@ -56,6 +57,7 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer) } } } + _dedicatedMemoryMB = bestVRAM; CGLDestroyRendererInfo(rendererInfo); From d924560af0dfa4f797f1fae40b52297c432e53e6 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 16 May 2019 14:36:31 -0700 Subject: [PATCH 06/16] undoing test code for gcc warnings --- libraries/platform/src/AndroidPlatform.cpp | 16 ++++++++-------- libraries/platform/src/LinuxPlatform.cpp | 16 ++++++++-------- libraries/platform/src/MACOSPlatform.cpp | 16 ++++++++-------- libraries/platform/src/WINPlatform.cpp | 16 ++++++++-------- libraries/platform/src/platformJsonKeys.h | 3 +++ 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/libraries/platform/src/AndroidPlatform.cpp b/libraries/platform/src/AndroidPlatform.cpp index 58274df9f5..4351b14688 100644 --- a/libraries/platform/src/AndroidPlatform.cpp +++ b/libraries/platform/src/AndroidPlatform.cpp @@ -15,19 +15,19 @@ using namespace platform; void AndroidInstance::enumerateCpu() { json cpu; - cpu[jsonKeys::cpuBrand] = ""; - cpu[jsonKeys::cpuModel] = ""; - cpu[jsonKeys::cpuClockSpeed] = ""; - cpu[jsonKeys::cpuNumCores] = ""; + cpu["cpuBrand"] = ""; + cpu["cpuModel"] = ""; + cpu["cpuClockSpeed"] = ""; + cpu["cpuNumCores"] = ""; _cpu.push_back(cpu); } void AndroidInstance::enumerateGpu() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData(); - gpu[jsonKeys::gpuMemory] = ident->getMemory(); - gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData(); + gpu["gpuName"] = ident->getName().toUtf8().constData(); + gpu["gpuMemory"] = ident->getMemory(); + gpu["gpuDriver"] = ident->getDriver().toUtf8().constData(); _gpu.push_back(gpu); _display = ident->getOutput(); @@ -35,6 +35,6 @@ void AndroidInstance::enumerateGpu() { void AndroidInstance::enumerateMemory() { json ram = {}; - ram[jsonKeys::totalMemory]=""; + ram["totalMemory"]=""; _memory.push_back(ram); } diff --git a/libraries/platform/src/LinuxPlatform.cpp b/libraries/platform/src/LinuxPlatform.cpp index b22344e728..01d89a4462 100644 --- a/libraries/platform/src/LinuxPlatform.cpp +++ b/libraries/platform/src/LinuxPlatform.cpp @@ -15,10 +15,10 @@ using namespace platform; void LinuxInstance::enumerateCpu() { json cpu = {}; - cpu[jsonKeys::cpuBrand] = ""; - cpu[jsonKeys::cpuModel] = ""; - cpu[jsonKeys::cpuClockSpeed] = ""; - cpu[jsonKeys::cpuNumCores] = ""; + cpu["cpuBrand"] = ""; + cpu["cpuModel"] = ""; + cpu["cpuClockSpeed"] = ""; + cpu["cpuNumCores"] = ""; _cpu.push_back(cpu); } @@ -26,9 +26,9 @@ void LinuxInstance::enumerateCpu() { void LinuxInstance::enumerateGpu() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData(); - gpu[jsonKeys::gpuMemory] = ident->getMemory(); - gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData(); + gpu["gpuName"] = ident->getName().toUtf8().constData(); + gpu["gpuMemory"] = ident->getMemory(); + gpu["gpuDriver"] = ident->getDriver().toUtf8().constData(); _gpu.push_back(gpu); _display = ident->getOutput(); @@ -36,7 +36,7 @@ void LinuxInstance::enumerateGpu() { void LinuxInstance::enumerateMemory() { json ram = {}; - ram[jsonKeys::totalMemory]=""; + ram["totalMemory"]=""; _memory.push_back(ram); } diff --git a/libraries/platform/src/MACOSPlatform.cpp b/libraries/platform/src/MACOSPlatform.cpp index 6b2e39bac5..151df96719 100644 --- a/libraries/platform/src/MACOSPlatform.cpp +++ b/libraries/platform/src/MACOSPlatform.cpp @@ -58,10 +58,10 @@ void MACOSInstance::enumerateCpu() { } } - cpu[jsonKeys::cpuBrand] = CPUBrandString; - cpu[jsonKeys::cpuModel] = CPUModelString; - cpu[jsonKeys::cpuClockSpeed] = CPUClockString; - cpu[jsonKeys::cpuNumCores] = std::thread::hardware_concurrency(); + cpu["cpuBrand"] = CPUBrandString; + cpu["cpuModel"] = CPUModelString; + cpu["cpuClockSpeed"] = CPUClockString; + cpu["cpuNumCores"] = std::thread::hardware_concurrency(); _cpu.push_back(cpu); @@ -79,9 +79,9 @@ void MACOSInstance::enumerateCpu() { void MACOSInstance::enumerateGpu() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData(); - gpu[jsonKeys::gpuMemory] = ident->getMemory(); - gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData(); + gpu["gpuName"] = ident->getName().toUtf8().constData(); + gpu["gpuMemory"] = ident->getMemory(); + gpu["gpuDriver"] = ident->getDriver().toUtf8().constData(); _gpu.push_back(gpu); _display = ident->getOutput(); @@ -94,7 +94,7 @@ void MACOSInstance::enumerateMemory() { #ifdef Q_OS_MAC long pages = sysconf(_SC_PHYS_PAGES); long page_size = sysconf(_SC_PAGE_SIZE); - ram[jsonKeys::totalMemory] = pages * page_size;; + ram["totalMemory"] = pages * page_size;; #endif _memory.push_back(ram); } diff --git a/libraries/platform/src/WINPlatform.cpp b/libraries/platform/src/WINPlatform.cpp index cc10b47442..b39c83889b 100644 --- a/libraries/platform/src/WINPlatform.cpp +++ b/libraries/platform/src/WINPlatform.cpp @@ -47,10 +47,10 @@ void WINInstance::enumerateCpu() { } } - cpu[platform::json::cpuBrand] = CPUBrandString; - cpu[jsonKeys::cpuModel] = CPUModelString; - cpu[jsonKeys::cpuClockSpeed] = CPUClockString; - cpu[jsonKeys::cpuNumCores] = std::thread::hardware_concurrency(); + cpu["cpuBrand"] = CPUBrandString; + cpu["cpuModel"] = CPUModelString; + cpu["cpuClockSpeed"] = CPUClockString; + cpu["cpuNumCores"] = std::thread::hardware_concurrency(); #endif _cpu.push_back(cpu); @@ -61,9 +61,9 @@ void WINInstance::enumerateGpu() { GPUIdent* ident = GPUIdent::getInstance(); json gpu = {}; - gpu[jsonKeys::gpuName] = ident->getName().toUtf8().constData(); - gpu[jsonKeys::gpuMemory] = ident->getMemory(); - gpu[jsonKeys::gpuDriver] = ident->getDriver().toUtf8().constData(); + gpu["gpuName"] = ident->getName().toUtf8().constData(); + gpu["gpuMemory"] = ident->getMemory(); + gpu["gpuDriver"] = ident->getDriver().toUtf8().constData(); _gpu.push_back(gpu); _display = ident->getOutput(); @@ -77,7 +77,7 @@ void WINInstance::enumerateMemory() { statex.dwLength = sizeof(statex); GlobalMemoryStatusEx(&statex); int totalRam = statex.ullTotalPhys / 1024 / 1024; - ram[jsonKeys::totalMemory] = totalRam; + ram["totalMemory"] = totalRam; #endif _memory.push_back(ram); } diff --git a/libraries/platform/src/platformJsonKeys.h b/libraries/platform/src/platformJsonKeys.h index a46d5e5b89..629aa30e34 100644 --- a/libraries/platform/src/platformJsonKeys.h +++ b/libraries/platform/src/platformJsonKeys.h @@ -11,6 +11,7 @@ namespace platform { namespace jsonKeys{ +#if 0 static const char* cpuBrand { "cpuBrand"}; static const char* cpuModel {"cpuModel"}; static const char* cpuClockSpeed {"clockSpeed"}; @@ -25,6 +26,8 @@ namespace platform { static const char* displayCoordsRight { "coordinatesright"}; static const char* displayCoordsTop { "coordinatestop"}; static const char* displayCoordsBottom { "coordinatesbottom"}; +#endif + } } // namespace platform From c1c2efc71dbc392311a0acf3ecc1179bd5cc3b9c Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 16 May 2019 15:47:03 -0700 Subject: [PATCH 07/16] getting gpu name via profiler parsing --- libraries/shared/src/GPUIdent.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libraries/shared/src/GPUIdent.cpp b/libraries/shared/src/GPUIdent.cpp index 658f68a689..773e40aaee 100644 --- a/libraries/shared/src/GPUIdent.cpp +++ b/libraries/shared/src/GPUIdent.cpp @@ -22,7 +22,10 @@ #elif defined(Q_OS_MAC) #include -#include +#include +#include +#include + #endif #include @@ -57,6 +60,26 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer) } } } + + //get gpu name + FILE* stream = popen("system_profiler SPDisplaysDataType | grep Chipset", "r"); + + std::ostringstream hostStream; + while (!feof(stream) && !ferror(stream)) { + char buf[128]; + int bytesRead = fread(buf, 1, 128, stream); + hostStream.write(buf, bytesRead); + } + + QString result = QString::fromStdString(hostStream.str()); + QStringList parts = result.split('\n'); + std::string name; + + for (int i = 0; i < parts.size(); ++i) { + if (parts[i].toLower().contains("radeon") || parts[i].toLower().contains("nvidia")) { + _name=parts[i]; + } + } _dedicatedMemoryMB = bestVRAM; CGLDestroyRendererInfo(rendererInfo); From fee20d9e466d214e3956782625ccd5effd504613 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 16 May 2019 11:41:25 -0700 Subject: [PATCH 08/16] render scripting interface + renderMethod control --- interface/src/Application.cpp | 9 ++- interface/src/Application.h | 1 - .../scripting/RenderScriptingInterface.cpp | 39 ++++++++++ .../src/scripting/RenderScriptingInterface.h | 71 +++++++++++++++++++ libraries/render-utils/src/RenderViewTask.cpp | 6 +- libraries/task/src/task/Config.h | 3 +- 6 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 interface/src/scripting/RenderScriptingInterface.cpp create mode 100644 interface/src/scripting/RenderScriptingInterface.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3dc49e89d6..7978cd39da 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -193,8 +193,7 @@ #include "scripting/TTSScriptingInterface.h" #include "scripting/KeyboardScriptingInterface.h" #include "scripting/RefreshRateScriptingInterface.h" - - +#include "scripting/RenderScriptingInterface.h" #if defined(Q_OS_MAC) || defined(Q_OS_WIN) #include "SpeechRecognizer.h" @@ -3332,7 +3331,7 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) { surfaceContext->setContextProperty("LODManager", DependencyManager::get().data()); surfaceContext->setContextProperty("HMD", DependencyManager::get().data()); surfaceContext->setContextProperty("Scene", DependencyManager::get().data()); - surfaceContext->setContextProperty("Render", _graphicsEngine.getRenderEngine()->getConfiguration().get()); + surfaceContext->setContextProperty("Render", RenderScriptingInterface::getInstance()); surfaceContext->setContextProperty("Workload", _gameWorkload._engine->getConfiguration().get()); surfaceContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface()); surfaceContext->setContextProperty("Snapshot", DependencyManager::get().data()); @@ -3447,7 +3446,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get().data()); surfaceContext->setContextProperty("SoundCache", DependencyManager::get().data()); surfaceContext->setContextProperty("AvatarBookmarks", DependencyManager::get().data()); - surfaceContext->setContextProperty("Render", AbstractViewStateInterface::instance()->getRenderEngine()->getConfiguration().get()); + surfaceContext->setContextProperty("Render", RenderScriptingInterface::getInstance()); surfaceContext->setContextProperty("Workload", qApp->getGameWorkload()._engine->getConfiguration().get()); surfaceContext->setContextProperty("Controller", DependencyManager::get().data()); surfaceContext->setContextProperty("Pointers", DependencyManager::get().data()); @@ -7401,7 +7400,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe scriptEngine->registerFunction("HMD", "getHUDLookAtPosition3D", HMDScriptingInterface::getHUDLookAtPosition3D, 0); scriptEngine->registerGlobalObject("Scene", DependencyManager::get().data()); - scriptEngine->registerGlobalObject("Render", _graphicsEngine.getRenderEngine()->getConfiguration().get()); + scriptEngine->registerGlobalObject("Render", RenderScriptingInterface::getInstance()); scriptEngine->registerGlobalObject("Workload", _gameWorkload._engine->getConfiguration().get()); GraphicsScriptingInterface::registerMetaTypes(scriptEngine.data()); diff --git a/interface/src/Application.h b/interface/src/Application.h index 34a5ba1d0c..17f5b24383 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -290,7 +290,6 @@ public: render::EnginePointer getRenderEngine() override { return _graphicsEngine.getRenderEngine(); } gpu::ContextPointer getGPUContext() const { return _graphicsEngine.getGPUContext(); } - const GameWorkload& getGameWorkload() const { return _gameWorkload; } virtual void pushPostUpdateLambda(void* key, const std::function& func) override; diff --git a/interface/src/scripting/RenderScriptingInterface.cpp b/interface/src/scripting/RenderScriptingInterface.cpp new file mode 100644 index 0000000000..0b862eb007 --- /dev/null +++ b/interface/src/scripting/RenderScriptingInterface.cpp @@ -0,0 +1,39 @@ +// +// Created by Sam Gondelman on 5/16/19 +// Copyright 2013-2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#include "RenderScriptingInterface.h" + +const QString DEFERRED = "deferred"; +const QString FORWARD = "forward"; + +RenderScriptingInterface* RenderScriptingInterface::getInstance() { + static RenderScriptingInterface sharedInstance; + return &sharedInstance; +} + +RenderScriptingInterface::RenderScriptingInterface() { + setRenderMethod((render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD); +} + +QString RenderScriptingInterface::getRenderMethod() { + return (render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD; +} + +void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) { + auto config = dynamic_cast(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); + if (config) { + if (renderMethod == DEFERRED) { + _renderMethodSetting.set(render::Args::RenderMethod::DEFERRED); + config->setBranch(render::Args::RenderMethod::DEFERRED); + emit config->dirtyEnabled(); + } else if (renderMethod == FORWARD) { + _renderMethodSetting.set(render::Args::RenderMethod::FORWARD); + config->setBranch(render::Args::RenderMethod::FORWARD); + emit config->dirtyEnabled(); + } + } +} \ No newline at end of file diff --git a/interface/src/scripting/RenderScriptingInterface.h b/interface/src/scripting/RenderScriptingInterface.h new file mode 100644 index 0000000000..71a8a64fdb --- /dev/null +++ b/interface/src/scripting/RenderScriptingInterface.h @@ -0,0 +1,71 @@ +// +// Created by Sam Gondelman on 5/16/19 +// Copyright 2013-2019 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_RenderScriptingInterface_h +#define hifi_RenderScriptingInterface_h + +#include +#include "Application.h" + +#include "RenderForward.h" + +/**jsdoc + * The Render API allows you to configure the graphics engine + * + * @namespace Render + * + * @hifi-interface + * @hifi-client-entity + * @hifi-avatar + */ +class RenderScriptingInterface : public QObject { + Q_OBJECT + Q_PROPERTY(QString renderMethod READ getRenderMethod WRITE setRenderMethod) + +public: + RenderScriptingInterface(); + + static RenderScriptingInterface* getInstance(); + +public slots: + /**jsdoc + * Get a config for a job by name + * @function Render.getConfig + * @param {string} name - Can be: + * - . Search for the first job named job_name traversing the the sub graph of task and jobs (from this task as root) + * - .[.]. Allows you to first look for the parent_name job (from this task as root) and then search from there for the + * optional sub_parent_names and finally from there looking for the job_name (assuming every job in the path is found) + * @returns {object} The sub job config. + */ + QObject* getConfig(const QString& name) { return qApp->getRenderEngine()->getConfiguration()->getConfig(name); } + + /**jsdoc + * Gets the current render method + * @function Render.getRenderMethod + * @returns {string} "deferred" or "forward" + */ + QString getRenderMethod(); + + /**jsdoc + * Sets the current render method + * @function Render.setRenderMethod + * @param {string} renderMethod - "deferred" or "forward" + */ + void setRenderMethod(const QString& renderMethod); + +private: + Setting::Handle _renderMethodSetting { "renderMethod", +#ifdef RENDER_FORWARD + render::Args::RenderMethod::FORWARD +#else + render::Args::RenderMethod::DEFERRED +#endif + }; +}; + +#endif // hifi_RenderScriptingInterface_h diff --git a/libraries/render-utils/src/RenderViewTask.cpp b/libraries/render-utils/src/RenderViewTask.cpp index ffaecedb0b..93a3ff2d67 100644 --- a/libraries/render-utils/src/RenderViewTask.cpp +++ b/libraries/render-utils/src/RenderViewTask.cpp @@ -15,8 +15,6 @@ #include "RenderDeferredTask.h" #include "RenderForwardTask.h" -#include - void RenderShadowsAndDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) { task.addJob("SetRenderMethodTask", render::Args::DEFERRED); @@ -34,9 +32,9 @@ void RenderShadowsAndDeferredTask::build(JobModel& task, const render::Varying& } void DeferredForwardSwitchJob::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) { - task.addBranch("RenderShadowsAndDeferredTask", RENDER_FORWARD ? 1 : 0, input, cullFunctor, tagBits, tagMask); + task.addBranch("RenderShadowsAndDeferredTask", 0, input, cullFunctor, tagBits, tagMask); - task.addBranch("RenderForwardTask", RENDER_FORWARD ? 0 : 1, input); + task.addBranch("RenderForwardTask", 1, input); } void RenderViewTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) { diff --git a/libraries/task/src/task/Config.h b/libraries/task/src/task/Config.h index 891970006d..ab76bc5fba 100644 --- a/libraries/task/src/task/Config.h +++ b/libraries/task/src/task/Config.h @@ -220,7 +220,6 @@ public: TaskConfig() = default; TaskConfig(bool enabled) : JobConfig(enabled) {} - /**jsdoc * @function Render.getConfig * @param {string} name @@ -262,7 +261,7 @@ public: class SwitchConfig : public JobConfig { Q_OBJECT - Q_PROPERTY(bool branch READ getBranch WRITE setBranch NOTIFY dirtyEnabled) + Q_PROPERTY(int branch READ getBranch WRITE setBranch NOTIFY dirtyEnabled) public: uint8_t getBranch() const { return _branch; } From 70a4d6e8d536d6f50a5a29788dde06c83eb4a02f Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 16 May 2019 16:15:05 -0700 Subject: [PATCH 09/16] Implement Performance settings and VR mode top bar switch --- .../settingsApp/general/General.qml | 13 ++++++++ .../simplifiedUI/topBar/SimplifiedTopBar.qml | 30 +++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/simplifiedUI/settingsApp/general/General.qml b/interface/resources/qml/hifi/simplifiedUI/settingsApp/general/General.qml index cabea8f6d5..de5e75b7e5 100644 --- a/interface/resources/qml/hifi/simplifiedUI/settingsApp/general/General.qml +++ b/interface/resources/qml/hifi/simplifiedUI/settingsApp/general/General.qml @@ -13,6 +13,7 @@ import "../../simplifiedConstants" as SimplifiedConstants import "../../simplifiedControls" as SimplifiedControls import stylesUit 1.0 as HifiStylesUit import QtQuick.Layouts 1.3 +import PerformanceEnums 1.0 Flickable { property string avatarNametagMode: Settings.getValue("simplifiedNametag/avatarNametagMode", "on") @@ -113,16 +114,28 @@ Flickable { SimplifiedControls.RadioButton { id: performanceLow text: "Eco" + checked: Performance.getRefreshRateProfile() === RefreshRate.ECO + onClicked: { + Performance.setRefreshRateProfile(RefreshRate.ECO); + } } SimplifiedControls.RadioButton { id: performanceMedium text: "Interactive" + checked: Performance.getRefreshRateProfile() === RefreshRate.INTERACTIVE + onClicked: { + Performance.setRefreshRateProfile(RefreshRate.INTERACTIVE); + } } SimplifiedControls.RadioButton { id: performanceHigh text: "Realtime" + checked: Performance.getRefreshRateProfile() === RefreshRate.REALTIME + onClicked: { + Performance.setRefreshRateProfile(RefreshRate.REALTIME); + } } } } diff --git a/interface/resources/qml/hifi/simplifiedUI/topBar/SimplifiedTopBar.qml b/interface/resources/qml/hifi/simplifiedUI/topBar/SimplifiedTopBar.qml index 6622da33d9..a5a079b4dc 100644 --- a/interface/resources/qml/hifi/simplifiedUI/topBar/SimplifiedTopBar.qml +++ b/interface/resources/qml/hifi/simplifiedUI/topBar/SimplifiedTopBar.qml @@ -277,8 +277,34 @@ Rectangle { } onClicked: { Tablet.playSound(TabletEnums.ButtonClick); - // TODO: actually do this right and change the display plugin - HMD.active = !HMD.active; + var displayPluginCount = Window.getDisplayPluginCount(); + if (HMD.active) { + // This next line seems backwards and shouldn't be necessary - the NOTIFY handler should + // result in `displayModeImage.source` changing automatically - but that's not working. + // This is working. So, I'm keeping it. + displayModeImage.source = "./images/vrMode.svg"; + + // Switch to desktop mode - selects first VR display plugin + for (var i = 0; i < displayPluginCount; i++) { + if (!Window.isDisplayPluginHmd(i)) { + Window.setActiveDisplayPlugin(i); + return; + } + } + } else { + // This next line seems backwards and shouldn't be necessary - the NOTIFY handler should + // result in `displayModeImage.source` changing automatically - but that's not working. + // This is working. So, I'm keeping it. + displayModeImage.source = "./images/desktopMode.svg"; + + // Switch to VR mode - selects first HMD display plugin + for (var i = 0; i < displayPluginCount; i++) { + if (Window.isDisplayPluginHmd(i)) { + Window.setActiveDisplayPlugin(i); + return; + } + } + } } } } From 5cbb39a48ecf8655e7ad250d51fb62d968d31940 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 16 May 2019 16:25:02 -0700 Subject: [PATCH 10/16] adding computer changes to the platofrm --- libraries/platform/src/AndroidPlatform.cpp | 5 ++++ libraries/platform/src/AndroidPlatform.h | 1 + libraries/platform/src/LinuxPlatform.cpp | 5 ++++ libraries/platform/src/LinuxPlatform.h | 1 + libraries/platform/src/MACOSPlatform.cpp | 31 ++++++++++++++------- libraries/platform/src/MACOSPlatform.h | 3 +- libraries/platform/src/WINPlatform.cpp | 5 ++++ libraries/platform/src/WINPlatform.h | 2 +- libraries/platform/src/platform.cpp | 8 ++++-- libraries/platform/src/platform.h | 3 +- libraries/platform/src/platformInstance.cpp | 17 +++++++++-- libraries/platform/src/platformInstance.h | 6 ++-- libraries/platform/src/platformJsonKeys.h | 4 ++- 13 files changed, 70 insertions(+), 21 deletions(-) diff --git a/libraries/platform/src/AndroidPlatform.cpp b/libraries/platform/src/AndroidPlatform.cpp index 4351b14688..57b0cf04bc 100644 --- a/libraries/platform/src/AndroidPlatform.cpp +++ b/libraries/platform/src/AndroidPlatform.cpp @@ -38,3 +38,8 @@ void AndroidInstance::enumerateMemory() { ram["totalMemory"]=""; _memory.push_back(ram); } + +void AndroidInstance::::enumerateComputer(){ + //no implememntation at this time +} + diff --git a/libraries/platform/src/AndroidPlatform.h b/libraries/platform/src/AndroidPlatform.h index 17efbb45e3..66d80ca1ef 100644 --- a/libraries/platform/src/AndroidPlatform.h +++ b/libraries/platform/src/AndroidPlatform.h @@ -18,6 +18,7 @@ namespace platform { void enumerateCpu() override; void enumerateMemory() override; void enumerateGpu() override; + void enumerateComputer () override; }; } // namespace platform diff --git a/libraries/platform/src/LinuxPlatform.cpp b/libraries/platform/src/LinuxPlatform.cpp index 01d89a4462..df425f417e 100644 --- a/libraries/platform/src/LinuxPlatform.cpp +++ b/libraries/platform/src/LinuxPlatform.cpp @@ -40,3 +40,8 @@ void LinuxInstance::enumerateMemory() { _memory.push_back(ram); } + +void LinuxInstance::::enumerateComputer(){ + //no implememntation at this time +} + diff --git a/libraries/platform/src/LinuxPlatform.h b/libraries/platform/src/LinuxPlatform.h index 1af4ce7444..63db8557f0 100644 --- a/libraries/platform/src/LinuxPlatform.h +++ b/libraries/platform/src/LinuxPlatform.h @@ -18,6 +18,7 @@ namespace platform { void enumerateCpu() override; void enumerateMemory() override; void enumerateGpu() override; + void enumerateComputer () override; }; } // namespace platform diff --git a/libraries/platform/src/MACOSPlatform.cpp b/libraries/platform/src/MACOSPlatform.cpp index 151df96719..019594aedd 100644 --- a/libraries/platform/src/MACOSPlatform.cpp +++ b/libraries/platform/src/MACOSPlatform.cpp @@ -64,16 +64,6 @@ void MACOSInstance::enumerateCpu() { cpu["cpuNumCores"] = std::thread::hardware_concurrency(); _cpu.push_back(cpu); - - - //get system name - size_t len=0; - sysctlbyname("hw.model",NULL, &len, NULL, 0); - char* model = (char *) malloc(sizeof(char)*len+1); - sysctlbyname("hw.model", model, &len, NULL,0); - - _computerModel=std::string(model); - free(model); } void MACOSInstance::enumerateGpu() { @@ -98,3 +88,24 @@ void MACOSInstance::enumerateMemory() { #endif _memory.push_back(ram); } + +void MACOSInstance::enumerateComputer(){ +#ifdef Q_OS_MAC + + //get system name + size_t len=0; + sysctlbyname("hw.model",NULL, &len, NULL, 0); + char* model = (char *) malloc(sizeof(char)*len+1); + sysctlbyname("hw.model", model, &len, NULL,0); + + + json computer; + computer["computerModel"]=std::string(model); + + _computer.push_back(computer); + + free(model); + +#endif +} + diff --git a/libraries/platform/src/MACOSPlatform.h b/libraries/platform/src/MACOSPlatform.h index 287e0c0ed7..04b8621698 100644 --- a/libraries/platform/src/MACOSPlatform.h +++ b/libraries/platform/src/MACOSPlatform.h @@ -18,8 +18,9 @@ namespace platform { void enumerateCpu() override; void enumerateMemory() override; void enumerateGpu() override; + void enumerateComputer () override; }; } // namespace platform -#endif //hifi_winplatform_h +#endif //hifi_macosplatform_h diff --git a/libraries/platform/src/WINPlatform.cpp b/libraries/platform/src/WINPlatform.cpp index b39c83889b..8b37aa4e77 100644 --- a/libraries/platform/src/WINPlatform.cpp +++ b/libraries/platform/src/WINPlatform.cpp @@ -81,3 +81,8 @@ void WINInstance::enumerateMemory() { #endif _memory.push_back(ram); } + +void WINInstance::enumerateComputer(){ + //no implememntation at this time +} + diff --git a/libraries/platform/src/WINPlatform.h b/libraries/platform/src/WINPlatform.h index 4d466a9b7e..828d27ffc3 100644 --- a/libraries/platform/src/WINPlatform.h +++ b/libraries/platform/src/WINPlatform.h @@ -18,7 +18,7 @@ namespace platform { void enumerateCpu() override; void enumerateMemory() override; void enumerateGpu() override; - + void enumerateComputer () override; }; } // namespace platform diff --git a/libraries/platform/src/platform.cpp b/libraries/platform/src/platform.cpp index 6f9dc78768..8c305ebed5 100644 --- a/libraries/platform/src/platform.cpp +++ b/libraries/platform/src/platform.cpp @@ -78,6 +78,10 @@ json platform::getMemory(int index) { return _instance->getMemory(index); } -std::string platform::getComputerModel(){ - return _instance->getComputerModel(); +int platform::getNumComputer(){ + return _instance->getNumComputer(); +} + +json platform::getComputer(int index){ + return _instance->getComputer(index); } diff --git a/libraries/platform/src/platform.h b/libraries/platform/src/platform.h index 250b9144ac..9dd3d4ab2f 100644 --- a/libraries/platform/src/platform.h +++ b/libraries/platform/src/platform.h @@ -32,7 +32,8 @@ json getDisplay(int index); int getNumMemory(); json getMemory(int index); -std::string getComputerModel(); +int getNumComputer(); +json getComputer(int index); } // namespace platform #endif // hifi_platform_h diff --git a/libraries/platform/src/platformInstance.cpp b/libraries/platform/src/platformInstance.cpp index f1cef32096..8b2543eaeb 100644 --- a/libraries/platform/src/platformInstance.cpp +++ b/libraries/platform/src/platformInstance.cpp @@ -8,13 +8,13 @@ #include "platform.h" - -#include #include "platformInstance.h" +#include using namespace platform; bool Instance::enumeratePlatform() { + enumerateComputer(); enumerateCpu(); enumerateGpu(); enumerateMemory(); @@ -47,6 +47,14 @@ json Instance::getGPU(int index) { return _gpu.at(index); } +json Instance::getComputer(<#int index#>){ + if(index >=(int) _computer.size()){ + return json(); + } + + return _computer.at(index); + +} json Instance::getDisplay(int index) { assert(index <(int) _display.size()); @@ -65,7 +73,6 @@ Instance::~Instance() { _memory.clear(); } - if (_gpu.size() > 0) { _gpu.clear(); } @@ -73,4 +80,8 @@ Instance::~Instance() { if (_display.size() > 0) { _display.clear(); } + + if(_computer.size()>0){ + _computer.clear(); + } } diff --git a/libraries/platform/src/platformInstance.h b/libraries/platform/src/platformInstance.h index 59aede1fb3..f5947e7392 100644 --- a/libraries/platform/src/platformInstance.h +++ b/libraries/platform/src/platformInstance.h @@ -31,11 +31,13 @@ public: int getNumDisplay() { return (int)_display.size(); } json getDisplay(int index); - std::string getComputerModel(){return _computerModel;} + int getNumComputer() {return (int)_computer.size();} + json getComputer(int index); void virtual enumerateCpu()=0; void virtual enumerateMemory()=0; void virtual enumerateGpu()=0; + void virtual enumerateComputer()=0; virtual ~Instance(); @@ -44,7 +46,7 @@ protected: std::vector _memory; std::vector _gpu; std::vector _display; - std::string _computerModel; + std::vector _computer; }; } // namespace platform diff --git a/libraries/platform/src/platformJsonKeys.h b/libraries/platform/src/platformJsonKeys.h index 629aa30e34..31d81a829c 100644 --- a/libraries/platform/src/platformJsonKeys.h +++ b/libraries/platform/src/platformJsonKeys.h @@ -26,10 +26,12 @@ namespace platform { static const char* displayCoordsRight { "coordinatesright"}; static const char* displayCoordsTop { "coordinatestop"}; static const char* displayCoordsBottom { "coordinatesbottom"}; + static const char* computerModel { "computerModel"}; + #endif } -} // namespace platform +} // namespace plaform::jsonKeys #endif From 93cf6c882c6161051377edb0403d54ef3435c77b Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 16 May 2019 16:26:23 -0700 Subject: [PATCH 11/16] spacing --- libraries/platform/src/platformInstance.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/platform/src/platformInstance.cpp b/libraries/platform/src/platformInstance.cpp index 8b2543eaeb..06c431621f 100644 --- a/libraries/platform/src/platformInstance.cpp +++ b/libraries/platform/src/platformInstance.cpp @@ -48,13 +48,13 @@ json Instance::getGPU(int index) { } json Instance::getComputer(<#int index#>){ - if(index >=(int) _computer.size()){ + if(index >= (int)_computer.size()){ return json(); } return _computer.at(index); - } + json Instance::getDisplay(int index) { assert(index <(int) _display.size()); From a62f91c7b39ea808082c0b25e47c1c1569c93470 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 16 May 2019 16:30:30 -0700 Subject: [PATCH 12/16] removed xcode goofines --- libraries/platform/src/platformInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/platform/src/platformInstance.cpp b/libraries/platform/src/platformInstance.cpp index 06c431621f..1996ba9567 100644 --- a/libraries/platform/src/platformInstance.cpp +++ b/libraries/platform/src/platformInstance.cpp @@ -47,7 +47,7 @@ json Instance::getGPU(int index) { return _gpu.at(index); } -json Instance::getComputer(<#int index#>){ +json Instance::getComputer(int index){ if(index >= (int)_computer.size()){ return json(); } From 3ae33353d9f924af2aec70f8334e95d67bae3f54 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 16 May 2019 16:38:47 -0700 Subject: [PATCH 13/16] Fixed unused variables warnings --- libraries/render-utils/src/CauterizedModel.cpp | 1 - libraries/render-utils/src/Model.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/libraries/render-utils/src/CauterizedModel.cpp b/libraries/render-utils/src/CauterizedModel.cpp index 2cc3f49259..9cdefa0545 100644 --- a/libraries/render-utils/src/CauterizedModel.cpp +++ b/libraries/render-utils/src/CauterizedModel.cpp @@ -76,7 +76,6 @@ void CauterizedModel::createRenderItemSet() { // Run through all of the meshes, and place them into their segregated, but unsorted buckets int shapeID = 0; uint32_t numMeshes = (uint32_t)meshes.size(); - const HFMModel& hfmModel = getHFMModel(); for (uint32_t i = 0; i < numMeshes; i++) { const auto& mesh = meshes.at(i); if (!mesh) { diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 7cb20de526..938cc4a485 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -1477,7 +1477,6 @@ void Model::createRenderItemSet() { // Run through all of the meshes, and place them into their segregated, but unsorted buckets int shapeID = 0; uint32_t numMeshes = (uint32_t)meshes.size(); - auto& hfmModel = getHFMModel(); for (uint32_t i = 0; i < numMeshes; i++) { const auto& mesh = meshes.at(i); if (!mesh) { @@ -1735,7 +1734,6 @@ void Blender::run() { DETAILED_PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } }); int numBlendshapeOffsets = 0; // number of offsets required for all meshes. int numMeshes = 0; // number of meshes in this model. - int maxVertsInMesh = 0; // number of vertices in the largest mesh. for (auto meshIter = _hfmModel->meshes.cbegin(); meshIter != _hfmModel->meshes.cend(); ++meshIter) { numMeshes++; int numVertsInMesh = meshIter->vertices.size(); From 3b448ce1fe118fae6333419a6424eeed945b1155 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 16 May 2019 16:38:59 -0700 Subject: [PATCH 14/16] moving to only one computer. also a bit of cleanup: --- libraries/platform/src/AndroidPlatform.cpp | 5 ++--- libraries/platform/src/LinuxPlatform.cpp | 3 +-- libraries/platform/src/MACOSPlatform.cpp | 8 ++------ libraries/platform/src/platform.cpp | 8 ++------ libraries/platform/src/platform.h | 7 +++---- libraries/platform/src/platformInstance.cpp | 9 --------- libraries/platform/src/platformInstance.h | 6 +++--- 7 files changed, 13 insertions(+), 33 deletions(-) diff --git a/libraries/platform/src/AndroidPlatform.cpp b/libraries/platform/src/AndroidPlatform.cpp index 57b0cf04bc..f35674a984 100644 --- a/libraries/platform/src/AndroidPlatform.cpp +++ b/libraries/platform/src/AndroidPlatform.cpp @@ -8,9 +8,8 @@ #include "AndroidPlatform.h" #include "platformJsonKeys.h" - #include -#include + using namespace platform; void AndroidInstance::enumerateCpu() { @@ -39,7 +38,7 @@ void AndroidInstance::enumerateMemory() { _memory.push_back(ram); } -void AndroidInstance::::enumerateComputer(){ +void AndroidInstance::enumerateComputer(){ //no implememntation at this time } diff --git a/libraries/platform/src/LinuxPlatform.cpp b/libraries/platform/src/LinuxPlatform.cpp index df425f417e..aa63eb1e08 100644 --- a/libraries/platform/src/LinuxPlatform.cpp +++ b/libraries/platform/src/LinuxPlatform.cpp @@ -9,7 +9,6 @@ #include "LinuxPlatform.h" #include "platformJsonKeys.h" #include -#include using namespace platform; void LinuxInstance::enumerateCpu() { @@ -41,7 +40,7 @@ void LinuxInstance::enumerateMemory() { _memory.push_back(ram); } -void LinuxInstance::::enumerateComputer(){ +void LinuxInstance::enumerateComputer(){ //no implememntation at this time } diff --git a/libraries/platform/src/MACOSPlatform.cpp b/libraries/platform/src/MACOSPlatform.cpp index 019594aedd..7081044879 100644 --- a/libraries/platform/src/MACOSPlatform.cpp +++ b/libraries/platform/src/MACOSPlatform.cpp @@ -98,12 +98,8 @@ void MACOSInstance::enumerateComputer(){ char* model = (char *) malloc(sizeof(char)*len+1); sysctlbyname("hw.model", model, &len, NULL,0); - - json computer; - computer["computerModel"]=std::string(model); - - _computer.push_back(computer); - + _computer["computerModel"]=std::string(model); + free(model); #endif diff --git a/libraries/platform/src/platform.cpp b/libraries/platform/src/platform.cpp index 8c305ebed5..64bd536eee 100644 --- a/libraries/platform/src/platform.cpp +++ b/libraries/platform/src/platform.cpp @@ -78,10 +78,6 @@ json platform::getMemory(int index) { return _instance->getMemory(index); } -int platform::getNumComputer(){ - return _instance->getNumComputer(); -} - -json platform::getComputer(int index){ - return _instance->getComputer(index); +json platform::getComputer(){ + return _instance->getComputer(); } diff --git a/libraries/platform/src/platform.h b/libraries/platform/src/platform.h index 9dd3d4ab2f..14ec5fa8b2 100644 --- a/libraries/platform/src/platform.h +++ b/libraries/platform/src/platform.h @@ -9,8 +9,7 @@ #ifndef hifi_Platform_h #define hifi_Platform_h -#include "platformInstance.h" -#include + #include namespace platform { @@ -32,8 +31,8 @@ json getDisplay(int index); int getNumMemory(); json getMemory(int index); -int getNumComputer(); -json getComputer(int index); +json getComputer(); + } // namespace platform #endif // hifi_platform_h diff --git a/libraries/platform/src/platformInstance.cpp b/libraries/platform/src/platformInstance.cpp index 1996ba9567..9eccaa43c6 100644 --- a/libraries/platform/src/platformInstance.cpp +++ b/libraries/platform/src/platformInstance.cpp @@ -7,7 +7,6 @@ // -#include "platform.h" #include "platformInstance.h" #include @@ -47,14 +46,6 @@ json Instance::getGPU(int index) { return _gpu.at(index); } -json Instance::getComputer(int index){ - if(index >= (int)_computer.size()){ - return json(); - } - - return _computer.at(index); -} - json Instance::getDisplay(int index) { assert(index <(int) _display.size()); diff --git a/libraries/platform/src/platformInstance.h b/libraries/platform/src/platformInstance.h index f5947e7392..8d0a181e3d 100644 --- a/libraries/platform/src/platformInstance.h +++ b/libraries/platform/src/platformInstance.h @@ -31,8 +31,8 @@ public: int getNumDisplay() { return (int)_display.size(); } json getDisplay(int index); - int getNumComputer() {return (int)_computer.size();} - json getComputer(int index); + + json getComputer() {return _computer;} void virtual enumerateCpu()=0; void virtual enumerateMemory()=0; @@ -46,7 +46,7 @@ protected: std::vector _memory; std::vector _gpu; std::vector _display; - std::vector _computer; + json _computer; }; } // namespace platform From 027583cddc57f67d900f77f964f7c5c9878dcf90 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 16 May 2019 16:40:16 -0700 Subject: [PATCH 15/16] removing stuff from destructor since its not a vector of computers --- libraries/platform/src/platformInstance.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/platform/src/platformInstance.cpp b/libraries/platform/src/platformInstance.cpp index 9eccaa43c6..5859577748 100644 --- a/libraries/platform/src/platformInstance.cpp +++ b/libraries/platform/src/platformInstance.cpp @@ -71,8 +71,4 @@ Instance::~Instance() { if (_display.size() > 0) { _display.clear(); } - - if(_computer.size()>0){ - _computer.clear(); - } } From db813fab6a3b2b71cbb902de9a54e598efa20dec Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 16 May 2019 16:14:56 -0700 Subject: [PATCH 16/16] threadsafe setRenderMethod --- interface/src/scripting/RenderScriptingInterface.cpp | 5 +++++ interface/src/scripting/RenderScriptingInterface.h | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/interface/src/scripting/RenderScriptingInterface.cpp b/interface/src/scripting/RenderScriptingInterface.cpp index 0b862eb007..8581c7527d 100644 --- a/interface/src/scripting/RenderScriptingInterface.cpp +++ b/interface/src/scripting/RenderScriptingInterface.cpp @@ -24,6 +24,11 @@ QString RenderScriptingInterface::getRenderMethod() { } void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) { + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(const QString&, renderMethod)); + return; + } + auto config = dynamic_cast(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch")); if (config) { if (renderMethod == DEFERRED) { diff --git a/interface/src/scripting/RenderScriptingInterface.h b/interface/src/scripting/RenderScriptingInterface.h index 71a8a64fdb..2aff3a08b6 100644 --- a/interface/src/scripting/RenderScriptingInterface.h +++ b/interface/src/scripting/RenderScriptingInterface.h @@ -59,13 +59,7 @@ public slots: void setRenderMethod(const QString& renderMethod); private: - Setting::Handle _renderMethodSetting { "renderMethod", -#ifdef RENDER_FORWARD - render::Args::RenderMethod::FORWARD -#else - render::Args::RenderMethod::DEFERRED -#endif - }; + Setting::Handle _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED }; }; #endif // hifi_RenderScriptingInterface_h