-
Notifications
You must be signed in to change notification settings - Fork 50
Log graphics API that is in use by the Qt Quick #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2021 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <qml/util.h> | ||
|
||
#include <string> | ||
|
||
#include <QQuickWindow> | ||
#include <QSGRendererInterface> | ||
#include <QString> | ||
|
||
namespace QmlUtil { | ||
|
||
QString GraphicsApi(QQuickWindow* window) | ||
{ | ||
switch (window->rendererInterface()->graphicsApi()) { | ||
case QSGRendererInterface::Unknown: return "Unknown"; | ||
case QSGRendererInterface::Software: return "The Qt Quick 2D Renderer"; | ||
case QSGRendererInterface::OpenGL: return "OpenGL ES 2.0 or higher"; | ||
case QSGRendererInterface::Direct3D12: return "Direct3D 12"; | ||
case QSGRendererInterface::OpenVG: return "OpenVG via EGL"; | ||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is the isApiRhiBased function. It was introduced in Qt 5.14. This check is then appropriate and allows for a simplified control flow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jarolrod still needs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, i meant that the way it is done here simplifies the control flow compared to if we used the function. |
||
case QSGRendererInterface::OpenGLRhi: return "OpenGL ES 2.0 or higher via a graphics abstraction layer"; | ||
case QSGRendererInterface::Direct3D11Rhi: return "Direct3D 11 via a graphics abstraction layer"; | ||
case QSGRendererInterface::VulkanRhi: return "Vulkan 1.0 via a graphics abstraction layer"; | ||
case QSGRendererInterface::MetalRhi: return "Metal via a graphics abstraction layer"; | ||
case QSGRendererInterface::NullRhi: return "Null (no output) via a graphics abstraction layer"; | ||
#endif | ||
} // no default case, so the compiler can warn about missing cases | ||
assert(false); | ||
} | ||
|
||
} // namespace QmlUtil |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2021 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_QML_UTIL_H | ||
#define BITCOIN_QML_UTIL_H | ||
|
||
#include <QString> | ||
#include <QtGlobal> | ||
|
||
QT_BEGIN_NAMESPACE | ||
class QQuickWindow; | ||
QT_END_NAMESPACE | ||
|
||
/** | ||
* Utility functions used by the QML-based Bitcoin Core GUI. | ||
*/ | ||
namespace QmlUtil { | ||
/** | ||
* Returns a human-readable description of the graphics API | ||
* that is in use by the Qt Quick scene graph renderer. | ||
*/ | ||
QString GraphicsApi(QQuickWindow* window); | ||
|
||
} // namespace QmlUtil | ||
|
||
#endif // BITCOIN_QML_UTIL_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've spent hours and hours digging through Qt code to figure out if there is a better way than manually maintaining these strings. Sadly, there is not. For now, this allows us to conveniently debug.
Note: Let's revisit this at some point in the future