fix(waylib): fix Vulkan dmabuf RT and SHM upload via wlroots - #1218
Conversation
Reviewer's GuideFix Vulkan dmabuf render targets and SHM uploads in waylib by adding thin wlroots Vulkan wrappers, introducing a ColorContentsMode/RenderTarget lifecycle, and wiring color contents handling through outputs, layers, viewports, and buffer rendering paths. Sequence diagram for Vulkan dmabuf render target lifecyclesequenceDiagram
actor Client
participant OutputHelper
participant WBufferRenderer
participant WRenderHelper
participant wlr_renderer
participant QtRHI as QRhi
Client->>OutputHelper: beginRender(pixelSize, format, flags, mode)
OutputHelper->>WBufferRenderer: beginRender(pixelSize, dpr, format, flags, mode)
WBufferRenderer->>WRenderHelper: acquireRenderTarget(renderControl, buffer, mode)
WRenderHelper->>wlr_renderer: waylib_vk_renderer_import_dmabuf(renderer, dmabuf, vkImage)
wlr_renderer-->>WRenderHelper: vkImage.image, vkImage.format
WRenderHelper-->>WBufferRenderer: RenderTarget (vkImage, colorPreserved)
WBufferRenderer->>QtRHI: renderNextFrame(renderer)
WBufferRenderer->>WRenderHelper: prepareVulkanRenderTarget(commandBuffer, RenderTarget)
WRenderHelper->>QtRHI: beginExternal()
WRenderHelper->>QtRHI: vkCmdPipelineBarrier (GENERAL -> COLOR_ATTACHMENT_OPTIMAL)
WRenderHelper->>QtRHI: endExternal()
WBufferRenderer->>WRenderHelper: finishVulkanRenderTarget(commandBuffer, RenderTarget)
WRenderHelper->>QtRHI: beginExternal()
WRenderHelper->>QtRHI: vkCmdPipelineBarrier (COLOR_ATTACHMENT_OPTIMAL -> GENERAL)
WRenderHelper->>QtRHI: endExternal()
note over WRenderHelper,wlr_renderer: BufferData destructor calls
WRenderHelper->>wlr_renderer: waylib_vk_imported_image_finish(renderer, vkImage)
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
6aa1d2b to
6f33d4f
Compare
|
TAG Bot New tag: 0.8.17 |
97c7fef to
e4cff83
Compare
There was a problem hiding this comment.
Pull request overview
EN: This PR updates waylib’s QtQuick rendering pipeline and the vendored wlroots Vulkan backend to correctly support Vulkan dmabuf render targets (COLOR_ATTACHMENT) and ensure SHM uploads are visible to Qt by flushing wlroots’ Vulkan stage command buffer. It also introduces a tri-state color contents preservation mode that flows from outputs/layers into render-target creation.
**ZH:**本 PR 更新了 waylib 的 QtQuick 渲染链路以及内置 wlroots 的 Vulkan 后端:通过以 COLOR_ATTACHMENT 方式导入 dmabuf 修复 Vulkan render target,并在 Qt 采样前 flush wlroots 的 Vulkan stage 命令缓冲以保证 SHM 上传可见。同时引入三态的颜色内容保留策略,并贯穿 output/layer 到 render target 的创建与生命周期管理。
Changes / 变更点:
- Add thin wlroots Vulkan wrapper APIs (
waylib_vk_renderer_import_dmabuf,waylib_vk_imported_image_finish,waylib_vk_renderer_flush_stage) and exportwaylib_*symbols. / 在 wlroots Vulkan 中新增waylib_薄封装 API 并导出符号。 - Introduce
WGlobal::ColorContentsModeandWRenderHelper::RenderTargetto manage render-target lifecycle + preserve/clear semantics. / 引入ColorContentsMode与RenderTarget句柄化生命周期管理。 - Wire the new mode and Vulkan barriers/flush through QtQuick buffer/output render path. / 将新模式与 Vulkan 屏障/flush 串到 QtQuick 渲染链路。
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
waylib/src/server/qtquick/wsgtextureprovider.cpp |
Flush wlroots Vulkan stage CB before Qt samples; adjust QRhiTexture cleanup ownership. |
waylib/src/server/qtquick/wrenderhelper.h |
Add WRenderHelper::RenderTarget handle type and Vulkan prepare/finish hooks. |
waylib/src/server/qtquick/wrenderhelper.cpp |
Implement render-target tracking, COLOR_ATTACHMENT dmabuf import for Vulkan, and layout transitions around Qt render passes. |
waylib/src/server/qtquick/woutputviewport.h |
Replace boolean preserve flag with WGlobal::ColorContentsMode property. |
waylib/src/server/qtquick/woutputviewport.cpp |
Implement colorContentsMode getter/setter + signal. |
waylib/src/server/qtquick/woutputrenderwindow.cpp |
Plumb ColorContentsMode through output/layer rendering; adjust shadow renderer decisions. |
waylib/src/server/qtquick/woutputlayer.h |
Add colorContentsMode property; remove PreserveColorContents flag. |
waylib/src/server/qtquick/woutputlayer.cpp |
Implement colorContentsMode state + signal. |
waylib/src/server/qtquick/woutputhelper.h |
Switch render-target API to return WRenderHelper::RenderTarget. |
waylib/src/server/qtquick/woutputhelper.cpp |
Return RenderTarget directly; update last-target API. |
waylib/src/server/qtquick/private/wqmlhelper.cpp |
Add QML helper isVulkanBackend based on WRenderHelper::getGraphicsApi(). |
waylib/src/server/qtquick/private/wqmlhelper_p.h |
Expose isVulkanBackend as a QML singleton property. |
waylib/src/server/qtquick/private/woutputviewport_p.h |
Store colorContentsMode in viewport private data. |
waylib/src/server/qtquick/private/wbufferrenderer.cpp |
Pass mode into beginRender; use render-target handle; add Vulkan prepare/finish calls. |
waylib/src/server/qtquick/private/wbufferrenderer_p.h |
Update renderer state to store RenderTarget + mode; add isColorPreserved(). |
waylib/src/server/kernel/woutput.cpp |
Filter AMD DCC modifiers when Vulkan renderer active to avoid white scanout. |
waylib/src/server/kernel/wglobal.h |
Add WGlobal::ColorContentsMode enum for QML/C++ use. |
tests/test_dtk_inwindowblur_override/main.cpp |
New QtTest validating DTK InWindowBlur QML override behavior. |
tests/test_dtk_inwindowblur_override/CMakeLists.txt |
Add build/test wiring and DConfig test environment setup. |
tests/CMakeLists.txt |
Register the new test subdirectory. |
src/core/qmlengine.h |
Store URL interceptor lifetime member. |
src/core/qmlengine.cpp |
Install QQmlAbstractUrlInterceptor to redirect DTK InWindowBlur QML to Treeland override. |
src/core/qml/overridable/InWindowBlur.qml |
New override component backed by Treeland Blur. |
src/core/qml/Effects/Blur.qml |
Add Vulkan fallback path (skip RenderBufferBlitter backdrop capture on Vulkan). |
src/CMakeLists.txt |
Add QRC resource for the DTK override QML. |
3rdparty/wlroots/wlroots.syms |
Export waylib_* symbols from the vendored wlroots build. |
3rdparty/wlroots/render/vulkan/texture.c |
Implement dmabuf import wrapper + imported-image finish helper. |
3rdparty/wlroots/render/vulkan/renderer.c |
Implement stage-CB flush helper for Vulkan renderer. |
3rdparty/wlroots/include/wlr/render/vulkan.h |
Declare new waylib Vulkan wrapper APIs and imported-image struct. |
Suppressed comments (1)
waylib/src/server/kernel/woutput.cpp:268
- EN: The
wlr_renderer_is_vk(renderer)check needsENABLE_VULKAN_RENDERguarding too; otherwise non-Vulkan builds won’t have the symbol and this block won’t compile. Please wrap the Vulkan-only modifier filtering with#ifdef ENABLE_VULKAN_RENDER.
ZH:wlr_renderer_is_vk(renderer)同样需要用ENABLE_VULKAN_RENDER保护,否则在未启用 Vulkan 的构建下该符号不可用,导致这里编译失败。建议将 Vulkan 专用的 modifier 过滤逻辑放进#ifdef ENABLE_VULKAN_RENDER。
const struct wlr_drm_format *effective_render_format = render_format;
if (wlr_renderer_is_vk(renderer)) {
for (size_t i = 0; i < render_format->len; i++) {
uint64_t mod = render_format->modifiers[i];
if (IS_AMD_FMT_MOD(mod)
&& ((mod >> AMD_FMT_MOD_DCC_SHIFT) & AMD_FMT_MOD_DCC_MASK)) {
continue;
}
if (!wlr_drm_format_add(&dcc_filtered, mod)) {
wlr_drm_format_finish(&dcc_filtered);
return false;
}
}
if (dcc_filtered.len > 0)
effective_render_format = &dcc_filtered;
}
cf6fa22 to
e845094
Compare
73bcd8e to
1fa40d8
Compare
1fa40d8 to
b4cd9df
Compare
161e901 to
b4ffa07
Compare
zzxyb
left a comment
There was a problem hiding this comment.
晚点合入,在wlroots 0.20.2升级后再合
1fdc0e9 to
6c69ddb
Compare
1. Reuse wlroots wlr_vk_render_buffer for Qt Quick RHI. 2. Record FOREIGN_EXT ownership transfer around Qt rendering. 3. Preserve SHM partial updates and avoid QRhi::finish on Vulkan. Log: Fix Vulkan scanout and SHM upload stability Influence: 1. Run Vulkan output rendering with SHM and DMA-BUF clients. 2. Verify repeated frames and buffer reuse do not crash. 3. Verify GLES and software paths keep their existing flush behavior. Acknowledgements: Thanks to GitHub user @LFRon for identifying the Qt RHI/wlroots Vulkan integration issue and suggesting in PR linuxdeepin#1132 that Treeland reuse wlroots APIs, which helped guide this implementation. fix(waylib): 修复 Vulkan 扫描输出渲染目标 1. 复用 wlroots 的 wlr_vk_render_buffer 供 Qt Quick RHI 使用。 2. 在 Qt 绘制前后记录 FOREIGN_EXT 所有权转移。 3. 保留 SHM 局部更新,并避免 Vulkan 调用 QRhi::finish。 Log: 修复 Vulkan 扫描输出与 SHM 上传稳定性 Influence: 1. 验证 Vulkan 下 SHM 和 DMA-BUF 客户端输出。 2. 验证多帧绘制和缓冲复用不再触发崩溃。 3. 验证 GLES 与软件渲染路径保持原有刷新行为。 致谢: 感谢 GitHub 用户 @LFRon 发现 Qt RHI 与 wlroots Vulkan 集成问题, 并在 PR linuxdeepin#1132 中建议 Treeland 直接复用 wlroots 暴露的 API, 为本次实现提供了重要参考。
6c69ddb to
54541c0
Compare
1. Use a white placeholder Rectangle for Blur in Vulkan mode. 2. Preserve InWindowBlur content and offscreen semantics. 3. Stabilize lockscreen user switching popup lifecycle and visibility. 4. Keep the popup regression test independent of QtQuick.Window. Log: Restore lockscreen blur and user popup rendering Influence: 1. Verify the white Blur placeholder on the Vulkan backend. 2. Verify InWindowBlur offscreen and valid transitions. 3. Run DTK override tests with software, OpenGL, and Vulkan backends. fix(lockscreen): 增加 Vulkan 专用 Blur 占位处理 1. Vulkan 模式下使用白色 Rectangle 作为 Blur 占位实现。 2. 保持 InWindowBlur 内容和 offscreen 语义兼容。 3. 稳定锁屏切换用户弹窗的生命周期和显示行为。 4. 保持弹窗回归测试不依赖 QtQuick.Window QML 模块。 Log: 恢复锁屏模糊与用户弹窗渲染行为 Influence: 1. 验证 Vulkan 后端下的白色 Blur 占位实现。 2. 验证 InWindowBlur 的 offscreen 和 valid 状态切换。 3. 使用软件、OpenGL 和 Vulkan 后端运行 DTK 覆盖测试。
54541c0 to
cb5baa8
Compare
1. Launch the build-tree wallpaper factory in Qt Debug builds. 2. Keep Release builds on the installed factory executable. 3. Avoid requiring a separately installed Debug factory binary. Log: Debug wallpaper sessions now use the build-tree factory. Influence: 1. Verify Debug Treeland starts the build-tree factory. 2. Verify wallpaper updates work in Debug sessions. 3. Verify Release still starts installed treeland-wallpaper-factory. fix(wallpaper):Debug 使用构建目录中的 factory 1. Qt Debug 构建启动构建目录中的 wallpaper factory。 2. Release 构建继续使用系统安装的 factory。 3. 避免 Debug 环境依赖额外安装的 factory。 Log: Debug wallpaper 会话现在使用构建目录中的 factory。 Influence: 1. 验证 Debug Treeland 启动构建目录中的 factory。 2. 验证 Debug 会话中的 wallpaper 更新正常。 3. 验证 Release 仍启动系统安装的 treeland-wallpaper-factory。
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zccrs, zzxyb The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary
Fix Vulkan rendering without copying wlroots internals (supersedes the approach in #1132; core scanout path aligned with #1171).
Changes
waylib_APIs)waylib_vk_renderer_get_render_buffer_attribs()— reuse wlrootswlr_vk_render_buffer(same VkImage as tinywl/scene)waylib_vk_renderer_record_render_buffer_acquire/release()—VK_QUEUE_FAMILY_FOREIGN_EXTownership transfer (same as wlrootspass.c)waylib_vk_renderer_flush_stage()— flush SHM stage CB before Qt sampleswaylib_*inwlroots.symsQRhiTexture::setNativeLayout(GENERAL)ColorContentsModeandWRenderHelper::RenderTargetlifecycleBlur.qml: skipRenderBufferBlitteron Vulkan for nowInWindowBlur→ TreelandBlurtests/test_dtk_inwindowblur_overrideWhy not DCC modifier filtering
Filtering AMD DCC in
output_pick_formatwas wrong: tinywl is fine with the same modifiers; stripping DCC black-screened some AMD machines. Dropped.Why not #1132 style
Vendor wlroots → thin helpers, not a ~600-line copy of import logic.
Relation to #1171
Core scanout ownership model matches #1171 (
get_render_buffer+ FOREIGN acquire/release + QRhi layout sync). This PR stays smaller: no full presentation/blitter/trace rewrite yet.摘要
复用 wlroots
wlr_vk_render_buffer(与 tinywl 同路径),Qt 绘制前后做 FOREIGN_EXT acquire/release 并同步 QRhi layout;保留 SHM stage flush。不再平行 import dmabuf,也不再过滤 AMD DCC。核心与 #1171 对齐,范围更小。Acknowledgements
Thanks to LFRon for identifying the Qt RHI/wlroots Vulkan integration issue and suggesting in #1132 that Treeland reuse wlroots APIs, which helped guide this implementation.
致谢
感谢 LFRon 发现 Qt RHI 与 wlroots Vulkan 集成问题,并在 #1132 中建议 Treeland 直接复用 wlroots 暴露的 API,为本次实现提供了重要参考。
Test plan
cmake --build build --target waylib-wlroots waylibserverctest -R test_dtk_inwindowblur_override(local)RADV_DEBUG=nodcc: no white/black/garbage