diff --git a/tools/nitpick/src/Nitpick.cpp b/tools/nitpick/src/Nitpick.cpp index 02ed120350..a7ec76be8c 100644 --- a/tools/nitpick/src/Nitpick.cpp +++ b/tools/nitpick/src/Nitpick.cpp @@ -9,6 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Nitpick.h" +#include "Platform.h" #ifdef Q_OS_WIN #include @@ -40,9 +41,15 @@ Nitpick::Nitpick(QWidget* parent) : QMainWindow(parent) { setWindowTitle("Nitpick - " + nitpickVersion); - clientProfiles << "VR-High" << "Desktop-High" << "Desktop-Low" << "Mobile-Touch" << "VR-Standalone"; - _ui.clientProfileComboBox->insertItems(0, clientProfiles); + _GPUVendors << "Nvidia" << "AMD"; + _ui.clientProfileComboBox->insertItems(0, _GPUVendors); + QString gpuVendor = Platform::getGraphicsCardType().toUpper(); + if (gpuVendor.contains("NVIDIA")) { + _ui.clientProfileComboBox->setCurrentIndex(0); + } else { + _ui.clientProfileComboBox->setCurrentIndex(1); + } } Nitpick::~Nitpick() { diff --git a/tools/nitpick/src/Nitpick.h b/tools/nitpick/src/Nitpick.h index 42f55ee8b2..046a07b8f5 100644 --- a/tools/nitpick/src/Nitpick.h +++ b/tools/nitpick/src/Nitpick.h @@ -111,7 +111,7 @@ private: bool _isRunningFromCommandline{ false }; - QStringList clientProfiles; + QStringList _GPUVendors; }; #endif // hifi_Nitpick_h \ No newline at end of file diff --git a/tools/nitpick/src/Platform.cpp b/tools/nitpick/src/Platform.cpp new file mode 100644 index 0000000000..5d1f6798df --- /dev/null +++ b/tools/nitpick/src/Platform.cpp @@ -0,0 +1,115 @@ +// +// Platform.h +// +// Created by Nissim Hadar on 2 Apr 2019. +// Copyright 2013 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 + +#include +#pragma comment(lib, "dxgi.lib") + +QString Platform::getGraphicsCardType() { +#ifdef Q_OS_WIN + IDXGIFactory1* pFactory = nullptr; + HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)(&pFactory)); + if (hr != S_OK || pFactory == nullptr) { + return "Unable to create DXGI"; + } + std::vector validAdapterList; + + using AdapterEntry = std::pair, std::vector>; + std::vector adapterToOutputs; + // Enumerate adapters and outputs + { + UINT adapterNum = 0; + IDXGIAdapter1* pAdapter = nullptr; + while (pFactory->EnumAdapters1(adapterNum, &pAdapter) != DXGI_ERROR_NOT_FOUND) { + + // Found an adapter, get descriptor + DXGI_ADAPTER_DESC1 adapterDesc; + pAdapter->GetDesc1(&adapterDesc); + + LARGE_INTEGER version; + hr = pAdapter->CheckInterfaceSupport(__uuidof(IDXGIDevice), &version); + + std::wstring wDescription (adapterDesc.Description); + std::string description(wDescription.begin(), wDescription.end()); + + AdapterEntry adapterEntry; + adapterEntry.first.first = adapterDesc; + adapterEntry.first.second = version; + + + + UINT outputNum = 0; + IDXGIOutput * pOutput; + bool hasOutputConnectedToDesktop = false; + while (pAdapter->EnumOutputs(outputNum, &pOutput) != DXGI_ERROR_NOT_FOUND) { + + // FOund an output attached to the adapter, get descriptor + DXGI_OUTPUT_DESC outputDesc; + pOutput->GetDesc(&outputDesc); + + adapterEntry.second.push_back(outputDesc); + + std::wstring wDeviceName(outputDesc.DeviceName); + std::string deviceName(wDeviceName.begin(), wDeviceName.end()); + + hasOutputConnectedToDesktop |= (bool)outputDesc.AttachedToDesktop; + + pOutput->Release(); + outputNum++; + } + + adapterToOutputs.push_back(adapterEntry); + + // add this adapter to the valid list if has output + if (hasOutputConnectedToDesktop && !adapterEntry.second.empty()) { + validAdapterList.push_back(adapterNum); + } + + pAdapter->Release(); + adapterNum++; + } + } + pFactory->Release(); + + if (!validAdapterList.empty()) { + auto& adapterEntry = adapterToOutputs[validAdapterList.front()]; + + std::wstring wDescription(adapterEntry.first.first.Description); + std::string description(wDescription.begin(), wDescription.end()); + return QString(description.c_str()); + } + +#elif defined Q_OS_MAC + 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'); + for (int i = 0; i < parts.size(); ++i) { + if (parts[i].toLower().contains("radeon") || parts[i].toLower().contains("nvidia")) { + return parts[i]; + } + } + + // unkown graphics card + return "UNKNOWN"; +#else + return QString("NO IMPLEMENTED"); +#endif + return ""; +} diff --git a/tools/nitpick/src/Platform.h b/tools/nitpick/src/Platform.h new file mode 100644 index 0000000000..da35580554 --- /dev/null +++ b/tools/nitpick/src/Platform.h @@ -0,0 +1,20 @@ +// +// Platform.h +// +// Created by Nissim Hadar on 2 Apr 2019. +// Copyright 2013 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_h +#define hifi_Platform_h + +#include + +class Platform { +public: + static QString getGraphicsCardType(); +}; + +#endif \ No newline at end of file diff --git a/tools/nitpick/src/common.h b/tools/nitpick/src/common.h index 51f1f85113..dfeb557fab 100644 --- a/tools/nitpick/src/common.h +++ b/tools/nitpick/src/common.h @@ -60,5 +60,5 @@ const double R_Y = 0.212655f; const double G_Y = 0.715158f; const double B_Y = 0.072187f; -const QString nitpickVersion{ "v3.1.5" }; +const QString nitpickVersion{ "v3.1.6" }; #endif // hifi_common_h \ No newline at end of file diff --git a/tools/nitpick/ui/Nitpick.ui b/tools/nitpick/ui/Nitpick.ui index e1d7699f22..4c98bd639e 100644 --- a/tools/nitpick/ui/Nitpick.ui +++ b/tools/nitpick/ui/Nitpick.ui @@ -56,7 +56,7 @@ 70 - 40 + 120 220 40 @@ -69,7 +69,7 @@ 70 - 180 + 200 220 40 @@ -82,7 +82,7 @@ 320 - 180 + 200 220 40 @@ -94,7 +94,7 @@ - 210 + 320 120 220 40 @@ -108,7 +108,7 @@ 70 - 300 + 360 220 40 @@ -121,7 +121,7 @@ 320 - 300 + 360 220 40 @@ -134,7 +134,7 @@ 70 - 240 + 280 220 40 @@ -147,7 +147,7 @@ 320 - 240 + 280 220 40 @@ -156,16 +156,6 @@ Create all testAuto scripts - - - - 320 - 40 - 120 - 40 - - - @@ -927,14 +917,29 @@ 330 190 - 181 - 51 + 180 + 50 Evaluate Test + + + + 330 + 110 + 180 + 40 + + + + + 16 + + +