-
Notifications
You must be signed in to change notification settings - Fork 43
【Experimental】Enable Vulkan Renderer #1032
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
base: master
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -7,6 +7,9 @@ | |
|
|
||
| extern "C" { | ||
| #include <wlr/render/wlr_texture.h> | ||
| #if WLR_HAVE_VULKAN_RENDERER | ||
| #include <wlr/render/vulkan.h> | ||
| #endif | ||
| } | ||
|
|
||
| QW_BEGIN_NAMESPACE | ||
|
|
@@ -17,6 +20,10 @@ class QW_CLASS_REINTERPRET_CAST(texture) | |
| QW_FUNC_STATIC(texture, from_pixels, qw_texture *, wlr_renderer *renderer, uint32_t fmt, uint32_t stride, uint32_t width, uint32_t height, const void *data) | ||
| QW_FUNC_STATIC(texture, from_dmabuf, qw_texture *, wlr_renderer *renderer, wlr_dmabuf_attributes *attribs) | ||
| QW_FUNC_STATIC(texture, from_buffer, qw_texture *, wlr_renderer *renderer, wlr_buffer *buffer) | ||
| #if WLR_HAVE_VULKAN_RENDERER | ||
| QW_FUNC_MEMBER(vk_texture, get_image_attribs, void, wlr_vk_image_attribs *attribs) | ||
|
Member
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. 同上 |
||
| QW_FUNC_MEMBER(vk_texture, has_alpha, bool) | ||
| #endif | ||
|
|
||
| QW_FUNC_MEMBER(texture, update_from_buffer, bool, wlr_buffer *buffer, const pixman_region32_t *damage) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,13 @@ | |
| #include <qwbuffer.h> | ||
| #include <qwlogging.h> | ||
|
|
||
| #include <DGuiApplicationHelper> | ||
| #include <DLog> | ||
|
|
||
| #include <QByteArray> | ||
| #include <QGuiApplication> | ||
| #include <QMetaType> | ||
| #include <QPalette> | ||
|
|
||
| #if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0) | ||
| # include <private/qgenericunixtheme_p.h> | ||
|
|
@@ -54,7 +55,15 @@ | |
| }); | ||
| // QQuickStyle::setStyle("Material"); | ||
|
|
||
| QGuiApplication::setAttribute(Qt::AA_UseOpenGLES); | ||
|
Member
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. 这行应该可以直接删掉,WRenderHelper::setupRendererBackend(); 会找到合适的backend
Member
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. 这里的设置不要紧,只是告诉Qt如果用opengl,应该用gles版本,不会影响treeland和QtQuick的渲染引擎。 |
||
| const QByteArray wlrRenderer = qgetenv("WLR_RENDERER"); | ||
| const bool hasExplicitWlrRenderer = !wlrRenderer.isEmpty() && wlrRenderer != "auto"; | ||
| if (wlrRenderer != "vulkan") | ||
| QGuiApplication::setAttribute(Qt::AA_UseOpenGLES); | ||
| if (hasExplicitWlrRenderer) { | ||
| WRenderHelper::setupRendererBackend(); | ||
| if (wlrRenderer == "vulkan") | ||
| qunsetenv("QSG_RHI_BACKEND"); | ||
| } | ||
| QGuiApplication::setHighDpiScaleFactorRoundingPolicy( | ||
| Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); | ||
| QGuiApplication::setQuitOnLastWindowClosed(false); | ||
|
|
@@ -77,7 +86,8 @@ | |
| #endif | ||
| DLogManager::registerJournalAppender(); | ||
|
|
||
| WRenderHelper::setupRendererBackend(); | ||
| if (!hasExplicitWlrRenderer) | ||
| WRenderHelper::setupRendererBackend(); | ||
| if (CmdLine::ref().tryExec()) | ||
| return 0; | ||
| Q_ASSERT(qw_buffer::get_objects().isEmpty()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
|
|
||
| #include <qwbuffer.h> | ||
| #include <qwlayershellv1.h> | ||
| #include <qwrenderer.h> | ||
|
|
||
| #include <QColor> | ||
| #include <QVariant> | ||
|
|
@@ -33,6 +34,21 @@ | |
| #define CLOSE_ANIMATION 2 | ||
| #define ALWAYSONTOPLAYER 1 | ||
|
|
||
| namespace { | ||
| bool isVulkanRendererBackend() | ||
| { | ||
| #ifdef ENABLE_VULKAN_RENDER | ||
| auto *helper = Helper::instance(); | ||
| if (!helper || !helper->window() || !helper->window()->renderer()) | ||
| return false; | ||
|
|
||
| return wlr_renderer_is_vk(helper->window()->renderer()->handle()); | ||
| #else | ||
| return false; | ||
| #endif | ||
| } | ||
| } | ||
|
|
||
| SurfaceWrapper::SurfaceWrapper(QmlEngine *qmlEngine, | ||
| WToplevelSurface *shellSurface, | ||
| Type type, | ||
|
|
@@ -609,6 +625,7 @@ void SurfaceWrapper::startPrelaunchSplashHideSequence() | |
| const QRectF toGeometry(toTopLeft, targetImplicitSize); | ||
| m_geometryAnimation = | ||
| m_engine->createGeometryAnimation(this, fromGeometry, toGeometry, container()); | ||
| Q_EMIT animationRunningChanged(); | ||
|
|
||
| bool ok = connect(m_geometryAnimation, | ||
| SIGNAL(ready()), | ||
|
|
@@ -647,6 +664,7 @@ void SurfaceWrapper::onPrelaunchGeometryAnimationFinished() | |
| m_geometryAnimation->disconnect(this); | ||
| m_geometryAnimation->deleteLater(); | ||
| m_geometryAnimation = nullptr; | ||
| Q_EMIT animationRunningChanged(); | ||
|
|
||
| if (m_decoration) | ||
| m_decoration->setVisible(true); | ||
|
|
@@ -1004,6 +1022,7 @@ void SurfaceWrapper::setSurfaceState(State newSurfaceState) | |
| m_geometryAnimation->disconnect(this); | ||
| m_geometryAnimation->deleteLater(); | ||
| m_geometryAnimation = nullptr; | ||
| Q_EMIT animationRunningChanged(); | ||
| } | ||
|
|
||
| doSetSurfaceState(newSurfaceState); | ||
|
|
@@ -1270,6 +1289,8 @@ void SurfaceWrapper::createNewOrClose(uint direction) | |
| case Type::XWayland: { | ||
| m_windowAnimation = m_engine->createNewAnimation(this, container(), direction); | ||
| m_windowAnimation->setProperty("enableBlur", m_blur); | ||
| if (m_type == Type::SplashScreen && isVulkanRendererBackend()) | ||
| m_windowAnimation->setProperty("liveSource", false); | ||
|
Member
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. 这是为啥?为什么vulkan backend时liveSource需要是false? |
||
| } break; | ||
| case Type::Layer: { | ||
| auto scope = QString(static_cast<WLayerSurfaceItem *>(m_surfaceItem) | ||
|
|
@@ -1413,6 +1434,7 @@ void SurfaceWrapper::onAnimationReady() | |
| m_geometryAnimation->disconnect(this); | ||
| m_geometryAnimation->deleteLater(); | ||
| m_geometryAnimation = nullptr; | ||
| Q_EMIT animationRunningChanged(); | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -1429,6 +1451,7 @@ void SurfaceWrapper::onAnimationFinished() | |
| m_geometryAnimation->disconnect(this); | ||
| m_geometryAnimation->deleteLater(); | ||
| m_geometryAnimation = nullptr; | ||
| Q_EMIT animationRunningChanged(); | ||
| } | ||
|
|
||
| bool SurfaceWrapper::startStateChangeAnimation(State targetState, const QRectF &targetGeometry) | ||
|
|
@@ -1438,6 +1461,7 @@ bool SurfaceWrapper::startStateChangeAnimation(State targetState, const QRectF & | |
|
|
||
| m_geometryAnimation = | ||
| m_engine->createGeometryAnimation(this, geometry(), targetGeometry, container()); | ||
| Q_EMIT animationRunningChanged(); | ||
| m_geometryAnimation->setProperty("enableBlur", m_blur); | ||
| m_pendingState = targetState; | ||
| m_pendingGeometry = targetGeometry; | ||
|
|
||
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.
不应该加到这个class里,要有应该是个新的 vk_renderer 类型