Merge pull request #15638 from samcake/nut

case BUGZ-191: Implement patform tier profile from platform description
This commit is contained in:
Shannon Romano 2019-05-28 15:28:05 -07:00 committed by GitHub
commit d065847bee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 1068 additions and 529 deletions

View file

@ -3322,6 +3322,7 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) {
surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
surfaceContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data());
surfaceContext->setContextProperty("Render", RenderScriptingInterface::getInstance());
surfaceContext->setContextProperty("PlatformInfo", PlatformInfoScriptingInterface::getInstance());
surfaceContext->setContextProperty("Workload", _gameWorkload._engine->getConfiguration().get());
surfaceContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface());
surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
@ -3445,6 +3446,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona
surfaceContext->setContextProperty("HiFiAbout", AboutUtil::getInstance());
surfaceContext->setContextProperty("WalletScriptingInterface", DependencyManager::get<WalletScriptingInterface>().data());
surfaceContext->setContextProperty("ResourceRequestObserver", DependencyManager::get<ResourceRequestObserver>().data());
surfaceContext->setContextProperty("PlatformInfo", PlatformInfoScriptingInterface::getInstance());
}
}

View file

@ -10,6 +10,9 @@
#include <shared/GlobalAppProperties.h>
#include <thread>
#include <platform/Platform.h>
#include <platform/Profiler.h>
#ifdef Q_OS_WIN
#include <Windows.h>
#elif defined Q_OS_MAC
@ -21,6 +24,17 @@ PlatformInfoScriptingInterface* PlatformInfoScriptingInterface::getInstance() {
return &sharedInstance;
}
PlatformInfoScriptingInterface::PlatformInfoScriptingInterface() {
platform::create();
if (!platform::enumeratePlatform()) {
}
}
PlatformInfoScriptingInterface::~PlatformInfoScriptingInterface() {
platform::destroy();
}
QString PlatformInfoScriptingInterface::getOperatingSystemType() {
#ifdef Q_OS_WIN
return "WINDOWS";
@ -149,3 +163,52 @@ bool PlatformInfoScriptingInterface::isStandalone() {
return qApp->property(hifi::properties::STANDALONE).toBool();
#endif
}
int PlatformInfoScriptingInterface::getNumCPUs() {
return platform::getNumCPUs();
}
QString PlatformInfoScriptingInterface::getCPU(int index) {
auto desc = platform::getCPU(index);
return QString(desc.dump().c_str());
}
int PlatformInfoScriptingInterface::getNumGPUs() {
return platform::getNumGPUs();
}
QString PlatformInfoScriptingInterface::getGPU(int index) {
auto desc = platform::getGPU(index);
return QString(desc.dump().c_str());
}
int PlatformInfoScriptingInterface::getNumDisplays() {
return platform::getNumDisplays();
}
QString PlatformInfoScriptingInterface::getDisplay(int index) {
auto desc = platform::getDisplay(index);
return QString(desc.dump().c_str());
}
QString PlatformInfoScriptingInterface::getMemory() {
auto desc = platform::getMemory(0);
return QString(desc.dump().c_str());
}
QString PlatformInfoScriptingInterface::getComputer() {
auto desc = platform::getComputer();
return QString(desc.dump().c_str());
}
PlatformInfoScriptingInterface::PlatformTier PlatformInfoScriptingInterface::getTierProfiled() {
return (PlatformInfoScriptingInterface::PlatformTier) platform::Profiler::profilePlatform();
}
QStringList PlatformInfoScriptingInterface::getPlatformTierNames() {
static const QStringList platformTierNames = { "UNKNWON", "LOW", "MID", "HIGH" };
return platformTierNames;
}

View file

@ -9,6 +9,7 @@
#ifndef hifi_PlatformInfoScriptingInterface_h
#define hifi_PlatformInfoScriptingInterface_h
#include <platform/Profiler.h>
#include <QtCore/QObject>
class QScriptValue;
@ -25,6 +26,20 @@ class QScriptValue;
class PlatformInfoScriptingInterface : public QObject {
Q_OBJECT
public:
PlatformInfoScriptingInterface();
virtual ~PlatformInfoScriptingInterface();
// Platform tier enum type
enum PlatformTier {
UNKNOWN = platform::Profiler::Tier::UNKNOWN,
LOW = platform::Profiler::Tier::LOW,
MID = platform::Profiler::Tier::MID,
HIGH = platform::Profiler::Tier::HIGH,
};
Q_ENUM(PlatformTier);
public slots:
/**jsdoc
* @function PlatformInfo.getInstance
@ -98,6 +113,96 @@ public slots:
* @returns {boolean} <code>true</code> if Interface is running on a stand-alone device, <code>false</code> if it isn't.
*/
bool isStandalone();
/**jsdoc
* Get the number of CPUs.
* @function PlatformInfo.getNumCPUs
* @returns {number} The number of CPUs detected on the hardware platform.
*/
int getNumCPUs();
/**jsdoc
* Get the description of the CPU at the index parameter
* expected fields are:
* - cpuVendor...
* @param index The index of the CPU of the platform
* @function PlatformInfo.getCPU
* @returns {string} The CPU description json field
*/
QString getCPU(int index);
/**jsdoc
* Get the number of GPUs.
* @function PlatformInfo.getNumGPUs
* @returns {number} The number of GPUs detected on the hardware platform.
*/
int getNumGPUs();
/**jsdoc
* Get the description of the GPU at the index parameter
* expected fields are:
* - gpuVendor...
* @param index The index of the GPU of the platform
* @function PlatformInfo.getGPU
* @returns {string} The GPU description json field
*/
QString getGPU(int index);
/**jsdoc
* Get the number of Displays.
* @function PlatformInfo.getNumDisplays
* @returns {number} The number of Displays detected on the hardware platform.
*/
int getNumDisplays();
/**jsdoc
* Get the description of the Display at the index parameter
* expected fields are:
* - DisplayVendor...
* @param index The index of the Display of the platform
* @function PlatformInfo.getDisplay
* @returns {string} The Display description json field
*/
QString getDisplay(int index);
/**jsdoc
* Get the description of the Memory
* expected fields are:
* - MemoryVendor...
* @function PlatformInfo.getMemory
* @returns {string} The Memory description json field
*/
QString getMemory();
/**jsdoc
* Get the description of the Computer
* expected fields are:
* - ComputerVendor...
* @function PlatformInfo.getComputer
* @returns {string} The Computer description json field
*/
QString getComputer();
/**jsdoc
* Get the Platform TIer profiled on startup of the Computer
* Platform Tier is an ineger/enum value:
* LOW = 0, MID = 1, HIGH = 2
* @function PlatformInfo.getTierProfiled
* @returns {number} The Platform Tier profiled on startup.
*/
PlatformTier getTierProfiled();
/**jsdoc
* Get the Platform Tier possible Names as an array of strings
* Platform Tier is an ineger/enum value:
* LOW = 0, MID = 1, HIGH = 2
* @function PlatformInfo.getPlatformTierNames
* @returns {string} The array of names matching the number returned from PlatformInfo.getTierProfiled
*/
QStringList getPlatformTierNames();
};
#endif // hifi_PlatformInfoScriptingInterface_h

View file

@ -1,5 +1,7 @@
set(TARGET_NAME platform)
setup_hifi_library()
setup_hifi_library()
link_hifi_libraries(shared)
GroupSources("src")
target_json()

View file

@ -1,82 +0,0 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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 "LinuxPlatform.h"
#include "platformJsonKeys.h"
#include <GPUIdent.h>
#include <thread>
using namespace platform;
static void getLCpuId( uint32_t* p, uint32_t ax )
{
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
__asm __volatile
( "movl %%ebx, %%esi\n\t"
"cpuid\n\t"
"xchgl %%ebx, %%esi"
: "=a" (p[0]), "=S" (p[1]),
"=c" (p[2]), "=d" (p[3])
: "0" (ax)
);
#endif
}
void LinuxInstance::enumerateCpu() {
json cpu = {};
uint32_t cpuInfo[4]={0,0,0,0};
char CPUBrandString[16];
char CPUModelString[16];
char CPUClockString[16];
uint32_t nExIds;
getLCpuId(cpuInfo, 0x80000000);
nExIds = cpuInfo[0];
for (uint32_t i = 0x80000000; i <= nExIds; ++i) {
getLCpuId(cpuInfo, i);
// Interpret CPU brand string
if (i == 0x80000002) {
memcpy(CPUBrandString, cpuInfo, sizeof(cpuInfo));
} else if (i == 0x80000003) {
memcpy(CPUModelString, cpuInfo, sizeof(cpuInfo));
} else if (i == 0x80000004) {
memcpy(CPUClockString, cpuInfo, sizeof(cpuInfo));
}
}
cpu["cpuBrand"] = CPUBrandString;
cpu["cpuModel"] = CPUModelString;
cpu["cpuClockSpeed"] = CPUClockString;
cpu["cpuNumCores"] = std::thread::hardware_concurrency();
_cpu.push_back(cpu);
}
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.push_back(gpu);
_display = ident->getOutput();
}
void LinuxInstance::enumerateMemory() {
json ram = {};
ram["totalMemory"]="";
_memory.push_back(ram);
}
void LinuxInstance::enumerateComputer(){
//no implememntation at this time
}

View file

@ -1,107 +0,0 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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 "MACOSPlatform.h"
#include "platformJsonKeys.h"
#include <thread>
#include <GPUIdent.h>
#include <string>
#ifdef Q_OS_MAC
#include <unistd.h>
#include <cpuid.h>
#include <sys/sysctl.h>
#endif
using namespace platform;
static void getCpuId( uint32_t* p, uint32_t ax )
{
#ifdef Q_OS_MAC
__asm __volatile
( "movl %%ebx, %%esi\n\t"
"cpuid\n\t"
"xchgl %%ebx, %%esi"
: "=a" (p[0]), "=S" (p[1]),
"=c" (p[2]), "=d" (p[3])
: "0" (ax)
);
#endif
}
void MACOSInstance::enumerateCpu() {
json cpu = {};
uint32_t cpuInfo[4]={0,0,0,0};
char CPUBrandString[16];
char CPUModelString[16];
char CPUClockString[16];
uint32_t nExIds;
getCpuId(cpuInfo, 0x80000000);
nExIds = cpuInfo[0];
for (uint32_t i = 0x80000000; i <= nExIds; ++i) {
getCpuId(cpuInfo, i);
// Interpret CPU brand string
if (i == 0x80000002) {
memcpy(CPUBrandString, cpuInfo, sizeof(cpuInfo));
} else if (i == 0x80000003) {
memcpy(CPUModelString, cpuInfo, sizeof(cpuInfo));
} else if (i == 0x80000004) {
memcpy(CPUClockString, cpuInfo, sizeof(cpuInfo));
}
}
cpu["cpuBrand"] = CPUBrandString;
cpu["cpuModel"] = CPUModelString;
cpu["cpuClockSpeed"] = CPUClockString;
cpu["cpuNumCores"] = std::thread::hardware_concurrency();
_cpu.push_back(cpu);
}
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.push_back(gpu);
_display = ident->getOutput();
}
void MACOSInstance::enumerateMemory() {
json ram = {};
#ifdef Q_OS_MAC
long pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGE_SIZE);
ram["totalMemory"] = pages * page_size;;
#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);
_computer["computerModel"]=std::string(model);
free(model);
#endif
}

View file

@ -1,88 +0,0 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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 "WINPlatform.h"
#include "platformJsonKeys.h"
#ifdef Q_OS_WINDOWS
#include <intrin.h>
#include <Windows.h>
#endif
#include <thread>
#include <GPUIdent.h>
#include <string>
using namespace platform;
void WINInstance::enumerateCpu() {
json cpu = {};
#ifdef Q_OS_WINDOWS
int CPUInfo[4] = { -1 };
unsigned nExIds;
unsigned int i = 0;
char CPUBrandString[16];
char CPUModelString[16];
char CPUClockString[16];
// Get the information associated with each extended ID.
__cpuid(CPUInfo, 0x80000000);
nExIds = CPUInfo[0];
for (i = 0x80000000; i <= nExIds; ++i) {
__cpuid(CPUInfo, i);
// Interpret CPU brand string
if (i == 0x80000002) {
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
} else if (i == 0x80000003) {
memcpy(CPUModelString, CPUInfo, sizeof(CPUInfo));
} else if (i == 0x80000004) {
memcpy(CPUClockString, CPUInfo, sizeof(CPUInfo));
}
}
cpu["cpuBrand"] = CPUBrandString;
cpu["cpuModel"] = CPUModelString;
cpu["cpuClockSpeed"] = CPUClockString;
cpu["cpuNumCores"] = std::thread::hardware_concurrency();
#endif
_cpu.push_back(cpu);
}
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.push_back(gpu);
_display = ident->getOutput();
}
void WINInstance::enumerateMemory() {
json ram = {};
#ifdef Q_OS_WINDOWS
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
int totalRam = statex.ullTotalPhys / 1024 / 1024;
ram["totalMemory"] = totalRam;
#endif
_memory.push_back(ram);
}
void WINInstance::enumerateComputer(){
//no implememntation at this time
}

View file

@ -1,83 +0,0 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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 "platform.h"
#include <qglobal.h>
#if defined(Q_OS_WIN)
#include "WINPlatform.h"
#elif defined(Q_OS_MAC)
#include "MACOSPlatform.h"
#elif defined(Q_OS_ANDROID)
#include "AndroidPlatform.h"
#elif defined(Q_OS_LINUX)
#include "LinuxPlatform.h"
#endif
using namespace platform;
Instance *_instance;
void platform::create() {
#if defined(Q_OS_WIN)
_instance =new WINInstance();
#elif defined(Q_OS_MAC)
_instance = new MACOSInstance();
#elif defined(Q_OS_ANDROID)
_instance= new AndroidInstance();
#elif defined(Q_OS_LINUX)
_instance= new LinuxInstance();
#endif
}
void platform::destroy() {
if(_instance)
delete _instance;
}
bool platform::enumeratePlatform() {
return _instance->enumeratePlatform();
}
int platform::getNumCPU() {
return _instance->getNumCPU();
}
json platform::getCPU(int index) {
return _instance->getCPU(index);
}
int platform::getNumGPU() {
return _instance->getNumGPU();
}
json platform::getGPU(int index) {
return _instance->getGPU(index);
}
int platform::getNumDisplay() {
return _instance->getNumDisplay();
}
json platform::getDisplay(int index) {
return _instance->getDisplay(index);
}
int platform::getNumMemory() {
return _instance->getNumMemory();
}
json platform::getMemory(int index) {
return _instance->getMemory(index);
}
json platform::getComputer(){
return _instance->getComputer();
}

View file

@ -19,20 +19,20 @@ void create();
void destroy();
bool enumeratePlatform();
int getNumCPU();
int getNumCPUs();
json getCPU(int index);
int getNumGPU();
int getNumGPUs();
json getGPU(int index);
int getNumDisplay();
int getNumDisplays();
json getDisplay(int index);
int getNumMemory();
int getNumMemories();
json getMemory(int index);
json getComputer();
} // namespace platform
#endif // hifi_platform_h

View file

@ -0,0 +1,57 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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_platform_PlatformKeys_h
#define hifi_platform_PlatformKeys_h
namespace platform { namespace keys{
namespace cpu {
extern const char* vendor;
extern const char* vendor_Intel;
extern const char* vendor_AMD;
extern const char* model;
extern const char* clockSpeed;
extern const char* numCores;
}
namespace gpu {
extern const char* vendor;
extern const char* vendor_NVIDIA;
extern const char* vendor_AMD;
extern const char* vendor_Intel;
extern const char* model;
extern const char* videoMemory;
extern const char* driver;
}
namespace display {
extern const char* description;
extern const char* name;
extern const char* coordsLeft;
extern const char* coordsRight;
extern const char* coordsTop;
extern const char* coordsBottom;
}
extern const char* memTotal;
namespace computer {
extern const char* OS;
extern const char* OS_WINDOWS;
extern const char* OS_MACOS;
extern const char* OS_LINUX;
extern const char* OS_ANDROID;
extern const char* vendor;
extern const char* vendor_Apple;
extern const char* model;
extern const char* profileTier;
}
} } // namespace plaform::keys
#endif

View file

@ -0,0 +1,127 @@
//
// Profiler.cpp
// libraries/platform/src/platform
//
// Created by Sam Gateau on 5/22/2019.
// Copyright 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 "Profiler.h"
#include "Platform.h"
#include "PlatformKeys.h"
using namespace platform;
const std::array<const char*, Profiler::Tier::NumTiers> Profiler::TierNames = {{ "UNKNOWN", "LOW", "MID", "HIGH" }};
bool filterOnComputer(const platform::json& computer, Profiler::Tier& tier);
bool filterOnComputerMACOS(const platform::json& computer, Profiler::Tier& tier);
bool filterOnProcessors(const platform::json& computer, const platform::json& cpu, const platform::json& gpu, Profiler::Tier& tier);
Profiler::Tier Profiler::profilePlatform() {
auto platformTier = Profiler::Tier::UNKNOWN; // unknown tier yet
// first filter on the computer info and catch known models
auto computerInfo = platform::getComputer();
if (filterOnComputer(computerInfo, platformTier)) {
return platformTier;
}
// Not filtered yet, let s try to make sense of the cpu and gpu info
auto cpuInfo = platform::getCPU(0);
auto gpuInfo = platform::getGPU(0);
if (filterOnProcessors(computerInfo, cpuInfo, gpuInfo, platformTier)) {
return platformTier;
}
// Default answer is
return Profiler::Tier::LOW;
}
// tier filter on computer info
bool filterOnComputer(const platform::json& computer, Profiler::Tier& tier) {
if (computer.count(keys::computer::OS)) {
const auto os = computer[keys::computer::OS].get<std::string>();
if (os.compare(keys::computer::OS_MACOS) == 0) {
return filterOnComputerMACOS(computer, tier);
}
}
return false;
}
// tier filter on computer MACOS
bool filterOnComputerMACOS(const platform::json& computer, Profiler::Tier& tier) {
// it s a macos computer, probably can tell from the model name:
if (computer.count(keys::computer::model)) {
const auto model = computer[keys::computer::model].get<std::string>();
if (model.find("MacBookAir") != std::string::npos) {
tier = Profiler::Tier::LOW;
return true;
} else if (model.find("MacBookPro") != std::string::npos) {
tier = Profiler::Tier::MID;
return true;
} else if (model.find("MacBook") != std::string::npos) {
tier = Profiler::Tier::LOW;
return true;
}
}
return false;
}
bool filterOnProcessors(const platform::json& computer, const platform::json& cpu, const platform::json& gpu, Profiler::Tier& tier) {
// first filter on the number of cores, <= 4 means LOW
int numCores = 0;
std::string cpuVendor;
if (cpu.count(keys::cpu::numCores)) {
numCores = cpu[keys::cpu::numCores].get<int>();
if (numCores <= 4) {
tier = Profiler::Tier::LOW;
return true;
}
cpuVendor = cpu[keys::cpu::vendor].get<std::string>();
}
// enough cores to be mid or high
// let s look at the gpu
if (gpu.count(keys::gpu::vendor)) {
std::string gpuVendor = gpu[keys::gpu::vendor].get<std::string>();
std::string gpuModel = gpu[keys::gpu::model].get<std::string>();
// intel integrated graphics
if (gpuVendor.find(keys::gpu::vendor_Intel) != std::string::npos) {
// go mid because GPU
tier = Profiler::Tier::MID;
return true;
}
// AMD gpu
else if (gpuVendor.find(keys::gpu::vendor_AMD) != std::string::npos) {
// TODO: Filter base on the model of AMD
// that is their integrated graphics, go low!
if (gpuModel.find("Vega 3") != std::string::npos) {
tier = Profiler::Tier::LOW;
return true;
}
// go high because GPU
tier = Profiler::Tier::HIGH;
return true;
}
// NVIDIA gpu
else if (gpuVendor.find(keys::gpu::vendor_NVIDIA) != std::string::npos) {
// TODO: Filter base on the model of NV
// go high because GPU
tier = Profiler::Tier::HIGH;
return true;
}
}
// Not able to profile
return false;
}

View file

@ -0,0 +1,34 @@
//
// Profiler.h
// libraries/platform/src/platform
//
// Created by Sam Gateau on 5/22/2019.
// Copyright 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_platform_Profiler_h
#define hifi_platform_Profiler_h
#include <array>
namespace platform {
class Profiler {
public:
enum Tier {
UNKNOWN = 0,
LOW,
MID,
HIGH,
NumTiers, // not a valid Tier
};
static const std::array<const char*, Tier::NumTiers> TierNames;
static Tier profilePlatform();
};
}
#endif

View file

@ -7,38 +7,41 @@
//
#include "AndroidPlatform.h"
#include "platformJsonKeys.h"
#include "../PlatformKeys.h"
#include <GPUIdent.h>
using namespace platform;
void AndroidInstance::enumerateCpu() {
json cpu;
cpu["cpuBrand"] = "";
cpu["cpuModel"] = "";
cpu["cpuClockSpeed"] = "";
cpu["cpuNumCores"] = "";
cpu[keys::cpu::vendor] = "";
cpu[keys::cpu::model] = "";
cpu[keys::cpu::clockSpeed] = "";
cpu[keys::cpu::numCores] = 0;
_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[keys::gpu::vendor] = ident->getName().toUtf8().constData();
gpu[keys::gpu::model] = ident->getName().toUtf8().constData();
gpu[keys::gpu::videoMemory] = ident->getMemory();
gpu[keys::gpu::driver] = ident->getDriver().toUtf8().constData();
_gpu.push_back(gpu);
_display = ident->getOutput();
}
void AndroidInstance::enumerateMemory() {
json ram = {};
ram["totalMemory"]="";
ram[keys::memTotal]=0;
_memory.push_back(ram);
}
void AndroidInstance::enumerateComputer(){
//no implememntation at this time
_computer[keys::computer::OS] = keys::computer::OS_ANDROID;
_computer[keys::computer::vendor] = "";
_computer[keys::computer::model] = "";
}

View file

@ -9,7 +9,7 @@
#ifndef hifi_AndroidPlatform_h
#define hifi_AndroidPlatform_h
#include "platformInstance.h"
#include "PlatformInstance.h"
namespace platform {
class AndroidInstance : public Instance {

View file

@ -0,0 +1,54 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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 "LinuxPlatform.h"
#include "../PlatformKeys.h"
#include <thread>
#include <string>
#include <CPUIdent.h>
#include <GPUIdent.h>
using namespace platform;
void LinuxInstance::enumerateCpu() {
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);
}
void LinuxInstance::enumerateGpu() {
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::videoMemory] = ident->getMemory();
gpu[keys::gpu::driver] = ident->getDriver().toUtf8().constData();
_gpu.push_back(gpu);
_display = ident->getOutput();
}
void LinuxInstance::enumerateMemory() {
json ram = {};
ram[keys::memTotal]=0;
_memory.push_back(ram);
}
void LinuxInstance::enumerateComputer(){
_computer[keys::computer::OS] = keys::computer::OS_LINUX;
_computer[keys::computer::vendor] = "";
_computer[keys::computer::model] = "";
}

View file

@ -9,7 +9,7 @@
#ifndef hifi_LinuxPlatform_h
#define hifi_LinuxPlatform_h
#include "platformInstance.h"
#include "PlatformInstance.h"
namespace platform {
class LinuxInstance : public Instance {

View file

@ -0,0 +1,77 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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 "MACOSPlatform.h"
#include "../PlatformKeys.h"
#include <thread>
#include <string>
#include <CPUIdent.h>
#include <GPUIdent.h>
#ifdef Q_OS_MAC
#include <unistd.h>
#include <cpuid.h>
#include <sys/sysctl.h>
#endif
using namespace platform;
void MACOSInstance::enumerateCpu() {
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);
}
void MACOSInstance::enumerateGpu() {
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::videoMemory] = ident->getMemory();
gpu[keys::gpu::driver] = ident->getDriver().toUtf8().constData();
_gpu.push_back(gpu);
_display = ident->getOutput();
}
void MACOSInstance::enumerateMemory() {
json ram = {};
#ifdef Q_OS_MAC
long pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGE_SIZE);
ram[keys::memTotal] = pages * page_size;
#endif
_memory.push_back(ram);
}
void MACOSInstance::enumerateComputer(){
_computer[keys::computer::OS] = keys::computer::OS_MACOS;
_computer[keys::computer::vendor] = keys::computer::vendor_Apple;
#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);
_computer[keys::computer::model]=std::string(model);
free(model);
#endif
}

View file

@ -9,7 +9,7 @@
#ifndef hifi_MACOSPlatform_h
#define hifi_MACOSPlatform_h
#include "platformInstance.h"
#include "PlatformInstance.h"
namespace platform {
class MACOSInstance : public Instance {

View file

@ -0,0 +1,130 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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 "../Platform.h"
#include "../PlatformKeys.h"
namespace platform { namespace keys {
namespace cpu {
const char* vendor = "vendor";
const char* vendor_Intel = "Intel";
const char* vendor_AMD = "AMD";
const char* model = "model";
const char* clockSpeed = "clockSpeed";
const char* numCores = "numCores";
}
namespace gpu {
const char* vendor = "vendor";
const char* vendor_NVIDIA = "NVIDIA";
const char* vendor_AMD = "AMD";
const char* vendor_Intel = "Intel";
const char* model = "model";
const char* videoMemory = "videoMemory";
const char* driver = "driver";
}
namespace display {
const char* description = "description";
const char* name = "deviceName";
const char* coordsLeft = "coordinatesleft";
const char* coordsRight = "coordinatesright";
const char* coordsTop = "coordinatestop";
const char* coordsBottom = "coordinatesbottom";
}
const char* memTotal = "memTotal";
namespace computer {
const char* OS = "OS";
const char* OS_WINDOWS = "WINDOWS";
const char* OS_MACOS = "MACOS";
const char* OS_LINUX = "LINUX";
const char* OS_ANDROID = "ANDROID";
const char* vendor = "vendor";
const char* vendor_Apple = "Apple";
const char* model = "model";
const char* profileTier = "profileTier";
}
}}
#include <qglobal.h>
#if defined(Q_OS_WIN)
#include "WINPlatform.h"
#elif defined(Q_OS_MAC)
#include "MACOSPlatform.h"
#elif defined(Q_OS_ANDROID)
#include "AndroidPlatform.h"
#elif defined(Q_OS_LINUX)
#include "LinuxPlatform.h"
#endif
using namespace platform;
Instance *_instance;
void platform::create() {
#if defined(Q_OS_WIN)
_instance =new WINInstance();
#elif defined(Q_OS_MAC)
_instance = new MACOSInstance();
#elif defined(Q_OS_ANDROID)
_instance= new AndroidInstance();
#elif defined(Q_OS_LINUX)
_instance= new LinuxInstance();
#endif
}
void platform::destroy() {
if(_instance)
delete _instance;
}
bool platform::enumeratePlatform() {
return _instance->enumeratePlatform();
}
int platform::getNumCPUs() {
return _instance->getNumCPUs();
}
json platform::getCPU(int index) {
return _instance->getCPU(index);
}
int platform::getNumGPUs() {
return _instance->getNumGPUs();
}
json platform::getGPU(int index) {
return _instance->getGPU(index);
}
int platform::getNumDisplays() {
return _instance->getNumDisplays();
}
json platform::getDisplay(int index) {
return _instance->getDisplay(index);
}
int platform::getNumMemories() {
return _instance->getNumMemories();
}
json platform::getMemory(int index) {
return _instance->getMemory(index);
}
json platform::getComputer(){
return _instance->getComputer();
}

View file

@ -7,8 +7,10 @@
//
#include "platformInstance.h"
#include <QtGlobal>
#include "PlatformInstance.h"
#include "../PlatformKeys.h"
#include "../Profiler.h"
using namespace platform;
@ -17,6 +19,10 @@ bool Instance::enumeratePlatform() {
enumerateCpu();
enumerateGpu();
enumerateMemory();
// And profile the platform and put the tier in "computer"
_computer[keys::computer::profileTier] = Profiler::TierNames[Profiler::profilePlatform()];
return true;
}
@ -72,3 +78,44 @@ Instance::~Instance() {
_display.clear();
}
}
json Instance::listAllKeys() {
json allKeys;
allKeys.array({{
keys::cpu::vendor,
keys::cpu::vendor_Intel,
keys::cpu::vendor_AMD,
keys::cpu::model,
keys::cpu::clockSpeed,
keys::cpu::numCores,
keys::gpu::vendor,
keys::gpu::vendor_NVIDIA,
keys::gpu::vendor_AMD,
keys::gpu::vendor_Intel,
keys::gpu::model,
keys::gpu::videoMemory,
keys::gpu::driver,
keys::display::description,
keys::display::name,
keys::display::coordsLeft,
keys::display::coordsRight,
keys::display::coordsTop,
keys::display::coordsBottom,
keys::memTotal,
keys::computer::OS,
keys::computer::OS_WINDOWS,
keys::computer::OS_MACOS,
keys::computer::OS_LINUX,
keys::computer::OS_ANDROID,
keys::computer::vendor,
keys::computer::vendor_Apple,
keys::computer::model,
keys::computer::profileTier
}});
return allKeys;
}

View file

@ -19,16 +19,16 @@ class Instance {
public:
bool virtual enumeratePlatform();
int getNumCPU() { return (int)_cpu.size(); }
int getNumCPUs() { return (int)_cpu.size(); }
json getCPU(int index);
int getNumGPU() { return (int)_gpu.size(); }
int getNumGPUs() { return (int)_gpu.size(); }
json getGPU(int index);
int getNumMemory() { return (int)_memory.size(); }
int getNumMemories() { return (int)_memory.size(); }
json getMemory(int index);
int getNumDisplay() { return (int)_display.size(); }
int getNumDisplays() { return (int)_display.size(); }
json getDisplay(int index);
@ -41,6 +41,8 @@ public:
virtual ~Instance();
static json listAllKeys();
protected:
std::vector<json> _cpu;
std::vector<json> _memory;

View file

@ -0,0 +1,66 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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 "WINPlatform.h"
#include "../PlatformKeys.h"
#include <thread>
#include <string>
#include <CPUIdent.h>
#include <GPUIdent.h>
#ifdef Q_OS_WIN
#include <Windows.h>
#endif
using namespace platform;
void WINInstance::enumerateCpu() {
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);
}
void WINInstance::enumerateGpu() {
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::videoMemory] = ident->getMemory();
gpu[keys::gpu::driver] = ident->getDriver().toUtf8().constData();
_gpu.push_back(gpu);
_display = ident->getOutput();
}
void WINInstance::enumerateMemory() {
json ram = {};
#ifdef Q_OS_WIN
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
int totalRam = statex.ullTotalPhys / 1024 / 1024;
ram[platform::keys::memTotal] = totalRam;
#endif
_memory.push_back(ram);
}
void WINInstance::enumerateComputer(){
_computer[keys::computer::OS] = keys::computer::OS_WINDOWS;
_computer[keys::computer::vendor] = "";
_computer[keys::computer::model] = "";
}

View file

@ -9,7 +9,7 @@
#ifndef hifi_WinPlatform_h
#define hifi_WinPlatform_h
#include "platformInstance.h"
#include "PlatformInstance.h"
namespace platform {
class WINInstance : public Instance {

View file

@ -1,37 +0,0 @@
//
// Created by Amer Cerkic 05/02/2019
// Copyright 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
//
#pragma once
#ifndef hifi_PlatformJsonKeys_h
#define hifi_PlatformJsonKeys_h
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"};
static const char* computerModel { "computerModel"};
#endif
}
} // namespace plaform::jsonKeys
#endif

View file

@ -10,7 +10,16 @@
#include "CPUIdent.h"
#ifdef Q_OS_WIN
#include <QtCore/QtGlobal>
#include <string.h>
#include "CPUDetect.h"
void getCPUID(uint32_t* p, uint32_t eax) {
cpuidex((int*) p, (int) eax, 0);
}
void getCPUIDEX(uint32_t* p, uint32_t eax, uint32_t ecx) {
cpuidex((int*) p, (int) eax, (int) ecx);
}
const CPUIdent::CPUIdent_Internal CPUIdent::CPU_Rep;
@ -72,4 +81,86 @@ std::vector<CPUIdent::Feature> CPUIdent::getAllFeatures() {
return features;
};
#endif
CPUIdent::CPUIdent_Internal::CPUIdent_Internal()
: nIds_{ 0 },
nExIds_{ 0 },
isIntel_{ false },
isAMD_{ false },
f_1_ECX_{ 0 },
f_1_EDX_{ 0 },
f_7_EBX_{ 0 },
f_7_ECX_{ 0 },
f_81_ECX_{ 0 },
f_81_EDX_{ 0 },
data_{},
extdata_{}
{
//int cpuInfo[4] = {-1};
std::array<uint32_t, 4> cpui;
// Calling __cpuid with 0x0 as the function_id argument
// gets the number of the highest valid function ID.
getCPUID(cpui.data(), 0);
nIds_ = cpui[0];
for (uint32_t i = 0; i <= nIds_; ++i) {
getCPUIDEX(cpui.data(), i, 0);
data_.push_back(cpui);
}
// Capture vendor string
char vendor[0x20];
memset(vendor, 0, sizeof(vendor));
*reinterpret_cast<int*>(vendor) = data_[0][1];
*reinterpret_cast<int*>(vendor + 4) = data_[0][3];
*reinterpret_cast<int*>(vendor + 8) = data_[0][2];
vendor_ = vendor;
if (vendor_ == "GenuineIntel") {
isIntel_ = true;
}
else if (vendor_ == "AuthenticAMD") {
isAMD_ = true;
}
// load bitset with flags for function 0x00000001
if (nIds_ >= 1) {
f_1_ECX_ = data_[1][2];
f_1_EDX_ = data_[1][3];
}
// load bitset with flags for function 0x00000007
if (nIds_ >= 7) {
f_7_EBX_ = data_[7][1];
f_7_ECX_ = data_[7][2];
}
// Calling __cpuid with 0x80000000 as the function_id argument
// gets the number of the highest valid extended ID.
getCPUID(cpui.data(), 0x80000000);
nExIds_ = cpui[0];
char brand[0x40];
memset(brand, 0, sizeof(brand));
for (uint32_t i = 0x80000000; i <= nExIds_; ++i) {
getCPUIDEX(cpui.data(), i, 0);
extdata_.push_back(cpui);
}
// load bitset with flags for function 0x80000001
if (nExIds_ >= 0x80000001) {
f_81_ECX_ = extdata_[1][2];
f_81_EDX_ = extdata_[1][3];
}
// Interpret CPU brand string if reported
if (nExIds_ >= 0x80000004) {
memcpy(brand, extdata_[2].data(), sizeof(cpui));
memcpy(brand + 16, extdata_[3].data(), sizeof(cpui));
memcpy(brand + 32, extdata_[4].data(), sizeof(cpui));
brand_ = brand;
}
}

View file

@ -18,17 +18,11 @@
#ifndef hifi_CPUIdent_h
#define hifi_CPUIdent_h
#include <QtCore/QtGlobal>
#include <vector>
#include <bitset>
#include <array>
#include <string>
#ifdef Q_OS_WIN
#include <intrin.h>
class CPUIdent
{
// forward declarations
@ -109,88 +103,10 @@ private:
class CPUIdent_Internal
{
public:
CPUIdent_Internal()
: nIds_ { 0 },
nExIds_ { 0 },
isIntel_ { false },
isAMD_ { false },
f_1_ECX_ { 0 },
f_1_EDX_ { 0 },
f_7_EBX_ { 0 },
f_7_ECX_ { 0 },
f_81_ECX_ { 0 },
f_81_EDX_ { 0 },
data_ {},
extdata_ {}
{
//int cpuInfo[4] = {-1};
std::array<int, 4> cpui;
CPUIdent_Internal();
// Calling __cpuid with 0x0 as the function_id argument
// gets the number of the highest valid function ID.
__cpuid(cpui.data(), 0);
nIds_ = cpui[0];
for (int i = 0; i <= nIds_; ++i) {
__cpuidex(cpui.data(), i, 0);
data_.push_back(cpui);
}
// Capture vendor string
char vendor[0x20];
memset(vendor, 0, sizeof(vendor));
*reinterpret_cast<int*>(vendor) = data_[0][1];
*reinterpret_cast<int*>(vendor + 4) = data_[0][3];
*reinterpret_cast<int*>(vendor + 8) = data_[0][2];
vendor_ = vendor;
if (vendor_ == "GenuineIntel") {
isIntel_ = true;
} else if (vendor_ == "AuthenticAMD") {
isAMD_ = true;
}
// load bitset with flags for function 0x00000001
if (nIds_ >= 1) {
f_1_ECX_ = data_[1][2];
f_1_EDX_ = data_[1][3];
}
// load bitset with flags for function 0x00000007
if (nIds_ >= 7) {
f_7_EBX_ = data_[7][1];
f_7_ECX_ = data_[7][2];
}
// Calling __cpuid with 0x80000000 as the function_id argument
// gets the number of the highest valid extended ID.
__cpuid(cpui.data(), 0x80000000);
nExIds_ = cpui[0];
char brand[0x40];
memset(brand, 0, sizeof(brand));
for (int i = 0x80000000; i <= nExIds_; ++i) {
__cpuidex(cpui.data(), i, 0);
extdata_.push_back(cpui);
}
// load bitset with flags for function 0x80000001
if (nExIds_ >= 0x80000001) {
f_81_ECX_ = extdata_[1][2];
f_81_EDX_ = extdata_[1][3];
}
// Interpret CPU brand string if reported
if (nExIds_ >= 0x80000004) {
memcpy(brand, extdata_[2].data(), sizeof(cpui));
memcpy(brand + 16, extdata_[3].data(), sizeof(cpui));
memcpy(brand + 32, extdata_[4].data(), sizeof(cpui));
brand_ = brand;
}
};
int nIds_;
int nExIds_;
uint32_t nIds_;
uint32_t nExIds_;
std::string vendor_;
std::string brand_;
bool isIntel_;
@ -201,12 +117,9 @@ private:
std::bitset<32> f_7_ECX_;
std::bitset<32> f_81_ECX_;
std::bitset<32> f_81_EDX_;
std::vector<std::array<int, 4>> data_;
std::vector<std::array<int, 4>> extdata_;
std::vector<std::array<uint32_t, 4>> data_;
std::vector<std::array<uint32_t, 4>> extdata_;
};
};
#endif
#endif // hifi_CPUIdent_h

View file

@ -38,6 +38,15 @@ PropFolderPanel {
proItem['type'] = typeof(proItem.object[proItem.property])
}
switch(proItem.type) {
case 'string':
case 'PropString': {
var component = Qt.createComponent("PropString.qml");
component.createObject(propItemsContainer, {
"label": proItem.property,
"object": proItem.object,
"property": proItem.property
})
} break;
case 'boolean':
case 'PropBool': {
var component = Qt.createComponent("PropBool.qml");
@ -57,6 +66,7 @@ PropFolderPanel {
"min": (proItem["min"] !== undefined ? proItem.min : 0.0),
"max": (proItem["max"] !== undefined ? proItem.max : 1.0),
"integer": (proItem["integral"] !== undefined ? proItem.integral : false),
"readOnly": (proItem["readOnly"] !== undefined ? proItem["readOnly"] : false),
})
} break;
case 'PropEnum': {
@ -97,6 +107,22 @@ PropFolderPanel {
}
}
}
function populateFromObjectProps(object) {
var propsModel = []
var props = Object.keys(object);
for (var p in props) {
var o = {};
o["object"] = object
o["property"] = props[p];
// o["readOnly"] = true;
o["type"] = "string";
propsModel.push(o)
}
root.updatePropItems(root.propItemsPanel, propsModel);
}
Component.onCompleted: {
}
}

View file

@ -18,12 +18,16 @@ Item {
// Prop item is designed to author an object[property]:
property var object: {}
property string property: ""
property bool readOnly: false
// value is accessed through the "valueVarSetter" and "valueVarGetter"
// By default, these just go get or set the value from the object[property]
//
function defaultGet() { return root.object[root.property]; }
function defaultSet(value) { root.object[root.property] = value; }
// function defaultSetReadOnly(value) { log ( "read only " + property + ", NOT setting to " + value); }
// function defaultSetReadOnly(value) {}
// property var valueVarSetter: (root.readOnly ? defaultSetReadOnly : defaultSet)
property var valueVarSetter: defaultSet
property var valueVarGetter: defaultGet

View file

@ -20,16 +20,12 @@ PropItem {
property bool integral: false
property var numDigits: 2
property alias valueVar : sliderControl.value
property alias min: sliderControl.minimumValue
property alias max: sliderControl.maximumValue
property bool showValue: true
signal valueChanged(real value)
Component.onCompleted: {
@ -42,11 +38,11 @@ PropItem {
anchors.left: root.splitter.right
anchors.verticalCenter: root.verticalCenter
width: root.width * global.valueAreaWidthScale
width: root.width * (root.readOnly ? 1.0 : global.valueAreaWidthScale)
horizontalAlignment: global.valueTextAlign
height: global.slimHeight
text: sliderControl.value.toFixed(root.integral ? 0 : root.numDigits)
text: root.valueVarGetter().toFixed(root.integral ? 0 : root.numDigits)
background: Rectangle {
color: global.color
@ -58,12 +54,13 @@ PropItem {
HifiControls.Slider {
id: sliderControl
visible: !root.readOnly
stepSize: root.integral ? 1.0 : 0.0
anchors.left: valueLabel.right
anchors.right: root.right
anchors.verticalCenter: root.verticalCenter
onValueChanged: { root.valueVarSetter(value) }
onValueChanged: { if (!root.readOnly) { root.valueVarSetter(value)} }
}

View file

@ -0,0 +1,41 @@
//
// PropItem.qml
//
// Created by Sam Gateau on 3/2/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
import controlsUit 1.0 as HifiControls
PropItem {
Global { id: global }
id: root
// Scalar Prop
property bool integral: false
property var numDigits: 2
PropLabel {
id: valueLabel
anchors.left: root.splitter.right
anchors.right: root.right
anchors.verticalCenter: root.verticalCenter
horizontalAlignment: global.valueTextAlign
height: global.slimHeight
text: root.valueVarGetter();
background: Rectangle {
color: global.color
border.color: global.colorBorderLight
border.width: global.valueBorderWidth
radius: global.valueBorderRadius
}
}
}

View file

@ -10,5 +10,6 @@ PropFolderPanel 1.0 style/PiFolderPanel.qml
PropItem 1.0 PropItem.qml
PropScalar 1.0 PropScalar.qml
PropString 1.0 PropString.qml
PropEnum 1.0 PropEnum.qml
PropColor 1.0 PropColor.qml

View file

@ -24,6 +24,7 @@ Item {
readonly property real horizontalMargin: 4
readonly property color color: hifi.colors.baseGray
readonly property color colorBack: hifi.colors.baseGray
readonly property color colorBackShadow: hifi.colors.baseGrayShadow
readonly property color colorBackHighlight: hifi.colors.baseGrayHighlight
readonly property color colorBorderLight: hifi.colors.lightGray

View file

@ -31,7 +31,7 @@ Rectangle {
clip: true
Column {
width: render.width
width: parent.width
Prop.PropFolderPanel {
label: "Shading Model"
panelFrameData: Component {
@ -87,14 +87,14 @@ Rectangle {
}
}
}
Jet.TaskPropView {
/* Jet.TaskPropView {
id: "le"
jobPath: ""
label: "Le Render Engine"
// anchors.left: parent.left
// anchors.right: parent.right
}
}*/
}
}
}

View file

@ -0,0 +1,18 @@
// Test key commands
PlatformInfo.getComputer()
// {"OS":"WINDOWS","keys":null,"model":"","profileTier":"HIGH","vendor":""}
PlatformInfo.getNumCPUs()
// 1
PlatformInfo.getCPU(0)
//{"clockSpeed":" 4.00GHz","model":") i7-6700K CPU @ 4.00GHz","numCores":8,"vendor":"Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz"}
PlatformInfo.getNumGPUs()
// 1
PlatformInfo.getGPU(0)
// {"driver":"25.21.14.1967","model":"NVIDIA GeForce GTX 1080","vendor":"NVIDIA GeForce GTX 1080","videoMemory":8079}
var window = Desktop.createWindow(Script.resolvePath('./platform.qml'), {
title: "Platform",
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: 350, y: 700}
});

View file

@ -0,0 +1,75 @@
//
// platform.qml
//
// Created by Sam Gateau on 5/25/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import controlsUit 1.0 as HifiControls
import "../lib/prop" as Prop
Rectangle {
anchors.fill: parent
id: platform;
Prop.Global { id: global;}
color: global.colorBack
Column {
width: parent.width
Prop.PropGroup {
id: computer
label: "Computer"
isUnfold: true
Component.onCompleted: {
computer.populateFromObjectProps(JSON.parse(PlatformInfo.getComputer()))
}
}
Prop.PropGroup {
id: cpu
label: "CPU"
isUnfold: true
Component.onCompleted: {
cpu.populateFromObjectProps(JSON.parse(PlatformInfo.getCPU(0)))
}
}
Prop.PropGroup {
id: memory
label: "Memory"
isUnfold: true
Component.onCompleted: {
memory.populateFromObjectProps(JSON.parse(PlatformInfo.getMemory()))
}
}
Prop.PropGroup {
id: gpu
label: "GPU"
isUnfold: true
Component.onCompleted: {
gpu.populateFromObjectProps(JSON.parse(PlatformInfo.getGPU(0)))
}
}
Prop.PropGroup {
id: display
label: "Display"
isUnfold: true
Component.onCompleted: {
display.populateFromObjectProps(JSON.parse(PlatformInfo.getDisplay(0)))
}
}
}
}