Skip to content

feat: vendor WSGBatchRenderer and centralize output geometry - #1664

Merged
zccrs merged 3 commits into
linuxdeepin:masterfrom
zccrs:wsg-batch-renderer-base
Nov 18, 2026
Merged

zccrs merged 3 commits into
linuxdeepin:masterfrom
zccrs:wsg-batch-renderer-base

Conversation

@zccrs

@zccrs zccrs commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Split the prerequisite work out of #1275 so it can be reviewed and merged before the Scene Graph damage tracking.

This branch is rebased onto current linuxdeepin/treeland master (87c837729).

  1. Vendor Qt Quick's QSGBatchRenderer as WSGBatchRenderer and install it before any QQuickRenderControl is created.
  2. Composite captured non-cursor layers through that renderer.
  3. Output owns the output geometry: applyGeometry() only sets item and viewport size, applyPendingGeometry() derives mode/orientation/scale from the staged extraState (falling back to committed values), and setTransform() stages an orientation and resyncs. OutputManager::setScale reuses the same path. setExtraState() wakes only that output with scheduleFrame().

Damage tracking and the treeland-debug highlight stay on wsg-batch-renderer and are not in this PR.

摘要

从 #1275 拆出 damage 之前的前提改动,方便先审核合入。

分支已变为基到当前 linuxdeepin/treeland master(87c837729)。

  1. 将 Qt Quick 的 QSGBatchRenderer 引入为 WSGBatchRenderer,并在创建任何 QQuickRenderControl 之前安装。
  2. 通过该渲染器合成捕获的非光标图层。
  3. 输出几何归 Output:applyGeometry() 只设置 item 与 viewport 尺寸;applyPendingGeometry() 按 extraState 中暂存的 mode/方向/缩放计算(未暂存时回退到已提交值);setTransform() 暂存方向并重算几何;OutputManager::setScale 复用同一路径;setExtraState() 只唤醒该路输出(scheduleFrame())。

场景图 damage 跟踪和 treeland-debug 高亮仍留在 wsg-batch-renderer,不在本 PR。

Review follow-up

  • Output::applyPendingGeometry() replaces the duplicated mode/scale math (OutputManager::setScale, Output::enable), and reads staged mode/transform/scale so a rapid rotate-after-scale cannot compute a stale viewport.
  • WaylandServer::setOutputTransform is gone. Output::setTransform(WOutput::Transform) is Q_INVOKABLE, and Output::create()/createCopy() expose the wrapper to the item as treelandOutput; SourceOutput.qml and MirrorOutput.qml call it directly instead of going through a forwarder.
  • scenegraph/README.md no longer records a local /home/... tree path.
  • woutputviewport.cpp includes woutputhelper.h for WOutputHelper::ExtraState (the branch did not compile without it).
  • The vendored renderer no longer references QSGNodePrivate::mutabilityGroup(). Qt 6.12 declares that function but only marks the class Q_AUTOTEST_EXPORT, so a 6.12 build failed to link; the group stays neutral, matching the vendored 6.11 invalidation rules.

Test plan

Local verification on this head (Debug, Qt 6.8.0):

  • cmake --build in the -Werror CI configuration completes.
  • Headless compositor (WLR_BACKENDS=headless, pixman) driven by wlr-randr + treeland-debug scene:
Step QML output item WOutputViewport
1280x720, normal, scale 1 1280x720 1280x720
1280x720, normal, scale 2 640x360 640x360
1280x720, 90°, scale 1 720x1280 1280x720
1280x720, 90°, scale 2 360x640 640x360
1280x720, normal, scale 1.5 853.3x480 853.3x480
1024x768 custom, normal, scale 2 512x384 512x384
  • test_wlr_output_management_unstable_v1 passes.
  • Full ctest sweep: 90/97 pass. The 7 failures (test_native_handles, test_treeland_dde_shell_lockscreen_desktop_v1, test_treeland_dde_shell_multitask_desktop_v1, test_session_isolation, test_treeland_prelaunch_splash_desktop_v2, test_wayland_ext_session_lock_v1, test_wayland_xdg_output_unstable_v1) reproduce identically on unmodified master 87c837729 in the same environment, so they are not regressions from this PR. test_drm is skipped without a DRM device.

Checklist:

  • Launch tinywl-qtquick on the default RHI backend and confirm windows, titlebar, lockscreen, overview, blur, and glass still render.
  • Run with QT_QUICK_BACKEND=software and confirm the software path is unchanged.
  • Change resolution, rotate, and scale an output. Confirm windows follow the new logical size and the picture is not stretched.
  • Confirm a pending mode or transform does not schedule a frame on other outputs.

@sourcery-ai

sourcery-ai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Sorry @zccrs, your pull request is larger than the review limit of 150,000 diff characters

@zccrs
zccrs requested a review from zzxyb November 16, 2026 09:15
@zccrs
zccrs force-pushed the wsg-batch-renderer-base branch from b0faaf1 to c176920 Compare November 16, 2026 09:40
Comment thread src/core/waylandserver.cpp Resolved
Comment thread src/output/output.cpp Resolved
Comment thread src/output/output.cpp Resolved
@zccrs
zccrs force-pushed the wsg-batch-renderer-base branch from c176920 to 11e432f Compare November 16, 2026 10:35
1. Vendor qtdeclarative v6.11.1 QSGBatchRenderer/QSGRhiVisualizer
   into waylib as WSGBatchRenderer, version-gated for Qt 6.8-6.12.
2. Install WSGContext as QQuickRenderControlPrivate::sg before any
   QQuickRenderControl so RHI createRenderer() returns the fork.
3. Route extra sources and WRenderBufferNode through createRenderer();
   keep the software backend on Qt's own scene graph adaptation.

Log: RHI path uses a vendored Scene Graph batch renderer. No
user-facing changes yet; damage tracking is not in this step.

Influence:
1. Launch tinywl-qtquick on the default RHI backend and verify
   windows, titlebar, lockscreen, overview, Blur/Glass still render.
2. Run with QT_QUICK_BACKEND=software and confirm the software path
   is unchanged and RenderControl creation does not crash.
3. Confirm that creating a QQuickRenderControl before
   WOutputRenderWindow fatals with the WSGContext install error.

feat: 将 Qt BatchRenderer 以 WSGBatchRenderer 接入 RHI

1. 从 qtdeclarative v6.11.1 引入 QSGBatchRenderer/QSGRhiVisualizer,
   命名空间改为 WSGBatchRenderer,并用版本宏兼容 Qt 6.8-6.12。
2. 在任何 QQuickRenderControl 构造前安装 WSGContext 覆盖 sg,
   使 RHI 路径的 createRenderer() 直接创建 fork。
3. extra source 与 WRenderBufferNode 改为走 createRenderer();
   software 仍使用 Qt 自己的 scene graph adaptation。

Log: RHI 路径改用自带的 Scene Graph batch renderer。暂无用户可见
变化,本步未做 damage tracking。

Influence:
1. 用默认 RHI 启动 tinywl-qtquick,检查窗口、标题栏、锁屏、多任务、
   Blur/Glass 绘制是否正常。
2. 设置 QT_QUICK_BACKEND=software,确认 software 路径不变、不崩溃。
3. 若在 WOutputRenderWindow 之前创建 QQuickRenderControl,应 qFatal。

Log: RHI path uses a vendored Scene Graph batch renderer. No
PMS:
@zccrs
zccrs force-pushed the wsg-batch-renderer-base branch 2 times, most recently from 9393cc4 to 7e828e8 Compare November 16, 2026 11:18
@LFRon

LFRon commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@zccrs 大佬,QML画布局部更新功能还有吗(

@zccrs

zccrs commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@zccrs 大佬,QML画布局部更新功能还有吗(

有呀,只是拆分了下提交,这个提交里没有

@zccrs
zccrs force-pushed the wsg-batch-renderer-base branch 2 times, most recently from 4b0f70a to 9a3d55f Compare November 17, 2026 02:23
Comment thread src/output/output.cpp Resolved
Comment thread src/output/outputmanager.cpp Resolved
@zccrs
zccrs force-pushed the wsg-batch-renderer-base branch 8 times, most recently from d8f81d2 to 661b253 Compare November 17, 2026 04:29
1. A capture lock forbids direct scan-out and reads the primary buffer
2. Non-cursor OutputLayers on a locked output left their pixels on a plane
3. OutputHelper pins those layers onto the primary plane while compositing
4. Cursor layers stay; overlay cursor still uses software_cursor_locks

Log: Screencopy now includes non-cursor layer content in the primary buffer

Influence:
1. Start a screencopy while a non-cursor OutputLayer is on a hardware plane
2. Confirm the captured buffer contains that layer's pixels, not a hole
3. Confirm the cursor plane is unchanged unless overlay cursor was requested

fix: 捕获时把非光标层合成进主平面

1. 捕获锁禁止直接扫描输出,读的是主 buffer
2. 被锁输出上的非光标层原先留在独立 plane,截图里是洞
3. OutputHelper 合成时把这些层钉到主平面,不让 OutputLayer 关心这把锁
4. 光标层保持不动,带光标仍走 software_cursor_locks

Log: 截屏主缓冲现在包含非光标层的内容

Influence:
1. 非光标 OutputLayer 在硬件平面上时开始截屏
2. 确认截到的 buffer 含该层像素,而不是一块空洞
3. 确认未要求叠加光标时光标平面不变

Log: Screencopy now includes non-cursor layer content in the primary buffer
PMS:
@zccrs
zccrs force-pushed the wsg-batch-renderer-base branch 6 times, most recently from db04138 to 4b7ccac Compare November 17, 2026 08:55
1. Output::applyGeometry only sets item and viewport size. It does not
   read or write wlr_output_state.
2. Output::applyPendingGeometry derives mode, orientation, and scale from
   the staged extraState, falling back to the committed values, so the
   frame that commits a new state already draws at the new size.
3. Output::setTransform is Q_INVOKABLE. SourceOutput and MirrorOutput call
   it on the Output exposed as treelandOutput instead of going through a
   WaylandServer forwarder.
4. Rotation follows the output transform: applyPendingGeometry rotates the
   QML viewport, except for the animated rotation, which owns the rotation
   while it runs and commits at its halfway point.
5. Mode, scale, and adaptive sync still stage through setExtraState, and
   OutputManager keeps the protocol-facing configuration.

Influence:
1. Change resolution and confirm windows rearrange to the new size.
2. Rotate an output and confirm the item swaps size at the halfway point.
3. Change scale and confirm logical size updates without a stretched frame.

refactor: 把屏幕尺寸的更新集中到一处

1. Output::applyGeometry 现在只负责设置 item 和 viewport 的大小,不再读写
   wlr_output_state。
2. Output::applyPendingGeometry 根据暂存的 extraState 计算分辨率、方向和
   缩放,未暂存时回退到已提交的值,保证提交新状态的那一帧就按新尺寸绘制。
3. Output::setTransform 是 Q_INVOKABLE;SourceOutput 和 MirrorOutput 通过
   暴露为 treelandOutput 的 Output 直接调用,不再经 WaylandServer 转发。
4. 旋转跟随屏幕的 transform:applyPendingGeometry 负责设置 QML viewport
   的旋转;只有旋转动画自身例外,它在动画期间自己管理角度并在中点提交。
5. 分辨率、缩放和自适应同步仍由 setExtraState 暂存,协议相关的配置仍归
   OutputManager。

Influence:
1. 修改分辨率,确认窗口按新尺寸重排。
2. 旋转屏幕,确认动画中点交换尺寸。
3. 修改缩放,确认逻辑尺寸更新且画面不被拉伸。

Log: Output geometry only changes the item and viewport; rotation follows the output transform.
PMS:
@zccrs
zccrs force-pushed the wsg-batch-renderer-base branch from 4b7ccac to d76b13e Compare November 17, 2026 09:14
@deepin-bot

deepin-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.12.0
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1686

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zccrs
zccrs merged commit 9b5dcf4 into linuxdeepin:master Nov 18, 2026
9 of 10 checks passed
@LFRon

LFRon commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

终于合入了😭😭😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants