diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fd56795e12..8789fcde1c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1659,7 +1659,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // The value will be 0 if the user blew away settings this session, which is both a feature and a bug. static const QString TESTER = "HIFI_TESTER"; auto gpuIdent = GPUIdent::getInstance(); - auto glContextData = getGLContextData(); + auto glContextData = gl::ContextInfo::get(); QJsonObject properties = { { "version", applicationVersion() }, { "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) || isTester }, @@ -1676,11 +1676,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo { "gpu_name", gpuIdent->getName() }, { "gpu_driver", gpuIdent->getDriver() }, { "gpu_memory", static_cast(gpuIdent->getMemory()) }, - { "gl_version_int", glVersionToInteger(glContextData.value("version").toString()) }, - { "gl_version", glContextData["version"] }, - { "gl_vender", glContextData["vendor"] }, - { "gl_sl_version", glContextData["sl_version"] }, - { "gl_renderer", glContextData["renderer"] }, + { "gl_version_int", glVersionToInteger(glContextData.version.c_str()) }, + { "gl_version", glContextData.version.c_str() }, + { "gl_vender", glContextData.vendor.c_str() }, + { "gl_sl_version", glContextData.shadingLanguageVersion.c_str() }, + { "gl_renderer", glContextData.renderer.c_str() }, { "ideal_thread_count", QThread::idealThreadCount() } }; auto macVersion = QSysInfo::macVersion(); @@ -2282,8 +2282,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo properties["active_display_plugin"] = getActiveDisplayPlugin()->getName(); properties["using_hmd"] = isHMDMode(); - auto glInfo = getGLContextData(); - properties["gl_info"] = glInfo; + auto contextInfo = gl::ContextInfo::get(); + properties["gl_info"] = QJsonObject{ + { "version", contextInfo.version.c_str() }, + { "sl_version", contextInfo.shadingLanguageVersion.c_str() }, + { "vendor", contextInfo.vendor.c_str() }, + { "renderer", contextInfo.renderer.c_str() }, + }; properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemSize()); properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemSize()); properties["gpu_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerGPUAverage()); diff --git a/libraries/gl/src/gl/GLHelpers.cpp b/libraries/gl/src/gl/GLHelpers.cpp index 2555ac61fc..b2c98e91d3 100644 --- a/libraries/gl/src/gl/GLHelpers.cpp +++ b/libraries/gl/src/gl/GLHelpers.cpp @@ -304,21 +304,6 @@ int glVersionToInteger(QString glVersion) { return (majorNumber << 16) | minorNumber; } -const QJsonObject& getGLContextData() { - static QJsonObject result; - static std::once_flag once; - std::call_once(once, [] { - auto contextInfo = gl::ContextInfo::get(); - result = QJsonObject { - { "version", contextInfo.version.c_str() }, - { "sl_version", contextInfo.shadingLanguageVersion.c_str() }, - { "vendor", contextInfo.vendor.c_str() }, - { "renderer", contextInfo.renderer.c_str() }, - }; - }); - return result; -} - QThread* RENDER_THREAD = nullptr; bool isRenderThread() { diff --git a/libraries/gl/src/gl/GLHelpers.h b/libraries/gl/src/gl/GLHelpers.h index 5090153bab..05687b2a8a 100644 --- a/libraries/gl/src/gl/GLHelpers.h +++ b/libraries/gl/src/gl/GLHelpers.h @@ -29,7 +29,6 @@ class QGLFormat; size_t evalGLFormatSwapchainPixelSize(const QSurfaceFormat& format); const QSurfaceFormat& getDefaultOpenGLSurfaceFormat(); -const QJsonObject& getGLContextData(); int glVersionToInteger(QString glVersion); bool isRenderThread(); diff --git a/libraries/platform/src/platform/PlatformKeys.h b/libraries/platform/src/platform/PlatformKeys.h index 02c6a6021d..9bd9d47890 100644 --- a/libraries/platform/src/platform/PlatformKeys.h +++ b/libraries/platform/src/platform/PlatformKeys.h @@ -34,21 +34,21 @@ namespace platform { namespace keys{ extern const char* displays; extern const char* isMaster; } - namespace renderingApis { + namespace graphicsAPI { + extern const char* name; + extern const char* version; extern const char* apiOpenGL; extern const char* apiVulkan; extern const char* apiDirect3D11; extern const char* apiDirect3D12; extern const char* apiMetal; namespace gl { - extern const char* version; extern const char* shadingLanguageVersion; extern const char* vendor; extern const char* renderer; extern const char* extensions; } namespace vk { - extern const char* version; extern const char* devices; namespace device { extern const char* apiVersion; @@ -115,7 +115,7 @@ namespace platform { namespace keys{ // Keys for categories used in json returned by getAll() extern const char* CPUS; extern const char* GPUS; - extern const char* RENDERING_APIS; + extern const char* GRAPHICS_APIS; extern const char* DISPLAYS; extern const char* NICS; extern const char* MEMORY; diff --git a/libraries/platform/src/platform/backend/Platform.cpp b/libraries/platform/src/platform/backend/Platform.cpp index d15ce34776..dd40de04f1 100644 --- a/libraries/platform/src/platform/backend/Platform.cpp +++ b/libraries/platform/src/platform/backend/Platform.cpp @@ -35,7 +35,10 @@ namespace platform { namespace keys { const char* displays = "displays"; const char* isMaster = "isMaster"; } - namespace renderingApis { + namespace graphicsAPI { + const char* name = "name"; + const char* version = "version"; + const char* apiOpenGL = "OpenGL"; const char* apiVulkan = "Vulkan"; const char* apiDirect3D11 = "D3D11"; @@ -116,7 +119,7 @@ namespace platform { namespace keys { const char* CPUS = "cpus"; const char* GPUS = "gpus"; - const char* RENDERING_APIS = "renderingApis"; + const char* GRAPHICS_APIS = "graphicsAPIS"; const char* DISPLAYS = "displays"; const char* NICS = "nics"; const char* MEMORY = "memory"; diff --git a/libraries/platform/src/platform/backend/PlatformInstance.cpp b/libraries/platform/src/platform/backend/PlatformInstance.cpp index 0ac11f9f0f..faea24289a 100644 --- a/libraries/platform/src/platform/backend/PlatformInstance.cpp +++ b/libraries/platform/src/platform/backend/PlatformInstance.cpp @@ -127,12 +127,13 @@ void Instance::enumerateRenderingApis() { { auto& glContextInfo = gl::ContextInfo::get(); json gl; - gl[keys::renderingApis::gl::version] = glContextInfo.version; - gl[keys::renderingApis::gl::vendor] = glContextInfo.vendor; - gl[keys::renderingApis::gl::renderer] = glContextInfo.renderer; - gl[keys::renderingApis::gl::shadingLanguageVersion] = glContextInfo.shadingLanguageVersion; - gl[keys::renderingApis::gl::extensions] = glContextInfo.extensions; - _renderingApis[keys::renderingApis::apiOpenGL] = gl; + gl[keys::graphicsAPI::name] = keys::graphicsAPI::apiOpenGL; + gl[keys::graphicsAPI::version] = glContextInfo.version; + gl[keys::graphicsAPI::gl::vendor] = glContextInfo.vendor; + gl[keys::graphicsAPI::gl::renderer] = glContextInfo.renderer; + gl[keys::graphicsAPI::gl::shadingLanguageVersion] = glContextInfo.shadingLanguageVersion; + gl[keys::graphicsAPI::gl::extensions] = glContextInfo.extensions; + _graphicsApis.push_back(gl); } #if defined(HAVE_VULKAN) @@ -144,36 +145,37 @@ void Instance::enumerateRenderingApis() { if (instancePtr) { json vkinfo; const auto& vkinstance = *instancePtr; - vkinfo[keys::renderingApis::vk::version] = vkVersionToString(VK_API_VERSION_1_1); + vkinfo[keys::graphicsAPI::name] = keys::graphicsAPI::apiVulkan; + vkinfo[keys::graphicsAPI::version] = vkVersionToString(VK_API_VERSION_1_1); for (const auto& physicalDevice : vkinstance.enumeratePhysicalDevices()) { json vkdevice; auto properties = physicalDevice.getProperties(); - vkdevice[keys::renderingApis::vk::device::driverVersion] = vkVersionToString(properties.driverVersion); - vkdevice[keys::renderingApis::vk::device::apiVersion] = vkVersionToString(properties.apiVersion); - vkdevice[keys::renderingApis::vk::device::deviceType] = vk::to_string(properties.deviceType); - vkdevice[keys::renderingApis::vk::device::vendor] = properties.vendorID; - vkdevice[keys::renderingApis::vk::device::name] = properties.deviceName; + vkdevice[keys::graphicsAPI::vk::device::driverVersion] = vkVersionToString(properties.driverVersion); + vkdevice[keys::graphicsAPI::vk::device::apiVersion] = vkVersionToString(properties.apiVersion); + vkdevice[keys::graphicsAPI::vk::device::deviceType] = vk::to_string(properties.deviceType); + vkdevice[keys::graphicsAPI::vk::device::vendor] = properties.vendorID; + vkdevice[keys::graphicsAPI::vk::device::name] = properties.deviceName; for (const auto& extensionProperties : physicalDevice.enumerateDeviceExtensionProperties()) { - vkdevice[keys::renderingApis::vk::device::extensions].push_back(extensionProperties.extensionName); + vkdevice[keys::graphicsAPI::vk::device::extensions].push_back(extensionProperties.extensionName); } for (const auto& queueFamilyProperties : physicalDevice.getQueueFamilyProperties()) { json vkqueuefamily; - vkqueuefamily[keys::renderingApis::vk::device::queue::flags] = vk::to_string(queueFamilyProperties.queueFlags); - vkqueuefamily[keys::renderingApis::vk::device::queue::count] = queueFamilyProperties.queueCount; - vkdevice[keys::renderingApis::vk::device::queues].push_back(vkqueuefamily); + vkqueuefamily[keys::graphicsAPI::vk::device::queue::flags] = vk::to_string(queueFamilyProperties.queueFlags); + vkqueuefamily[keys::graphicsAPI::vk::device::queue::count] = queueFamilyProperties.queueCount; + vkdevice[keys::graphicsAPI::vk::device::queues].push_back(vkqueuefamily); } auto memoryProperties = physicalDevice.getMemoryProperties(); for (uint32_t heapIndex = 0; heapIndex < memoryProperties.memoryHeapCount; ++heapIndex) { json vkmemoryheap; const auto& heap = memoryProperties.memoryHeaps[heapIndex]; - vkmemoryheap[keys::renderingApis::vk::device::heap::flags] = vk::to_string(heap.flags); - vkmemoryheap[keys::renderingApis::vk::device::heap::size] = heap.size; - vkdevice[keys::renderingApis::vk::device::heaps].push_back(vkmemoryheap); + vkmemoryheap[keys::graphicsAPI::vk::device::heap::flags] = vk::to_string(heap.flags); + vkmemoryheap[keys::graphicsAPI::vk::device::heap::size] = heap.size; + vkdevice[keys::graphicsAPI::vk::device::heaps].push_back(vkmemoryheap); } - vkinfo[keys::renderingApis::vk::devices].push_back(vkdevice); + vkinfo[keys::graphicsAPI::vk::devices].push_back(vkdevice); } - _renderingApis[keys::renderingApis::apiVulkan] = vkinfo; + _graphicsApis.push_back(vkinfo); } } catch (const std::runtime_error&) { } @@ -243,17 +245,13 @@ json Instance::listAllKeys() { keys::gpu::driver, keys::gpu::displays, - keys::renderingApis::apiOpenGL, - keys::renderingApis::apiVulkan, - keys::renderingApis::apiMetal, - keys::renderingApis::apiDirect3D11, - keys::renderingApis::apiDirect3D12, + keys::graphicsAPI::version, + keys::graphicsAPI::name, - keys::renderingApis::gl::version, - keys::renderingApis::gl::shadingLanguageVersion, - keys::renderingApis::gl::vendor, - keys::renderingApis::gl::renderer, - keys::renderingApis::gl::extensions, + keys::graphicsAPI::gl::shadingLanguageVersion, + keys::graphicsAPI::gl::vendor, + keys::graphicsAPI::gl::renderer, + keys::graphicsAPI::gl::extensions, keys::display::boundsLeft, keys::display::boundsRight, @@ -276,7 +274,7 @@ json Instance::listAllKeys() { keys::CPUS, keys::GPUS, - keys::RENDERING_APIS, + keys::GRAPHICS_APIS, keys::DISPLAYS, keys::MEMORY, keys::COMPUTER, @@ -308,7 +306,7 @@ json Instance::getAll() { all[keys::MEMORY] = _memory; all[keys::CPUS] = _cpus; all[keys::GPUS] = _gpus; - all[keys::RENDERING_APIS] = _renderingApis; + all[keys::GRAPHICS_APIS] = _graphicsApis; all[keys::DISPLAYS] = _displays; all[keys::NICS] = _nics; diff --git a/libraries/platform/src/platform/backend/PlatformInstance.h b/libraries/platform/src/platform/backend/PlatformInstance.h index 7078c31d90..7cb419ceca 100644 --- a/libraries/platform/src/platform/backend/PlatformInstance.h +++ b/libraries/platform/src/platform/backend/PlatformInstance.h @@ -58,7 +58,7 @@ protected: std::vector _gpus; std::vector _displays; std::vector _nics; - json _renderingApis; + json _graphicsApis; json _memory; json _computer; diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.cpp b/libraries/ui/src/ui/OffscreenQmlSurface.cpp index 34cac90a05..35fb92a086 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.cpp +++ b/libraries/ui/src/ui/OffscreenQmlSurface.cpp @@ -264,7 +264,19 @@ void OffscreenQmlSurface::initializeEngine(QQmlEngine* engine) { } auto rootContext = engine->rootContext(); - rootContext->setContextProperty("GL", ::getGLContextData()); + + static QJsonObject QML_GL_INFO; + static std::once_flag once_gl_info; + std::call_once(once_gl_info, [] { + const auto& contextInfo = gl::ContextInfo::get(); + QML_GL_INFO = QJsonObject { + { "version", contextInfo.version.c_str() }, + { "sl_version", contextInfo.shadingLanguageVersion.c_str() }, + { "vendor", contextInfo.vendor.c_str() }, + { "renderer", contextInfo.renderer.c_str() }, + }; + }); + rootContext->setContextProperty("GL", QML_GL_INFO); rootContext->setContextProperty("urlHandler", new UrlHandler(rootContext)); rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath())); rootContext->setContextProperty("ApplicationInterface", qApp);