mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Mac code for gpu memory.
This commit is contained in:
parent
c274df6066
commit
7f748153c5
3 changed files with 26 additions and 5 deletions
|
@ -18,7 +18,6 @@
|
|||
#include <QtCore/qjsonobject.h>
|
||||
#include <QtCore/qjsonvalue.h>
|
||||
#include <shared/JSONHelpers.h>
|
||||
#include <GPUIdent.h>
|
||||
|
||||
#include "SettingHandle.h"
|
||||
|
||||
|
@ -180,8 +179,6 @@ public:
|
|||
|
||||
// getter for qml integration, prefer the templated getter
|
||||
Q_INVOKABLE QObject* getConfig(const QString& name) { return QObject::findChild<JobConfig*>(name); }
|
||||
Q_INVOKABLE uint getVRam() { return GPUIdent::getInstance()->getMemory(); }
|
||||
Q_INVOKABLE QString getVCard() { return GPUIdent::getInstance()->getName(); }
|
||||
// getter for cpp (strictly typed), prefer this getter
|
||||
template <class T> typename T::Config* getConfig(std::string job = "") const {
|
||||
QString name = job.empty() ? QString() : QString(job.c_str()); // an empty string is not a null string
|
||||
|
|
|
@ -9,9 +9,13 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <atlbase.h>
|
||||
#include <Wbemidl.h>
|
||||
|
||||
#elif defined(Q_OS_MAC)
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#endif
|
||||
|
||||
#include "SharedLogging.h"
|
||||
|
@ -26,7 +30,28 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer)
|
|||
return this;
|
||||
}
|
||||
_isQueried = true; // Don't try again, even if not _isValid;
|
||||
#ifdef Q_OS_WIN
|
||||
#if (defined Q_OS_MAC)
|
||||
GLuint cglDisplayMask = -1; // Iterate over all of them.
|
||||
CGLRendererInfoObj rendererInfo;
|
||||
GLint rendererInfoCount;
|
||||
CGLError err = CGLQueryRendererInfo(cglDisplayMask, &rendererInfo, &rendererInfoCount);
|
||||
GLint j, numRenderers = 0, deviceVRAM, bestVRAM = 0;
|
||||
err = CGLQueryRendererInfo(cglDisplayMask, &rendererInfo, &numRenderers);
|
||||
if (0 == err) {
|
||||
// Iterate over all of them and use the figure for the one with the most VRAM,
|
||||
// on the assumption that this is the one that will actually be used.
|
||||
CGLDescribeRenderer(rendererInfo, 0, kCGLRPRendererCount, &numRenderers);
|
||||
for (j = 0; j < numRenderers; j++) {
|
||||
CGLDescribeRenderer(rendererInfo, j, kCGLRPVideoMemoryMegabytes, &deviceVRAM);
|
||||
if (deviceVRAM > bestVRAM) {
|
||||
bestVRAM = deviceVRAM;
|
||||
}
|
||||
}
|
||||
}
|
||||
_dedicatedMemoryMB = bestVRAM;
|
||||
CGLDestroyRendererInfo(rendererInfo);
|
||||
|
||||
#elif defined(Q_OS_WIN)
|
||||
// COM must be initialized already using CoInitialize. E.g., by the audio subsystem.
|
||||
CComPtr<IWbemLocator> spLoc = NULL;
|
||||
HRESULT hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, (LPVOID *)&spLoc);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#ifdef Q_OS_WIN
|
||||
#include "CPUIdent.h"
|
||||
#endif
|
||||
#include "GPUIdent.h"
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
|
Loading…
Reference in a new issue