PR feedback

This commit is contained in:
Brad Davis 2019-08-01 16:57:54 -07:00
parent bfe42215aa
commit 06ad461c32
8 changed files with 67 additions and 65 deletions

View file

@ -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<qint64>(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());

View file

@ -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() {

View file

@ -29,7 +29,6 @@ class QGLFormat;
size_t evalGLFormatSwapchainPixelSize(const QSurfaceFormat& format);
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat();
const QJsonObject& getGLContextData();
int glVersionToInteger(QString glVersion);
bool isRenderThread();

View file

@ -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;

View file

@ -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";

View file

@ -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;

View file

@ -58,7 +58,7 @@ protected:
std::vector<json> _gpus;
std::vector<json> _displays;
std::vector<json> _nics;
json _renderingApis;
json _graphicsApis;
json _memory;
json _computer;

View file

@ -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);